market_data_get_order_book
Retrieve current order book data for financial instruments on Russian markets to analyze bid-ask spreads and market depth.
Instructions
Получение текущего стакана по инструменту
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | symbol в формате: SYMBOL@MIC (например, YDEX@MISX) |
Implementation Reference
- src/servers/market_data.py:31-34 (handler)The handler function `get_order_book` that implements the core logic of fetching the order book data for a given symbol via the Finam client. Due to the 'market_data' prefix on the MCP server, the tool is exposed as 'market_data_get_order_book'.@market_data_mcp.tool(tags={"market_data"}) async def get_order_book(symbol: Symbol) -> OrderBookResponse: """Получение текущего стакана по инструменту""" return await get_finam_client().get_order_book(symbol)
- src/main.py:13-13 (registration)Registers the market_data_mcp server under the 'market_data' prefix, which prefixes all its tools including 'get_order_book' to become 'market_data_get_order_book'.finam_mcp.mount(market_data_mcp, prefix="market_data")
- src/tradeapi/models.py:8-15 (schema)Pydantic schema for the 'symbol' input parameter used in the tool, providing validation, description, and examples.Symbol: type[str] = Annotated[ str, Field( description="symbol в формате: SYMBOL@MIC (например, YDEX@MISX)", pattern=r"^[A-Z0-9]+@[A-Z]+$", # Regex валидация examples=["YDEX@MISX", "SBER@TQBR"] ) ]
- src/servers/utils.py:6-8 (helper)Utility function to retrieve the FinamClient instance from the MCP context, used by the handler.def get_finam_client() -> FinamClient: return get_context().get_state("finam_client")
- src/servers/market_data.py:31-31 (registration)Registers the 'get_order_book' function as an MCP tool on the market_data_mcp server with 'market_data' tag.@market_data_mcp.tool(tags={"market_data"})