Skip to main content
Glama

fetchClosedOrders

Retrieve all completed orders from cryptocurrency exchanges to track trading history, analyze performance, and maintain records using configured exchange accounts.

Instructions

Fetch all closed 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 handler function that implements the fetchClosedOrders tool. It retrieves the CCXT exchange instance, checks if fetchClosedOrders is supported, fetches the closed orders, and returns them as JSON or an error message.
    async ({ accountName, symbol, since, limit, params }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // fetchClosedOrders 메서드가 지원되는지 확인 if (!exchange.has["fetchClosedOrders"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching closed orders`, }, ], isError: true, }; } const closedOrders = await exchange.fetchClosedOrders( symbol, since, limit, params, ); return { content: [ { type: "text", text: JSON.stringify(closedOrders, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching closed orders for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } },
  • The Zod schema defining the input parameters for the fetchClosedOrders tool: accountName (required), symbol, since, limit, params (all 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"), },
  • The registration of the fetchClosedOrders tool using server.tool(), including name, description, input schema, and handler function. This is within the registerOrderTools function.
    server.tool( "fetchClosedOrders", "Fetch all closed 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가 성공하면 인증은 보장됨 // fetchClosedOrders 메서드가 지원되는지 확인 if (!exchange.has["fetchClosedOrders"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching closed orders`, }, ], isError: true, }; } const closedOrders = await exchange.fetchClosedOrders( symbol, since, limit, params, ); return { content: [ { type: "text", text: JSON.stringify(closedOrders, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching closed orders for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }, ); }

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