get_holdings
Fetch current equity holdings with average buy price, current value, and profit/loss percentage to track investment performance.
Instructions
Fetch all current equity holdings with avg buy price, current value, P&L %
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/portfolio.ts:15-42 (handler)The "get_holdings" tool is registered and implemented within `registerPortfolioTools` in `src/tools/portfolio.ts`. It fetches holdings data from the `growwClient` and formats it into a text response for the MCP server.
// ── get_holdings ────────────────────────────────────────── server.tool( "get_holdings", "Fetch all current equity holdings with avg buy price, current value, P&L %", {}, async () => { try { const holdings = await growwClient.getHoldings(); if (holdings.length === 0) return mcpText("📭 No holdings found. Your portfolio is empty."); const lines = holdings.map((h) => { const emoji = pnlEmoji(h.pnl); return [ `${emoji} ${h.symbol}.${h.exchange} — ${h.name}`, ` Qty: ${h.quantity} | Avg: ${formatCurrencyExact(h.avgBuyPrice)} | LTP: ${formatCurrencyExact(h.currentPrice)}`, ` Invested: ${formatCurrency(h.investedValue)} | Current: ${formatCurrency(h.currentValue)}`, ` P&L: ${pnlSign(h.pnl)} (${formatPercent(h.pnlPercent)}) | Day: ${pnlSign(h.dayChange)} (${formatPercent(h.dayChangePercent)})`, ].join("\n"); }); const header = `📊 YOUR HOLDINGS (${holdings.length} stocks)\n${"─".repeat(50)}`; const footer = `\nAs of ${nowIST()}`; return mcpText([header, ...lines, footer].join("\n\n")); } catch (err) { return mcpError(normalizeError(err)); } } );