Skip to main content
Glama
Alexander-Panov

Finam MCP Server

market_data_get_bars

Retrieve historical market data as aggregated candlesticks for specified financial instruments within defined time periods and intervals to support analysis and decision-making.

Instructions

Получение исторических данных по инструменту (агрегированные свечи)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYessymbol в формате: SYMBOL@MIC (например, YDEX@MISX)
start_timeYes
end_timeYes
timeframeYes

Implementation Reference

  • Handler function for the 'market_data_get_bars' tool. It uses type annotations for input validation (Symbol, AwareDatetime, TimeFrame) and returns BarsResponse. Proxies the call to FinamClient.get_bars via get_finam_client() utility.
    @market_data_mcp.tool(tags={"market_data"}) async def get_bars(symbol: Symbol, start_time: AwareDatetime, end_time: AwareDatetime, timeframe: TimeFrame) -> BarsResponse: """Получение исторических данных по инструменту (агрегированные свечи)""" return await get_finam_client().get_bars(symbol, start_time, end_time, timeframe)
  • src/main.py:13-13 (registration)
    Registers the market_data_mcp FastMCP server with prefix 'market_data', making the get_bars tool available as 'market_data_get_bars'.
    finam_mcp.mount(market_data_mcp, prefix="market_data")
  • Pydantic type definition for the 'symbol' input parameter, with regex validation 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"] ) ]
  • Core implementation of get_bars in FinamClient, which makes the actual API request to Finam Trade API for bars data and parses into BarsResponse.
    async def get_bars(self, symbol: str, start_time: datetime, end_time: datetime, timeframe: TimeFrame): market_client = self.client.instruments return BarsResponse(**await self._exec_request(market_client, BaseClient.RequestMethod.GET, f"{market_client._url}/{symbol}/bars", params={ "timeframe": timeframe.value, "interval.start_time": start_time.isoformat(), "interval.end_time": end_time.isoformat(), }, ))
  • Utility function to retrieve the shared FinamClient instance from MCP context state.
    def get_finam_client() -> FinamClient: return get_context().get_state("finam_client")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Alexander-Panov/finam-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server