get_order_history
Retrieve past trading orders on Bybit exchange to analyze performance, track transactions, and manage account activity. Filter by category, symbol, time range, or status for specific order history review.
Instructions
Get order history
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| symbol | No | Symbol (e.g., BTCUSDT) | |
| orderId | No | Order ID | |
| orderLinkId | No | Order link ID | |
| orderFilter | No | Order filter | |
| orderStatus | No | Order status | |
| startTime | No | Start time in milliseconds | |
| endTime | No | End time in milliseconds | |
| limit | No | Number of orders to retrieve |
Implementation Reference
- src/bybit-service.ts:344-364 (handler)Core handler function that constructs API parameters and calls makeBybitRequest to fetch order history from Bybit's /v5/order/history endpoint.async getOrderHistory( category: string, symbol?: string, orderId?: string, orderLinkId?: string, orderFilter?: string, orderStatus?: string, startTime?: number, endTime?: number, limit: number = 50 ): Promise<BybitResponse<{ list: Order[] }> | { error: string }> { const params: any = { category, limit }; if (symbol) params.symbol = symbol; if (orderId) params.orderId = orderId; if (orderLinkId) params.orderLinkId = orderLinkId; if (orderFilter) params.orderFilter = orderFilter; if (orderStatus) params.orderStatus = orderStatus; if (startTime) params.startTime = startTime; if (endTime) params.endTime = endTime; return this.makeBybitRequest('/v5/order/history', 'GET', params); }
- src/index.ts:303-348 (schema)Input schema definition for the get_order_history tool, registered in ListToolsRequestSchema handler, defining parameters like category, symbol, etc.{ name: 'get_order_history', description: 'Get order history', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, orderId: { type: 'string', description: 'Order ID', }, orderLinkId: { type: 'string', description: 'Order link ID', }, orderFilter: { type: 'string', description: 'Order filter', }, orderStatus: { type: 'string', description: 'Order status', }, startTime: { type: 'number', description: 'Start time in milliseconds', }, endTime: { type: 'number', description: 'End time in milliseconds', }, limit: { type: 'number', description: 'Number of orders to retrieve', default: 50, }, }, required: ['category'], },
- src/index.ts:848-868 (registration)MCP tool dispatch/registration in the CallToolRequestSchema switch statement, mapping tool call to BybitService.getOrderHistory execution and response formatting.case 'get_order_history': { const result = await this.bybitService.getOrderHistory( typedArgs.category, typedArgs.symbol, typedArgs.orderId, typedArgs.orderLinkId, typedArgs.orderFilter, typedArgs.orderStatus, typedArgs.startTime, typedArgs.endTime, typedArgs.limit ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }