getPositions
Retrieve current futures positions on Bitget exchange to monitor open trades, track exposure, and manage risk with optional symbol filtering.
Instructions
Get current futures positions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | No | Filter by symbol |
Implementation Reference
- src/api/rest-client.ts:757-779 (handler)Core handler function that executes the logic to fetch current futures positions from Bitget API via REST endpoint '/api/v2/mix/position/all-position' and maps response to Position objectsasync getFuturesPositions(symbol?: string): Promise<Position[]> { const params: any = { productType: 'USDT-FUTURES' }; if (symbol) { // Add _UMCBL suffix for futures if not present params.symbol = symbol.includes('_') ? symbol : `${symbol}_UMCBL`; } const response = await this.request<any>('GET', '/api/v2/mix/position/all-position', params, true); const positions = response.data || []; return positions.map((position: any) => ({ symbol: position.symbol, side: position.holdSide || (parseFloat(position.size || '0') > 0 ? 'long' : 'short'), size: Math.abs(parseFloat(position.size || position.total || '0')).toString(), entryPrice: position.averageOpenPrice || position.openPriceAvg, markPrice: position.markPrice, pnl: position.unrealizedPL || position.achievedProfits, pnlPercent: position.unrealizedPLR || '0', margin: position.margin || position.marginSize, leverage: position.leverage, timestamp: parseInt(position.cTime || Date.now().toString()) })); }
- src/server.ts:427-438 (handler)MCP server tool call handler for 'getPositions' that validates input and delegates to BitgetRestClient.getFuturesPositionscase 'getPositions': { const { symbol } = GetPositionsSchema.parse(args); const positions = await this.bitgetClient.getFuturesPositions(symbol); return { content: [ { type: 'text', text: JSON.stringify(positions, null, 2), }, ], } as CallToolResult; }
- src/server.ts:205-215 (registration)Registration of the 'getPositions' tool in the ListTools response, defining name, description, and input schema{ name: 'getPositions', description: 'Get current futures positions', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Filter by symbol' } }, required: [] }, },
- src/types/mcp.ts:66-68 (schema)Zod schema defining input validation for getPositions tool parametersexport const GetPositionsSchema = z.object({ symbol: z.string().optional().describe('Filter by symbol') });