Sponsored by Deepsite.site

Portfolio Analyzer

Created By
Aakash356Aa month ago
Talk to Claude about your stock portfolio using live market data. Ask things like "Give me a full review of my portfolio this week" or "Any breaking news or SEC filings for my holdings today?", Claude calls the right tools and writes the analysis. 8 tools included: Live portfolio P&L and allocation Technical analysis: RSI, MACD, SMA 20/50/200, Bollinger Bands, support/resistance SEC EDGAR filings (8-K, 10-K, 10-Q) Breaking news scored by market impact (1–10) Fundamentals: valuation ratios, EPS history, next earnings date Side-by-side stock comparison for any ticker Also ships as a full Streamlit web app with candlestick charts and AI-written daily/weekly/monthly investment memos via Claude Sonnet 4.6. Runs entirely locally — no cloud, no extra subscription beyond your own API keys.
Content

Portfolio Tracker & Analyzer

A local-first stock portfolio tracker with a built-in MCP server for Claude Desktop. Talk to Claude naturally — it pulls live prices, technicals, SEC filings, and news from your portfolio without you opening the app.

Python Streamlit MCP License


What is this?

Two tools in one repo:

ToolWhat it does
📊Streamlit web appVisual dashboard: charts, P&L, technicals, AI summaries
🤖MCP serverConnects Claude Desktop to your live portfolio data

No cloud. No subscription beyond your own API keys. Runs entirely on your machine.


MCP Server — Talk to Claude About Your Portfolio

Once connected, just ask Claude:

"Give me a full review of my portfolio this week."
"What's the technical setup for NVDA right now?"
"Any breaking news or SEC filings for my holdings today?"
"Compare GOOGL, META, and AMZN — which looks best technically?"
"What are the upcoming earnings dates for my holdings?"

Claude calls the right tools, fetches live data, and writes the analysis — all using your existing Claude subscription.

8 tools Claude can call

ToolWhat it does
get_portfolioAll holdings: live price, P&L, allocation weight
get_portfolio_metricsReturns, Sharpe, max drawdown, beta vs S&P 500
get_technical_analysisRSI, MACD, SMA 20/50/200, Bollinger Bands, support/resistance
get_fundamentalsValuation ratios, EPS beat/miss history, next earnings date
get_newsLatest headlines from Yahoo Finance + Google News
get_sec_filingsRecent 8-K/10-K/10-Q filings from SEC EDGAR
get_breaking_newsAll fast sources scored by market impact (1–10)
compare_stocksSide-by-side multi-stock comparison

The technical analysis, news, SEC, and comparison tools work for any ticker — not just your portfolio holdings.

MCP Quick Setup

1. Install dependencies

pip install -r requirements.txt

2. Edit the Claude Desktop config

Mac: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "portfolio-analyzer": {
      "command": "python",
      "args": ["/FULL/PATH/TO/portfolio-analyzer/mcp_server.py"]
    }
  }
}

3. Restart Claude Desktop — look for the 🔨 hammer icon in the chat bar.

See MCP_SETUP.md for the full guide including troubleshooting.


Streamlit App

Setup

# 1. Install dependencies (Python 3.9+)
pip install -r requirements.txt

# 2. Add your OpenRouter API key (for AI summaries)
cp .env.example .env
# Edit .env and add your key from https://openrouter.ai/settings/keys

# 3. Run
streamlit run app.py

Open http://localhost:8501 in your browser.

Pages

Dashboard — Total value, cost basis, P&L, allocation pie chart, holdings table

Manage Holdings — Add/remove positions with ticker validation

Stock Analysis — Candlestick chart with SMA/EMA/Bollinger overlays, RSI, MACD, volume, fundamentals, and an AI memo (Claude Sonnet 4.6)

Performance — Portfolio vs S&P 500 (normalized), volatility, Sharpe, drawdown, beta, returns distribution

Summary — Claude Sonnet 4.6 writes a personal investment memo (daily / weekly / monthly) covering winners/losers, SEC events, macro themes, and recommendations

Monitor — Real-time news alerts from SEC EDGAR, Business Wire, PR Newswire, Yahoo, and Google News — scored by market impact


Project Structure

