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
| Name | Required | Description | Default |
|---|---|---|---|
| accountName | Yes | Account name defined in the configuration file (e.g., 'bybit_main') | |
| symbol | No | Trading symbol (e.g., 'BTC/USDT') | |
| since | No | Timestamp in ms to fetch trades since (optional) | |
| limit | No | Limit the number of trades returned (optional) |
Implementation Reference
- src/tools/account-tools.ts:270-312 (handler)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, }; } }
- src/tools/account-tools.ts:252-269 (schema)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)"), },
- src/tools/account-tools.ts:248-313 (registration)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);