Skip to content

trading_agent.tools.get_orders_tool

The get_orders tool: the order book, the trades, or the orders UBI's engine is holding.

Typical usage example:

tool = GetOrdersTool(reader, formatter)

GetOrdersArguments

Bases: BaseModel

The arguments of get_orders.

Attributes:

Name Type Description
kind Literal['orders', 'trades', 'open_parents']

"orders" for today's orders at the brokers, "trades" for today's fills, "open_parents" for orders UBI's engine is still holding or working, such as limit orders and stops.

GetOrdersTool

GetOrdersTool(reader, formatter)

Bases: BrokerTool

Reads the order book.

Source code in src/trading_agent/tools/broker_tool.py
def __init__(
    self,
    reader: broker_reader_module.BrokerReader,
    formatter: result_formatter_module.ResultFormatter,
):
    """Creates the tool.

    Args:
        reader (broker_reader_module.BrokerReader): The shared reader of UBI.
        formatter (result_formatter_module.ResultFormatter): Turns tradingmachine's answers into text.
    """
    self._reader = reader
    self._formatter = formatter

run async

run(arguments)

Reads the order book.

Parameters:

Name Type Description Default
arguments GetOrdersArguments

Which book.

required

Returns:

Type Description
ToolResult

UBI's answer, or an error.

Source code in src/trading_agent/tools/get_orders_tool.py
async def run(self, arguments: GetOrdersArguments) -> tool.ToolResult:
    """Reads the order book.

    Args:
        arguments (GetOrdersArguments): Which book.

    Returns:
        tool.ToolResult: UBI's answer, or an error.
    """
    return await self._answer(functools.partial(self._read, arguments))