get_signals
Retrieve trading signals from T-Invest with filters for tickers, time periods, and buy/sell directions to inform investment decisions.
Instructions
Получить торговые сигналы из Т-Инвестиций
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tickers | No | Фильтр по тикерам (если не указан — все сигналы) | |
| from | No | Начало периода (ISO 8601) | |
| to | No | Конец периода (ISO 8601) | |
| direction | No | Фильтр по направлению: buy — покупка, sell — продажа | |
| limit | No | Максимальное количество сигналов |
Implementation Reference
- src/tools/get-signals.ts:11-75 (handler)The 'get_signals' tool registration and handler implementation. It uses Zod for input validation and communicates with the TInvestClient to fetch trading signals.
export function registerGetSignals(server: McpServer, client: TInvestClient): void { server.tool( 'get_signals', 'Получить торговые сигналы из Т-Инвестиций', { tickers: z.array(z.string()).optional().describe('Фильтр по тикерам (если не указан — все сигналы)'), from: z.string().optional().describe('Начало периода (ISO 8601)'), to: z.string().optional().describe('Конец периода (ISO 8601)'), direction: z .enum(['buy', 'sell']) .optional() .describe('Фильтр по направлению: buy — покупка, sell — продажа'), limit: z.number().int().min(1).max(100).default(20).describe('Максимальное количество сигналов'), }, READ_ONLY, async ({ tickers, from, to, direction, limit }) => { try { let instrumentUids: string[] = []; if (tickers && tickers.length > 0) { const instrumentMap = await resolveTickersToInstruments(client, tickers); instrumentUids = Array.from(instrumentMap.values()).map((i) => i.uid); } const body: Record<string, unknown> = { paging: { pageNumber: 0, pageSize: limit }, }; if (instrumentUids.length === 1) body.instrumentUid = instrumentUids[0]; if (from) body.from = from; if (to) body.to = to; if (direction) { body.direction = direction === 'buy' ? 'SIGNAL_DIRECTION_BUY' : 'SIGNAL_DIRECTION_SELL'; } const response = await client.post<GetSignalsResponse>( API_PATHS.SIGNALS.GET_SIGNALS, body, ); if (!response.signals || response.signals.length === 0) { return { content: [{ type: 'text' as const, text: 'Сигналы не найдены.' }] }; } const lines = response.signals.map((s) => { const parts = [ `Направление: ${DIRECTION_LABELS[s.direction] ?? s.direction}`, `Дата: ${formatDateTime(s.createdAt)}`, ]; if (s.name) parts.push(`Название: ${s.name}`); if (s.description) parts.push(`Описание: ${s.description}`); if (s.targetPrice) parts.push(`Целевая цена: ${quotationToNumber(s.targetPrice).toFixed(2)}`); if (s.openPrice) parts.push(`Цена открытия: ${quotationToNumber(s.openPrice).toFixed(2)}`); if (s.validUntil) parts.push(`Действует до: ${formatDateTime(s.validUntil)}`); return parts.join('\n'); }); return { content: [{ type: 'text' as const, text: lines.join(SEPARATOR) }] }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, ); }