portfolio-analyzer/
├── app.py               # Streamlit app (6 pages)
├── mcp_server.py        # MCP server for Claude Desktop
├── requirements.txt
├── .env.example         # API key template
├── data/
│   ├── portfolio.json   # Your holdings
│   └── summaries/       # Saved AI summaries
└── src/
    ├── analytics.py     # Portfolio metrics & risk
    ├── data_fetcher.py  # yfinance wrapper with caching
    ├── indicators.py    # SMA, EMA, RSI, MACD, Bollinger
    ├── llm.py           # Claude Sonnet 4.6 via OpenRouter
    ├── news_monitor.py  # Multi-source news fetcher + scorer
    ├── portfolio.py     # Load / save / add / remove holdings
    ├── sec_edgar.py     # SEC EDGAR API client
    ├── snaptrade_integration.py  # Auto-import holdings from your brokerage
    └── summary_pipeline.py  # Weekly/daily/monthly memo pipeline

Adding Holdings

There are three ways to get your positions into the tracker. Pick whichever you prefer.

Connect your broker once and import your real positions (shares + cost basis) automatically — no CSVs, no manual typing. Works with Robinhood, Fidelity, Schwab, Vanguard, E*TRADE, Webull, Wealthsimple, and many more.

1. Create a free SnapTrade account Sign up at dashboard.snaptrade.com and verify your email. The free tier gives real brokerage data for a personal account at no cost.

2. Generate an API key in the dashboard — you'll get a Client ID and a Consumer Key.

3. Add them to your .env:

SNAPTRADE_CLIENT_ID=your-snaptrade-client-id
SNAPTRADE_CONSUMER_KEY=your-snaptrade-consumer-key

4. Install the SDK (already included if you ran pip install -r requirements.txt):

pip install snaptrade-python-sdk

5. In the app: open the 🏦 Connect Brokerage tab on the Manage Holdings page → Connect Brokerage. A SnapTrade window opens; log into your broker there. Back in the app, click Check Connection, then 🔄 Sync Holdings to import.

Your broker credentials go directly to SnapTrade and never touch this app. Your SnapTrade user secret is stored locally in data/.snaptrade_user.json (gitignored). Note: SnapTrade provides shares + average cost basis, but not the original lot purchase date, so imported positions use a placeholder date. Your P&L is accurate.

Option 2 — Upload a CSV export

On the Manage Holdings page, use the 📥 Import CSV tab to upload a holdings export from your broker (Robinhood, Fidelity, Schwab, Vanguard, etc.). The app standardizes common brokerage CSV formats automatically.

If your broker's CSV isn't supported: You can easily generate the portfolio.json file using any AI assistant (like Claude or ChatGPT). Just attach your CSV and ask it to "Convert my brokerage CSV into this JSON format:".

Option 3 — Manual entry / edit the file

Use the 🟢 Buy / 🔴 Sell tabs on the Manage Holdings page, or edit data/portfolio.json directly:

{
  "holdings": [
    {
      "ticker": "AAPL",
      "shares": 10,
      "purchase_price": 150.0,
      "purchase_date": "2024-01-15"
    }
  ]
}

Indicator Cheat-Sheet

IndicatorWhat it tells you
SMA / EMATrend direction. Price above MA = uptrend. SMA 50/200 cross = "golden/death cross".
RSI (14)Momentum. >70 overbought, <30 oversold.
MACDMomentum + trend. Histogram crossing zero = momentum shift.
Bollinger BandsVolatility envelope. Near upper = stretched up; near lower = stretched down.
Sharpe RatioReturn per unit of risk. >1 good, >2 great. Uses 4% risk-free rate.
Max DrawdownLargest peak-to-trough loss.
Beta vs SPYMarket sensitivity. >1 = more volatile than S&P 500.

Notes

  • Yahoo Finance data has a ~15 min delay on the free feed.
  • API responses are cached for 5 min to avoid rate-limit issues.
  • Performance history assumes you held current share counts for the full selected period — it's a "how would my current book have done?" view, not a true time-weighted return.
  • AI features require an OpenRouter API key. The MCP server uses your Claude Desktop subscription directly (no separate key needed).
  • Not investment advice.

Server Config

{
  "mcpServers": {
    "portfolio-analyzer": {
      "command": "python",
      "args": [
        "/FULL/PATH/TO/portfolio-analyzer/mcp_server.py"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
ChatWiseThe second fastest AI chatbot™
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
WindsurfThe new purpose-built IDE to harness magic
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
CursorThe AI Code Editor
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
Playwright McpPlaywright MCP server
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.