get_asset_fundamentals
Retrieve fundamental financial metrics for companies using their stock ticker symbols to analyze investment opportunities and assess company performance.
Instructions
Получить фундаментальные показатели компаний по тикерам
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tickers | Yes | Массив тикеров (до 100) |
Implementation Reference
- The registration function `registerGetAssetFundamentals` contains the handler logic for the `get_asset_fundamentals` tool, including input validation, instrument resolution, API call, and response formatting.
export function registerGetAssetFundamentals(server: McpServer, client: TInvestClient): void { server.tool( 'get_asset_fundamentals', 'Получить фундаментальные показатели компаний по тикерам', { tickers: z.array(z.string()).min(1).max(100).describe('Массив тикеров (до 100)'), }, READ_ONLY, async ({ tickers }) => { try { // Для фундаментала не фильтруем по apiTradeAvailableFlag — нужны все инструменты const instrumentMap = await resolveTickersToInstruments( client, tickers, { apiTradeAvailableFlag: false }, ); const notFound = tickers.filter((t) => !instrumentMap.has(t.toUpperCase())); if (instrumentMap.size === 0) { return { content: [{ type: 'text' as const, text: 'Инструменты по указанным тикерам не найдены.' }], isError: true, }; } const uidToTicker = new Map( Array.from(instrumentMap.entries()).map(([ticker, inst]) => [inst.uid, ticker]), ); const response = await client.post<GetAssetFundamentalsResponse>( API_PATHS.INSTRUMENTS.GET_ASSET_FUNDAMENTALS, { assets: Array.from(uidToTicker.keys()) }, ); if (!response.fundamentals || response.fundamentals.length === 0) { return { content: [{ type: 'text' as const, text: 'Фундаментальные данные не найдены.' }] }; } const results: string[] = []; for (const fundamental of response.fundamentals) { const ticker = uidToTicker.get(fundamental.assetUid ?? '') ?? 'N/A'; results.push(formatFundamental(ticker, fundamental)); } if (notFound.length > 0) { results.push(`\nНе найдены тикеры: ${notFound.join(', ')}`); } return { content: [{ type: 'text' as const, text: results.join(SEPARATOR) }] }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, ); }