cancel_order
Cancel a stock exchange order in T-Invest by providing account and order IDs. Requires confirmation to execute the cancellation.
Instructions
Отменить биржевую заявку в Т-Инвестициях (требуется confirm: true для исполнения)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Идентификатор счёта | |
| orderId | Yes | ID заявки (можно получить через get_orders) | |
| confirm | No | Передайте true для подтверждения отмены |
Implementation Reference
- src/tools/cancel-order.ts:25-50 (handler)The handler logic for the 'cancel_order' tool.
async ({ accountId, orderId, confirm }) => { try { if (requireConfirmation && confirm !== true) { return { content: [{ type: 'text' as const, text: `Подтвердите отмену заявки:\n ID заявки: ${orderId}\n Счёт: ${accountId}\n\nДля отмены вызовите повторно с confirm: true`, }], }; } const response = await client.post<CancelOrderResponse>( API_PATHS.ORDERS.CANCEL_ORDER, { accountId, orderId }, ); return { content: [{ type: 'text' as const, text: `Заявка ${orderId} отменена в ${formatDateTime(response.time)}` }], }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, - src/tools/cancel-order.ts:14-51 (registration)Registration of the 'cancel_order' tool within the server.
server.tool( 'cancel_order', requireConfirmation ? 'Отменить биржевую заявку в Т-Инвестициях (требуется confirm: true для исполнения)' : 'Отменить биржевую заявку в Т-Инвестициях', { accountId: z.string().describe('Идентификатор счёта'), orderId: z.string().describe('ID заявки (можно получить через get_orders)'), confirm: z.boolean().optional().describe('Передайте true для подтверждения отмены'), }, DESTRUCTIVE, async ({ accountId, orderId, confirm }) => { try { if (requireConfirmation && confirm !== true) { return { content: [{ type: 'text' as const, text: `Подтвердите отмену заявки:\n ID заявки: ${orderId}\n Счёт: ${accountId}\n\nДля отмены вызовите повторно с confirm: true`, }], }; } const response = await client.post<CancelOrderResponse>( API_PATHS.ORDERS.CANCEL_ORDER, { accountId, orderId }, ); return { content: [{ type: 'text' as const, text: `Заявка ${orderId} отменена в ${formatDateTime(response.time)}` }], }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, );