Skip to main content
Glama

fetchMyTrades

Retrieve personal trade history from cryptocurrency exchanges to track transactions, analyze performance, and maintain records for configured trading accounts.

Instructions

Fetch personal trade history for 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 trades since (optional)
limitNoLimit the number of trades returned (optional)

Implementation Reference

  • The main handler function for the 'fetchMyTrades' tool. It retrieves the CCXT exchange instance for the given account, checks if fetchMyTrades is supported, fetches the trades, and returns them as JSON or an error message.
    async ({ accountName, symbol, since, limit }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // fetchMyTrades 메서드가 지원되는지 확인 if (!exchange.has["fetchMyTrades"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades`, }, ], isError: true, }; } const trades = await exchange.fetchMyTrades(symbol, since, limit); return { content: [ { type: "text", text: JSON.stringify(trades, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching personal trades for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }
  • Zod schema defining the input parameters for the fetchMyTrades tool: accountName (required), symbol (optional), since (optional), limit (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 trades since (optional)"), limit: z .number() .optional() .describe("Limit the number of trades returned (optional)"), },
  • The server.tool() call that registers the 'fetchMyTrades' tool with MCP server, including description, input schema, and handler function.
    server.tool( "fetchMyTrades", "Fetch personal trade history for 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 trades since (optional)"), limit: z .number() .optional() .describe("Limit the number of trades returned (optional)"), }, async ({ accountName, symbol, since, limit }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // fetchMyTrades 메서드가 지원되는지 확인 if (!exchange.has["fetchMyTrades"]) { return { content: [ { type: "text", text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades`, }, ], isError: true, }; } const trades = await exchange.fetchMyTrades(symbol, since, limit); return { content: [ { type: "text", text: JSON.stringify(trades, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching personal trades for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } } );
  • src/server.ts:374-374 (registration)
    The call to registerAccountTools in the main CcxtMcpServer class's registerTools() method, which triggers the registration of fetchMyTrades among other account tools.
    registerAccountTools(this.server, this);

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