order_cancel
Cancel an exchange order by providing the order ID to manage trading positions on Russian financial markets through the Finam trading platform.
Instructions
Отмена биржевой заявки
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_id | Yes |
Implementation Reference
- src/servers/order.py:29-32 (handler)Handler function for the 'order_cancel' MCP tool (prefixed from 'cancel'), executes the order cancellation via the Finam client.@order_mcp.tool(tags={"order"}, meta={"sensitive": True}) async def cancel(order_id: str) -> OrderState: """Отмена биржевой заявки""" return await get_finam_client().cancel_order(order_id)
- src/main.py:15-15 (registration)Registers the order_mcp tools with 'order' prefix, making 'cancel' available as 'order_cancel'.finam_mcp.mount(order_mcp, prefix="order")
- src/tradeapi/order/models.py:110-118 (schema)Pydantic model for OrderState, used as the return type schema for the order_cancel tool.class OrderState(BaseModel): """Состояние заявки""" order_id: str = Field(..., description="Идентификатор заявки") exec_id: str | None = Field(None, description="Идентификатор исполнения") status: OrderStatus = Field(..., description="Статус заявки") order: Order = Field(..., description="Заявка") transact_at: datetime | None = Field(None, description="Дата и время выставления заявки") accept_at: datetime | None = Field(None, description="Дата и время принятия заявки") withdraw_at: datetime | None = Field(None, description="Дата и время отмены заявки")
- src/tradeapi/order/orders.py:56-67 (helper)Underlying API client method called by the handler to perform the order cancellation.async def cancel_order(self, order_id: str, account_id: str) -> OrderState: """Отмена биржевой заявки""" response, ok = await self._exec_request( self.RequestMethod.DELETE, self._url.format(account_id=account_id) + f"/{order_id}", ) if not ok: err = ErrorModel(**response) raise FinamTradeApiError(f"code={err.code} | message={err.message} | details={err.details}") return OrderState(**response)
- src/servers/utils.py:6-8 (helper)Utility function to retrieve the FinamClient instance used in the handler.def get_finam_client() -> FinamClient: return get_context().get_state("finam_client")