CREATE_ORDER
Execute buy or sell orders on the Upbit cryptocurrency exchange using private API credentials. Specify market, order type, volume, and price parameters to place trades programmatically.
Instructions
Create an Upbit order (requires private API)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market | Yes | ||
| side | Yes | ||
| ord_type | Yes | ||
| volume | No | ||
| price | No | ||
| time_in_force | No | ||
| smp_type | No | ||
| identifier | No |
Implementation Reference
- src/tools/create-order.ts:32-67 (handler)The createOrderTool object defining the CREATE_ORDER tool, including name, description, parameters schema reference, and the execute handler function that performs the order creation via Upbit's private API.export const createOrderTool = { name: "CREATE_ORDER", description: "Create an Upbit order (requires private API)", parameters: paramsSchema, execute: async ({ market, side, ord_type, volume, price, time_in_force, smp_type, identifier, }: Params) => { ensurePrivateEnabled(); const baseURL = `${config.upbit.baseUrl}${config.upbit.apiBasePath}`; const client = createHttpClient(baseURL); const body = { market, side, ord_type, volume, price, time_in_force, smp_type, identifier, }; const token = signJwtToken(body); const data = await fetchJson<unknown>(client, "/orders", { method: "POST", data: body, headers: { Authorization: `Bearer ${token}` }, }); return JSON.stringify(data, null, 2); }, } as const;
- src/tools/create-order.ts:6-28 (schema)Zod schema (paramsSchema) for validating input parameters to the CREATE_ORDER tool, including refinements for different order types.const paramsSchema = z .object({ market: z.string(), side: z.enum(["bid", "ask"]), ord_type: z.enum(["limit", "price", "market"]), volume: z.string().optional(), price: z.string().optional(), time_in_force: z.enum(["ioc", "fok", "post_only"]).optional(), smp_type: z.enum(["cancel_maker", "cancel_taker", "reduce"]).optional(), identifier: z.string().optional(), }) .refine((p) => (p.ord_type === "limit" ? p.volume && p.price : true), { message: "Limit orders require both volume and price", }) .refine((p) => (p.ord_type === "price" ? !!p.price : true), { message: "Market buy (price) requires price", }) .refine((p) => (p.ord_type === "market" ? !!p.volume : true), { message: "Market sell (market) requires volume", }) .refine((p) => !(p.time_in_force === "post_only" && p.smp_type), { message: "post_only cannot be used with smp_type", });
- src/index.ts:35-35 (registration)Registers the createOrderTool with the FastMCP server instance.server.addTool(createOrderTool);