fetchOpenOrders
Retrieve all open orders for a specified account and trading symbol using the CCXT MCP Server. Customize results with optional filters like timestamp, order count, and exchange-specific parameters.
Instructions
Fetch all open orders using a configured account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountName | Yes | Account name defined in the configuration file (e.g., 'bybit_main') | |
| limit | No | Limit the number of orders returned (optional) | |
| params | No | Additional exchange-specific parameters | |
| since | No | Timestamp in ms to fetch orders since (optional) | |
| symbol | No | Trading symbol (e.g., 'BTC/USDT') |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"accountName": {
"description": "Account name defined in the configuration file (e.g., 'bybit_main')",
"type": "string"
},
"limit": {
"description": "Limit the number of orders returned (optional)",
"type": "number"
},
"params": {
"additionalProperties": {},
"description": "Additional exchange-specific parameters",
"type": "object"
},
"since": {
"description": "Timestamp in ms to fetch orders since (optional)",
"type": "number"
},
"symbol": {
"description": "Trading symbol (e.g., 'BTC/USDT')",
"type": "string"
}
},
"required": [
"accountName"
],
"type": "object"
}
Implementation Reference
- src/tools/order-tools.ts:239-287 (handler)The asynchronous handler function that retrieves open orders from the CCXT exchange for the specified account, checks if the method is supported, handles errors, and returns JSON-formatted orders.async ({ accountName, symbol, since, limit, params }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // fetchOpenOrders 메서드가 지원되는지 확인 if (!exchange.has["fetchOpenOrders"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching open orders`, }, ], isError: true, }; } const openOrders = await exchange.fetchOpenOrders( symbol, since, limit, params, ); return { content: [ { type: "text", text: JSON.stringify(openOrders, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching open orders for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }, );
- src/tools/order-tools.ts:216-238 (schema)Zod schema defining input parameters for the fetchOpenOrders tool: accountName (required), symbol/since/limit/params (optional).{ accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), symbol: z .string() .optional() .describe("Trading symbol (e.g., 'BTC/USDT')"), since: z .number() .optional() .describe("Timestamp in ms to fetch orders since (optional)"), limit: z .number() .optional() .describe("Limit the number of orders returned (optional)"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), },
- src/tools/order-tools.ts:213-287 (registration)The server.tool() call registering the 'fetchOpenOrders' tool with name, description, input schema, and handler function within registerOrderTools.server.tool( "fetchOpenOrders", "Fetch all open orders using a configured account", { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), symbol: z .string() .optional() .describe("Trading symbol (e.g., 'BTC/USDT')"), since: z .number() .optional() .describe("Timestamp in ms to fetch orders since (optional)"), limit: z .number() .optional() .describe("Limit the number of orders returned (optional)"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), }, async ({ accountName, symbol, since, limit, params }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // fetchOpenOrders 메서드가 지원되는지 확인 if (!exchange.has["fetchOpenOrders"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching open orders`, }, ], isError: true, }; } const openOrders = await exchange.fetchOpenOrders( symbol, since, limit, params, ); return { content: [ { type: "text", text: JSON.stringify(openOrders, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching open orders for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }, );