Skip to main content
Glama

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
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
symbolNoSymbol (e.g., BTCUSDT)

Implementation Reference

  • 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); }
  • 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'], }, },
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kondisettyravi/mcp-bybit-node'

If you have feedback or need assistance with the MCP directory API, please join our Discord server