A Claude Code subagent specialized in real-time US stock market analysis using yfinance for accurate, up-to-date market data with automatic Python execution via uv.
This subagent provides comprehensive stock analysis combining technical indicators, fundamental metrics, sentiment analysis, and peer comparisons. It generates professional markdown reports with actionable investment insights.
Designed for Claude Code: This agent is meant to be used within Claude Code's agent ecosystem. Simply install and start chatting with Claude about stock analysis - the agent handles everything automatically.
- Real-time Market Data: Live prices, volume, and market cap data
- Technical Analysis: 20+ indicators including MA, RSI, MACD, Bollinger Bands, Stochastic, CCI, MFI, OBV, ATR, Williams %R, and more
- Fundamental Analysis: Comprehensive valuation, profitability, growth, and financial health metrics
- Peer Comparison: Side-by-side analysis with competitor stocks
- Options Data: Put/call ratios and open interest analysis
- Sentiment Analysis: News sentiment and analyst recommendations
- Automated Reports: Professional markdown reports saved automatically
Run the automated installation script:
./install.shThe script will:
- Copy agent files to
~/.claude/agents/directory - Install Python dependencies (yfinance, pandas, numpy) via
uv - Set up proper permissions
Requirements:
- Claude Code installed and configured
uvpackage manager (installation guide)
Simply ask Claude about stocks naturally:
You: Analyze AAPL stock
or
You: Analyze AAPL stock using us-stock-realtime agent
Claude will automatically:
- Invoke the stock analysis agent
- Fetch real-time market data
- Calculate technical indicators
- Analyze fundamentals
- Compare with relevant peers
- Generate a comprehensive markdown report
- Save the report as
stock_analysis_[TICKER]_[DATE].md
When you ask Claude Code about stock analysis, the agent:
- Identifies the request: Recognizes stock analysis queries
- Fetches data: Uses yfinance to get real-time market data
- Calculates indicators: Computes 20+ technical indicators
- Analyzes fundamentals: Evaluates valuation, profitability, growth
- Identifies peers: Automatically selects relevant competitor stocks
- Generates report: Creates comprehensive markdown analysis
- Saves output: Stores report in your current directory
The subagent performs multi-dimensional analysis across four key areas:
- Trend assessment using multiple moving averages
- Momentum indicators (RSI, MACD, Stochastic)
- Volatility analysis (Bollinger Bands, ATR)
- Support/resistance levels (Pivot Points)
- Valuation metrics (P/E, PEG, P/S, P/B, EV/EBITDA)
- Profitability (margins, ROE, ROA)
- Growth metrics (revenue, earnings growth)
- Financial health (liquidity, debt ratios, cash flow)
- Recent news sentiment
- Analyst consensus and price targets
- Options flow analysis
- Volume and short interest
- Relative valuation
- Competitive positioning
- Market share trends
The script returns structured JSON data containing:
- Real-time price data
- All technical indicators
- Fundamental metrics
- Options data
- Peer comparison data
When used as a Claude Code subagent, comprehensive analysis reports are automatically saved as:
stock_analysis_[TICKER]_[YYYY-MM-DD].md
Example: stock_analysis_NVDA_2025-09-23.md
Example Reports Included: This repository includes sample analysis reports for reference:
stock_analysis_NVDA_2025-09-23.md- NVIDIA comprehensive analysis (10KB)stock_analysis_COIN_2025-11-11.md- Coinbase analysis with peer comparison (20KB)stock_analysis_BABA_2025-11-11_GLM4.6.md- Alibaba analysis (7KB)
These examples demonstrate the depth and format of the automated analysis reports.
Composite Score (0-100):
- 80-100: Strong Buy
- 65-79: Buy
- 50-64: Hold
- 35-49: Reduce
- 0-34: Sell
- P/E Ratio: <15 (undervalued) | 15-25 (fair) | >25 (growth premium)
- PEG Ratio: <1 (undervalued) | 1-2 (fair) | >2 (overvalued)
- P/S Ratio: <1 (attractive) | 1-3 (reasonable) | >3 (expensive)
- Gross Margin: >40% (excellent) | 20-40% (good) | <20% (concerning)
- Net Margin: >20% (excellent) | 10-20% (good) | <5% (weak)
- ROE: >20% (excellent) | 15-20% (good) | <10% (poor)
- RSI: <30 (oversold) | 30-70 (neutral) | >70 (overbought)
- Put/Call Ratio: <0.5 (bullish) | 0.7-1.3 (neutral) | >1.5 (bearish)
stock_analyzer.py: Core analysis module
get_realtime_data(ticker): Fetches live market data and metricscalculate_technical_indicators(ticker, period): Computes 20+ technical indicatorsget_options_data(ticker): Retrieves options chain datafetch_stock_data(ticker, peer_tickers): Main data aggregation functionquick_price(ticker): Fast price check utility
- User requests stock analysis
- Script fetches real-time data via yfinance
- Calculates technical indicators from historical data
- Retrieves fundamental metrics and options data
- Optionally fetches peer comparison data
- Returns structured JSON
- Claude Code subagent analyzes and generates markdown report
The agent handles common issues automatically:
| Issue | How It's Handled |
|---|---|
| Missing dependencies | Installation script installs all required packages |
| Rate limiting | Automatic delays between API calls |
| Market closed | Returns most recent available data |
| Invalid ticker | Provides error message and suggests checking symbol |
| API unavailable | Graceful error handling with partial data |
claude-stock-agent/
├── install.sh # Automated installation script
├── stock_analyzer.py # Core Python analysis module
├── us-stock-realtime.md # Claude Code agent definition
├── README.md # This file
└── stock_analysis_*.md # Generated analysis reports (examples)
Installed Location (after running install.sh):
~/.claude/agents/
├── stock_analyzer.py # Analysis engine
└── us-stock-realtime.md # Agent configuration
- Market data may have 15-20 minute delay for some exchanges
- Options data availability depends on the stock
- Peer comparison limited to 6 stocks to avoid rate limiting
- Real-time data quality depends on yfinance API availability
This tool is for educational and research purposes only. The analysis and recommendations provided are not investment advice. Always conduct your own due diligence and consult with a qualified financial advisor before making investment decisions.
All market data is sourced from Yahoo Finance via the yfinance Python library.
This project is part of the Claude Code agent ecosystem.
Current Version: 1.0
- Installation Issues: Ensure
uvis installed and Claude Code is configured - Agent Not Working: Verify files are in
~/.claude/agents/directory - Data Issues: Check Yahoo Finance for ticker symbol validity
- Claude Code Help: Refer to Claude Code documentation
This is a specialized Claude Code subagent. When contributing:
- Maintain compatibility with Claude Code agent framework
- Follow the analysis methodology in
us-stock-realtime.md - Ensure all data fetching uses
uv run python - Test with multiple stock tickers and market conditions
- Update documentation for any new features
- Built for the Claude Code ecosystem
- Market data powered by yfinance
- Uses Yahoo Finance as the data source