finance_portfolio_tracker
Calculate portfolio value and allocation from holdings data to track financial investments and analyze asset distribution.
Instructions
Calculate portfolio value and allocation from a list of holdings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| holdings | Yes | Comma-separated holdings: 'BTC:0.5,ETH:10,SOL:100' or 'AAPL:50,MSFT:30' |
Implementation Reference
- src/modules/finance.ts:36-45 (handler)The implementation of the finance_portfolio_tracker tool, which parses a comma-separated list of holdings and returns a markdown table of the portfolio.
server.tool("finance_portfolio_tracker", "Calculate portfolio value and allocation from a list of holdings", { holdings: z.string().describe("Comma-separated holdings: 'BTC:0.5,ETH:10,SOL:100' or 'AAPL:50,MSFT:30'") }, async ({ holdings }) => { const items = holdings.split(",").map(h => { const [asset, qty] = h.trim().split(":"); return { asset: asset.trim(), qty: parseFloat(qty) || 0 }; }); const rows = items.map(i => [i.asset.toUpperCase(), i.qty.toString(), "Pending lookup", "Pending"]); return { content: [{ type: "text", text: `**Portfolio Tracker**\n\n${mdTable(["Asset", "Qty", "Price", "Value"], rows)}\n\n*Use crypto_price or finance_stock_price to look up individual prices, then calculate total.*` }] }; });