get_positions
Retrieve current trading positions on Bybit exchange to monitor open trades, view position details, and manage portfolio exposure.
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 that makes the Bybit API request to /v5/position/list to retrieve position information.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 tool call handler that delegates to BybitService.getPositions and formats the response.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 (schema)Input schema and metadata for the get_positions tool, registered in ListTools response.{ 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 defining the Position object structure used in getPositions response.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; }