place_buy_order
Execute stock purchase orders for Kiwoom Securities accounts. Supports market or limit orders by specifying stock code, quantity, and price.
Instructions
주식 매수 주문을 실행합니다. 시장가 또는 지정가 매수를 지원합니다
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stock_code | Yes | 종목코드 (예: 005930) | |
| quantity | Yes | 주문 수량 | |
| price | No | 주문 가격 (시장가일 경우 0) | |
| order_type | No | 주문유형: market(시장가) 또는 limit(지정가) | market |
| account_no | No | 계좌번호 (미입력시 기본 계좌 사용) |
Implementation Reference
- src/index.ts:236-249 (handler)The actual API interaction implementation for placing a buy order.
async placeBuyOrder(accountNo: string, stockCode: string, quantity: number, price: number, orderType: string) { const trde_tp = orderType === "market" ? "3" : "0"; const body: Record<string, unknown> = { acc_no: accountNo, dmst_stex_tp: "KRX", stk_cd: stockCode, ord_qty: String(quantity), trde_tp, }; if (orderType === "limit") { body.ord_uv = String(price); } return this.request("/api/dostk/ordr", "kt10000", body); } - src/index.ts:663-690 (registration)The MCP tool definition and registration for place_buy_order, including input schema and tool handler logic.
server.tool( "place_buy_order", "주식 매수 주문을 실행합니다. 시장가 또는 지정가 매수를 지원합니다", { stock_code: stockCodeSchema, quantity: z.number().int().positive().describe("주문 수량"), price: z.number().int().min(0).default(0).describe("주문 가격 (시장가일 경우 0)"), order_type: z.enum(["market", "limit"]).default("market").describe("주문유형: market(시장가) 또는 limit(지정가)"), account_no: accountNoSchema, }, { readOnlyHint: false, idempotentHint: false }, async ({ stock_code, quantity, price, order_type, account_no }) => { try { const acct = resolveAccountNo(account_no); if (order_type === "limit" && price <= 0) { return errorContent("지정가 주문 시 가격을 0보다 큰 값으로 입력해주세요."); } const data = await client.placeBuyOrder(acct, stock_code, quantity, price, order_type); const orderNo = data.ord_no ?? "N/A"; const typeLabel = order_type === "market" ? "시장가" : `지정가 ${formatCurrency(price)}`; let text = `## 매수 주문 완료\n\n`; text += `- 주문번호: ${orderNo}\n`; text += `- 종목코드: ${stock_code}\n`; text += `- 주문유형: ${typeLabel}\n`; text += `- 주문수량: ${quantity}주\n`; if (IS_MOCK) text += "\n(모의투자 주문)\n"; return textContent(text); } catch (error) {