get_positions
Retrieve current intraday open positions with unrealized profit and loss data for equity holdings on Groww.
Instructions
Intraday open positions with unrealized P&L
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/portfolio.ts:70-95 (handler)The MCP tool handler for 'get_positions' which calls the Groww client and formats the response for the MCP server.
// ── get_positions ───────────────────────────────────────── server.tool( "get_positions", "Intraday open positions with unrealized P&L", {}, async () => { try { const positions = await growwClient.getPositions(); if (positions.length === 0) return mcpText("📭 No open positions today."); const lines = positions.map((p) => { const emoji = pnlEmoji(p.pnl); return [ `${emoji} ${p.symbol}.${p.exchange} [${p.orderType} / ${p.productType}]`, ` Qty: ${p.quantity} | Buy: ${formatCurrencyExact(p.buyPrice)} | LTP: ${formatCurrencyExact(p.currentPrice)}`, ` Unrealized P&L: ${pnlSign(p.pnl)} (${formatPercent(p.pnlPercent)})`, ].join("\n"); }); const header = `⚡ OPEN POSITIONS (${positions.length})\n${"─".repeat(50)}`; return mcpText([header, ...lines, `\nAs of ${nowIST()}`].join("\n\n")); } catch (err) { return mcpError(normalizeError(err)); } } ); - src/client.ts:91-94 (helper)The client method that fetches position data from the API or mock data.
async getPositions(): Promise<Position[]> { if (isMockMode()) return MOCK.positions(); return this.request<Position[]>("GET", "/portfolio/positions"); }