get_max_lots
Calculate the maximum number of lots you can buy or sell in T-Invest by providing account ID, ticker, and optional price.
Instructions
Рассчитать максимальное количество лотов для покупки/продажи в Т-Инвестициях
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Идентификатор счёта | |
| ticker | Yes | Тикер инструмента | |
| price | No | Цена для расчёта (по умолчанию — рыночная) |
Implementation Reference
- src/tools/get-max-lots.ts:10-55 (handler)The tool registration and handler implementation for "get_max_lots".
export function registerGetMaxLots(server: McpServer, client: TInvestClient): void { server.tool( 'get_max_lots', 'Рассчитать максимальное количество лотов для покупки/продажи в Т-Инвестициях', { accountId: z.string().describe('Идентификатор счёта'), ticker: z.string().describe('Тикер инструмента'), price: z.number().positive().optional().describe('Цена для расчёта (по умолчанию — рыночная)'), }, READ_ONLY, async ({ accountId, ticker, price }) => { try { const item = await resolveTickerToInstrument(client, ticker); if (!item) { return { content: [{ type: 'text' as const, text: `Инструмент "${ticker}" не найден.` }], isError: true }; } const body: Record<string, unknown> = { accountId, instrumentId: item.uid }; if (price !== undefined) { body.price = toQuotation(price); } const response = await client.post<GetMaxLotsResponse>( API_PATHS.ORDERS.GET_MAX_LOTS, body, ); const lines = [ `${ticker}:`, ` Макс. покупка (рынок): ${response.buyMarketMax ?? 'н/д'} лот(ов)`, ` Макс. покупка (лимит): ${response.buyLimitMax ?? 'н/д'} лот(ов)`, ` Макс. продажа (рынок): ${response.sellMarketMax ?? 'н/д'} лот(ов)`, ` Макс. продажа (лимит): ${response.sellLimitMax ?? 'н/д'} лот(ов)`, ` Валюта: ${response.currency}`, ]; return { content: [{ type: 'text' as const, text: lines.join('\n') }] }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, ); }