Skip to main content
Glama

fetchOpenOrders

Retrieve all open orders from a cryptocurrency exchange account to monitor active trades and manage positions.

Instructions

Fetch all open orders using a configured account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountNameYesAccount name defined in the configuration file (e.g., 'bybit_main')
symbolNoTrading symbol (e.g., 'BTC/USDT')
sinceNoTimestamp in ms to fetch orders since (optional)
limitNoLimit the number of orders returned (optional)
paramsNoAdditional exchange-specific parameters

Implementation Reference

  • The main handler function for the 'fetchOpenOrders' MCP tool. It retrieves the authenticated CCXT exchange instance, checks if the exchange supports fetchOpenOrders, executes the method with provided parameters (symbol, since, limit, params), and returns the result as JSON or an error response.
    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, }; } }, );
  • Zod input schema defining parameters for the fetchOpenOrders tool: accountName (string, required), symbol (string, optional), since (number, optional), limit (number, optional), params (record, 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"), },
  • Local registration of the fetchOpenOrders tool within the registerOrderTools function using server.tool(name, description, inputSchema, handler).
    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, }; } }, );
  • src/server.ts:373-373 (registration)
    Top-level registration call to registerOrderTools in CcxtMcpServer.registerTools(), which includes registering the fetchOpenOrders tool.
    registerOrderTools(this.server, this);
  • Helper method used by the handler to retrieve the pre-loaded, authenticated CCXT Exchange instance for the specified accountName.
    getExchangeInstance(accountName: string): Exchange { const instance = this.exchangeInstances[accountName]; if (!instance) { console.error( `No pre-loaded exchange instance found for account name: ${accountName}`, ); // Consider listing available account names: Object.keys(this.exchangeInstances).join(', ') throw new Error( `Account configuration not found or failed to load for: ${accountName}`, ); } return instance; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lazy-dinosaur/ccxt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server