get_positions
Retrieve detailed position information for specific trading categories and symbols on Bybit, facilitating accurate market analysis and trading decisions.
Instructions
Get position information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| symbol | No | Symbol (e.g., BTCUSDT) |
Implementation Reference
- src/bybit-service.ts:166-179 (handler)Core handler function implementing the get_positions tool logic: constructs parameters and calls Bybit API /v5/position/list endpoint.async getPositions(category: string, symbol?: string): Promise<BybitResponse<{ list: Position[] }> | { error: string }> { const params: any = { category }; if (symbol) { params.symbol = symbol; } else { // Add settleCoin for linear/inverse when no symbol specified if (category === 'linear') { params.settleCoin = 'USDT'; } else if (category === 'inverse') { params.settleCoin = 'BTC'; } } return this.makeBybitRequest('/v5/position/list', 'GET', params); }
- src/index.ts:781-791 (handler)MCP CallToolRequest handler case for 'get_positions': delegates to BybitService.getPositions and returns JSON-formatted result.case 'get_positions': { const result = await this.bybitService.getPositions(typedArgs.category, typedArgs.symbol); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:157-174 (registration)Registration of 'get_positions' tool in ListTools response: includes name, description, and input schema.{ name: 'get_positions', description: 'Get position information', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, }, required: ['category'], }, },
- src/types.ts:72-106 (schema)TypeScript interface definition for Position objects returned in getPositions response (list: Position[]).export interface Position { symbol: string; side: string; size: string; avgPrice: string; positionValue: string; tradeMode: number; positionIdx: number; riskId: number; riskLimitValue: string; entryPrice: string; markPrice: string; liqPrice: string; bustPrice: string; positionMM: string; positionIM: string; tpslMode: string; takeProfit: string; stopLoss: string; trailingStop: string; unrealisedPnl: string; cumRealisedPnl: string; sessionAvgPrice: string; sessionUPL: string; leverage: string; autoAddMargin: number; positionStatus: string; adlRankIndicator: number; isReduceOnly: boolean; mmrSysUpdatedTime: string; leverageSysUpdatedTime: string; createdTime: string; updatedTime: string; seq: number; }