get_orders
Retrieve active exchange orders for a T-Invest account to monitor pending trades and manage investment positions.
Instructions
Получить активные биржевые заявки по счёту в Т-Инвестициях
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Идентификатор счёта (можно получить через get_accounts) |
Implementation Reference
- src/tools/get-orders.ts:13-60 (handler)The handler implementation for the 'get_orders' MCP tool.
server.tool( 'get_orders', 'Получить активные биржевые заявки по счёту в Т-Инвестициях', { accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'), }, READ_ONLY, async ({ accountId }) => { try { const response = await client.post<GetOrdersResponse>( API_PATHS.ORDERS.GET_ORDERS, { accountId }, ); if (!response.orders || response.orders.length === 0) { return { content: [{ type: 'text' as const, text: 'Активных заявок нет.' }] }; } const settled = await inBatches( response.orders, (order) => resolveInstrumentByFigi(client, order.figi), ); const lines = response.orders.map((order, i) => { const result = settled[i]; const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi; const parts = [ `Тикер: ${ticker}`, `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`, `Тип: ${ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`, `Статус: ${ORDER_STATUS_LABELS[order.executionReportStatus] ?? order.executionReportStatus}`, `Лотов запрошено / исполнено: ${order.lotsRequested} / ${order.lotsExecuted}`, ]; if (order.initialOrderPrice) parts.push(`Цена заявки: ${formatMoney(order.initialOrderPrice)}`); if (order.totalOrderAmount) parts.push(`Сумма: ${formatMoney(order.totalOrderAmount)}`); if (order.orderDate) parts.push(`Дата: ${formatDateTime(order.orderDate)}`); 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, }; } }, ); - src/tools/get-orders.ts:12-61 (registration)Registration function for the 'get_orders' MCP tool.
export function registerGetOrders(server: McpServer, client: TInvestClient): void { server.tool( 'get_orders', 'Получить активные биржевые заявки по счёту в Т-Инвестициях', { accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'), }, READ_ONLY, async ({ accountId }) => { try { const response = await client.post<GetOrdersResponse>( API_PATHS.ORDERS.GET_ORDERS, { accountId }, ); if (!response.orders || response.orders.length === 0) { return { content: [{ type: 'text' as const, text: 'Активных заявок нет.' }] }; } const settled = await inBatches( response.orders, (order) => resolveInstrumentByFigi(client, order.figi), ); const lines = response.orders.map((order, i) => { const result = settled[i]; const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi; const parts = [ `Тикер: ${ticker}`, `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`, `Тип: ${ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`, `Статус: ${ORDER_STATUS_LABELS[order.executionReportStatus] ?? order.executionReportStatus}`, `Лотов запрошено / исполнено: ${order.lotsRequested} / ${order.lotsExecuted}`, ]; if (order.initialOrderPrice) parts.push(`Цена заявки: ${formatMoney(order.initialOrderPrice)}`); if (order.totalOrderAmount) parts.push(`Сумма: ${formatMoney(order.totalOrderAmount)}`); if (order.orderDate) parts.push(`Дата: ${formatDateTime(order.orderDate)}`); 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, }; } }, ); }