Skip to content

trading_agent.tools.get_quote_tool

The get_quote tool: the live quote of one instrument, with market depth.

Typical usage example:

tool = GetQuoteTool(reader, formatter)

GetQuoteTool

GetQuoteTool(reader, formatter)

Bases: BrokerTool

Reads one instrument's quote.

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 quote.

Parameters:

Name Type Description Default
arguments InstrumentArguments

The instrument.

required

Returns:

Type Description
ToolResult

The quote, or an error.

Source code in src/trading_agent/tools/get_quote_tool.py
async def run(
    self,
    arguments: instrument_arguments.InstrumentArguments,
) -> tool.ToolResult:
    """Reads the quote.

    Args:
        arguments (instrument_arguments.InstrumentArguments): The instrument.

    Returns:
        tool.ToolResult: The quote, or an error.
    """
    return await self._answer(functools.partial(self._read, arguments))