get_order_history
Retrieve historical trading orders from Bybit to analyze past transactions, track performance, and review trading activity across spot, linear, inverse, and option markets.
Instructions
Get historical orders
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | ||
| symbol | No | ||
| limit | No |
Implementation Reference
- src/client.ts:110-121 (handler)Core implementation of getOrderHistory that calls Bybit's getHistoricOrders API endpoint.async getOrderHistory(category: string, symbol?: string, limit: number = 20) { try { const response = await this.client.getHistoricOrders({ category: category as any, symbol: symbol, limit: limit }); return response; } catch (error) { throw new Error(`Failed to get order history: ${error instanceof Error ? error.message : JSON.stringify(error)}`); } }
- src/types.ts:62-66 (schema)Zod input schema for the get_order_history tool defining category, optional symbol and limit.export const OrderHistorySchema = z.object({ category: z.enum(['spot', 'linear', 'inverse', 'option']).describe('Product type'), symbol: z.string().optional().describe('Trading symbol'), limit: z.number().min(1).max(50).optional().describe('Number of records to return (default: 20)') });
- src/tools.ts:78-86 (registration)MCP tool registration defining name, description, and input schema for get_order_history.{ name: 'get_order_history', description: 'Get historical orders', inputSchema: { type: 'object', properties: OrderHistorySchema.shape, required: ['category'] } },
- src/server.ts:100-106 (handler)Server-side dispatch handler that routes get_order_history calls to the client implementation.case 'get_order_history': result = await this.client.getOrderHistory( args.category as string, args.symbol as string, args.limit as number ); break;