fetchMyTrades
Retrieve your trade history for a specific cryptocurrency account and symbol through the CCXT MCP Server. Input account details, symbol, and optional filters like timestamp or limit to fetch personal trading data.
Instructions
Fetch personal trade history for a configured account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountName | Yes | Account name defined in the configuration file (e.g., 'bybit_main') | |
| limit | No | Limit the number of trades returned (optional) | |
| since | No | Timestamp in ms to fetch trades since (optional) | |
| symbol | No | Trading symbol (e.g., 'BTC/USDT') |
Implementation Reference
- src/tools/account-tools.ts:270-312 (handler)The handler function that executes the fetchMyTrades tool logic. It gets the CCXT exchange for the account, checks if fetchMyTrades is supported, fetches the trades, and returns them as JSON or handles errors.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/tools/account-tools.ts:251-269 (schema)Zod schema defining the input parameters for the fetchMyTrades tool: accountName (required string), symbol (optional string), since (optional number), limit (optional number).{ 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)"), },
- src/tools/account-tools.ts:248-313 (registration)The server.tool call that registers the fetchMyTrades MCP tool with its name, description, input schema, and handler function within the registerAccountTools 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, }; } } );