cancel_order
Cancel pending stock orders in Kiwoom Securities accounts using original order numbers. Specify quantity or cancel all remaining shares by setting quantity to zero.
Instructions
원주문번호로 미체결 주문을 취소합니다. 수량을 0으로 입력하면 잔량 전부 취소
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original_order_no | Yes | 취소할 원주문번호 | |
| stock_code | Yes | 종목코드 (예: 005930) | |
| quantity | Yes | 취소 수량 (0 입력시 잔량 전부 취소) | |
| account_no | No | 계좌번호 (미입력시 기본 계좌 사용) |
Implementation Reference
- src/index.ts:742-755 (handler)The MCP tool handler for 'cancel_order', which extracts input parameters and calls the client's cancelOrder method.
async ({ original_order_no, stock_code, quantity, account_no }) => { try { const acct = resolveAccountNo(account_no); const data = await client.cancelOrder(acct, original_order_no, stock_code, quantity); let text = `## 주문 취소 완료\n\n`; text += `- 취소 주문번호: ${data.ord_no ?? "N/A"}\n`; text += `- 원주문번호: ${original_order_no}\n`; text += `- 종목코드: ${stock_code}\n`; text += `- 취소수량: ${data.cncl_qty ?? quantity}주\n`; return textContent(text); } catch (error) { return errorContent(formatError(error)); } } - src/index.ts:732-741 (registration)Registration of the 'cancel_order' MCP tool with its schema definition.
server.tool( "cancel_order", "원주문번호로 미체결 주문을 취소합니다. 수량을 0으로 입력하면 잔량 전부 취소", { original_order_no: z.string().describe("취소할 원주문번호"), stock_code: stockCodeSchema, quantity: z.number().int().min(0).describe("취소 수량 (0 입력시 잔량 전부 취소)"), account_no: accountNoSchema, }, { readOnlyHint: false, idempotentHint: false, destructiveHint: true }, - src/index.ts:270-278 (helper)The underlying API client method that performs the network request for cancelling an order.
async cancelOrder(accountNo: string, origOrdNo: string, stockCode: string, quantity: number) { return this.request("/api/dostk/ordr", "kt10003", { acc_no: accountNo, dmst_stex_tp: "KRX", orig_ord_no: origOrdNo, stk_cd: stockCode, cncl_qty: String(quantity), }); }