| name | ai-hedge-fund |
| description | An AI-powered hedge fund team that simulates legendary investors (Buffett, Munger, Graham, etc.) to analyze stocks and provide investment recommendations using multi-agent consensus. |
| homepage | https://github.com/virattt/ai-hedge-fund |
| metadata | {"openclaw":{"emoji":"๐","requires":{"bins":["python3","pip3"]},"install":[{"id":"yfinance","kind":"pip","package":"yfinance","bins":[],"label":"Install yfinance (Yahoo Finance)"},{"id":"pandas","kind":"pip","package":"pandas","bins":[],"label":"Install pandas"},{"id":"numpy","kind":"pip","package":"numpy","bins":[],"label":"Install numpy"}]}} |
AI Hedge Fund Skill
An AI-powered hedge fund team that simulates legendary investors to analyze stocks and provide investment recommendations.
Overview
This skill creates a team of AI agents, each embodying the investment philosophy of famous investors:
Classic Investment Agents (5)
- Warren Buffett - Value investing, wonderful companies at fair prices
- Ben Graham - Margin of safety, hidden gems
- Technical Analyst - Chart patterns and indicators
- Risk Manager - Risk metrics and position sizing
- Cathie Wood - Innovation and disruption
Enhanced Analysis Agents (4) - NEW in v2.1
- Earnings Analyst - EPS surprises, beat rates, earnings quality
- Wall Street Consensus - Analyst ratings, price targets, upside
- Macro Strategist - VIX, market regime, SPY/QQQ trends
- Dividend Investor - Yield, payout safety, dividend growth
Total: 9 agents analyzing each stock for comprehensive coverage
Quick Start
ai-hedge-fund analyze AAPL
ai-hedge-fund portfolio AAPL,MSFT,GOOGL --risk moderate
ai-hedge-fund backtest AAPL,MSFT --start 2023-01-01 --end 2024-01-01
./ai-hedge-fund AAPL
./ai-hedge-fund AAPL --detailed
./ai-hedge-fund AAPL --hot
./ai-hedge-fund AAPL --rumor
./ai-hedge-fund AAPL --hot --rumor
./portfolio-build AAPL,MSFT,GOOGL
./backtester AAPL,MSFT --start 2023-01-01 --end 2024-01-01
./scanner hot
./scanner rumor
./scanner rumor -t NVDA
./scanner scan
Data Sources
Free Tier (No API Key Required)
- Yahoo Finance - Real-time prices, basic financials (via yfinance)
- AAPL, GOOGL, MSFT, NVDA, TSLA have extended free data
Optional API Keys (for enhanced data)
FINANCIAL_DATASETS_API_KEY=your_key
ALPHA_VANTAGE_API_KEY=your_key
Architecture
User Request
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Data Fetcher โ โ Yahoo Finance / API
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโดโโโโโฌโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโ
โผ โผ โผ โผ โผ
โโโโโโโโโ โโโโโโโโโ โโโโโโโโโ โโโโโโโโโ โโโโโโโโโ
โBuffettโ โ Mungerโ โGraham โ โBurry โ โCathie โ โ Parallel sub-agents
โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ
โ โ โ โ โ
โโโโโโโโโโโดโโโโโฌโโโโโดโโโโโโโโโโดโโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ Risk Manager โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โPortfolio Managerโ โ Final recommendation
โโโโโโโโโโโโโโโโโโโ
Agent Details
Warren Buffett Agent
Philosophy: "It's far better to buy a wonderful company at a fair price than a fair company at a wonderful price."
Analysis Criteria:
- Return on Equity (ROE) > 15%
- Debt to Equity < 0.5
- Operating Margin > 15%
- Consistent earnings growth
- Durable competitive moat
- Margin of safety calculation
Signal: bullish/bearish/neutral with confidence (0-100)
Charlie Munger Agent
Philosophy: "The big money is not in the buying and selling, but in the waiting."
Analysis Criteria:
- Mental model checklist
- Rational capital allocation
- Shareholder-friendly management
- Circle of competence
- Long-term thinking
Ben Graham Agent
Philosophy: "In the short run, the market is a voting machine but in the long run, it is a weighing machine."
Analysis Criteria:
- Margin of safety (price < intrinsic value * 0.66)
- P/E ratio < 15
- P/B ratio < 1.5
- Current ratio > 2
- No earnings deficit in past 10 years
Technical Analyst
Analysis:
- Moving averages (20, 50, 200 day)
- RSI (Relative Strength Index)
- MACD
- Support/resistance levels
- Volume analysis
Risk Manager
Metrics:
- Volatility (standard deviation)
- Beta vs S&P 500
- Maximum drawdown
- Sharpe ratio
- Position size recommendations
Enhanced Analysis (NEW in v2.1)
Based on features learned from stock-analysis skill, we've added 4 new agents:
Earnings Analyst
Focus: Earnings surprises and quality
- EPS surprise analysis (actual vs expected)
- Historical beat rate (last 4 quarters)
- Earnings growth trends
- Example: "Beat by +5.2%, 3/4 quarters exceeded estimates"
Wall Street Consensus
Focus: Professional analyst opinions
- Consensus rating (strong_buy/buy/hold/sell/strong_sell)
- Number of covering analysts
- Price target vs current price
- Upside/downside potential
- Example: "19 analysts, consensus HOLD, +1.2% upside to target"
Macro Strategist
Focus: Market environment context
- VIX level (fear index)
- Market regime (bull/bear/choppy)
- SPY/QQQ 10-day trends
- Risk-off/risk-on indicators
- Example: "VIX 19.6 (elevated), choppy market, SPY flat"
Dividend Investor
Focus: Income and dividend safety
- Dividend yield analysis
- Payout ratio safety assessment
- Dividend growth history
Market Intelligence (NEW in v2.2)
๐ฅ Hot Scanner
Find trending stocks and crypto before they hit mainstream
Data Sources:
- CoinGecko Trending (top trending crypto)
- Yahoo Finance Movers (gainers/losers/high volume)
Usage:
./scanner hot
./ai-hedge-fund TSLA --hot
Output Example:
๐ฅ HOT SCANNER - Trending Stocks & Crypto
Found 6 trending assets
๐ STOCKS:
๐ข UBER +3.18%
๐ข NVDA +2.45%
๐ช CRYPTO:
๐ ESP-USD +46.91%
๐ OP-USD -14.47%
๐ฎ Rumor Scanner
Detect early signals, M&A rumors, and insider activity
Detection Types:
- ๐ค M&A: Merger, acquisition, takeover rumors
- ๐ค Insider: Insider buying/selling activity
- โฌ๏ธ Upgrade: Analyst upgrades, price target raises
- โฌ๏ธ Downgrade: Analyst downgrades, target cuts
- ๐ Earnings: Earnings surprises, guidance changes
- ๐ค Partnership: New deals, collaborations
Confidence Levels:
- ๐ด High: Reputable source (Reuters, Bloomberg, CNBC)
- ๐ก Medium: Confirmed keywords ("announces", "SEC filing")
- โช Low: Early signals, unconfirmed
Usage:
./scanner rumor -t TSLA
./scanner rumor
./ai-hedge-fund NVDA --rumor
Output Example:
๐ฎ RUMOR SCANNER - Early Signals
Detected rumors for 3 tickers
๐ฐ NVDA:
๐ก โฌ๏ธ [UPGRADE] Goldman raises target to $850...
Source: MarketWatch | Confidence: medium
๐ฐ TSLA:
โช ๐ค [PARTNERSHIP] Rumored deal with...
Source: Twitter | Confidence: low
- Income rating (excellent/good/moderate/poor)
- Example: "2.8% yield, safe payout at 45%, dividend aristocrat"
Usage Examples
Basic Analysis
result = ai_hedge_fund.analyze("AAPL")
results = ai_hedge_fund.analyze(["AAPL", "MSFT", "GOOGL"])
Detailed Report
{
"ticker": "AAPL",
"analysis_date": "2025-02-18",
"agents": {
"warren_buffett": {
"signal": "bullish",
"confidence": 85,
"reasoning": "Strong ROE of 160%, excellent brand moat, consistent dividend growth"
},
"charlie_munger": {
"signal": "bullish",
"confidence": 80,
"reasoning": "Rational capital allocation via buybacks, strong pricing power"
},
"ben_graham": {
"signal": "neutral",
"confidence": 50,
"reasoning": "High P/E of 28 exceeds margin of safety threshold"
},
"technical": {
"signal": "bullish",
"confidence": 70,
"reasoning": "Price above 200-day MA, RSI at 55 indicates healthy momentum"
},
"risk_manager": {
"signal": "neutral",
"confidence": 60,
"reasoning": "Beta 1.2 indicates market correlation, moderate volatility"
}
},
"consensus": {
"signal": "bullish",
"confidence": 73,
"agreement": "4/5 agents bullish",
"key_risks": ["High valuation", "Market correlation"],
"recommendation": "Consider position size of 5-8% max"
}
}
Configuration
Environment Variables
OPENAI_API_KEY=sk-...
FINANCIAL_DATASETS_API_KEY=...
ALPHA_VANTAGE_API_KEY=...
MAX_AGENTS=12
PARALLEL_MODE=true
CACHE_DURATION=3600
Custom Agents
Add your own investment style by creating a new agent file:
from typing import Literal
class CustomAgentSignal(BaseModel):
signal: Literal["bullish", "bearish", "neutral"]
confidence: int = Field(description="Confidence 0-100")
reasoning: str = Field(description="Reasoning for the decision")
def custom_agent(state: AgentState, ticker: str) -> CustomAgentSignal:
"""Your custom analysis logic"""
data = fetch_financial_data(ticker)
score = analyze_custom_metrics(data)
return CustomAgentSignal(
signal="bullish" if score > 70 else "neutral",
confidence=score,
reasoning="Your reasoning here"
)
Limitations & Disclaimers
โ ๏ธ IMPORTANT: This tool is for educational and research purposes only.
- Not investment advice: These are AI simulations, not professional financial advice
- No guarantee: Past performance analyzed by AI does not predict future results
- Data limitations: Free data sources may have delays or inaccuracies
- Risk: Always consult a qualified financial advisor before making investment decisions
Technical Details
Multi-Agent Coordination
Uses OpenClaw's sessions_spawn to run agents in parallel:
const agentResults = await Promise.all(
agents.map(agent =>
sessions_spawn({
task: `Analyze ${ticker} as ${agent.name}`,
agentId: 'investment-analyst',
timeoutSeconds: 60
})
)
);
Data Caching
- Financial data cached for 1 hour to reduce API calls
- Agent results cached for same ticker within 30 minutes
Error Handling
- Graceful fallback if data source unavailable
- Individual agent failures don't block other agents
- Missing data reported in reasoning
Troubleshooting
"No data for ticker"
- Check ticker symbol is correct (e.g., "BRK-B" not "BRK.B")
- Try popular tickers first (AAPL, MSFT, GOOGL)
- Some tickers may not be available in free tier
"API rate limit"
- Wait a few minutes and retry
- Results are cached, so retry is fast
- Consider adding API key for higher limits
Slow analysis
- First run fetches and caches data
- Subsequent runs use cached data (much faster)
- Use
--quick flag for essential agents only
Feature Modules
1. Portfolio Construction (portfolio_constructor.py)
Modern Portfolio Theory (MPT) optimization:
- Mean-variance optimization
- Risk parity weighting
- Sector diversification analysis
- Sharpe ratio maximization
- Three risk profiles: conservative, moderate, aggressive
ai-hedge-fund portfolio AAPL,MSFT,GOOGL,JPM,JNJ --risk moderate
2. Backtesting (backtester.py)
Backtest strategies on historical data:
- Multiple strategies: ai_consensus, equal_weight, momentum, value
- Rebalancing schedules: weekly, monthly, quarterly
- Performance metrics: Sharpe, max drawdown, alpha, beta
- Benchmark comparison (S&P 500)
- Trade history tracking
ai-hedge-fund backtest AAPL,MSFT,GOOGL --start 2023-01-01 --end 2024-01-01 --strategy ai_consensus
3. Rebalancing Monitor (rebalance_monitor.py)
Monitor portfolio drift and generate alerts:
- Weight drift detection
- Signal-based target weights
- Urgency classification (HIGH/MEDIUM/LOW)
- Health score calculation
- Rebalancing schedule generation
ai-hedge-fund rebalance AAPL:0.3,MSFT:0.2,GOOGL:0.5 --last-rebalanced 2024-01-01
4. Tax Optimization (tax_optimizer.py)
Tax-loss harvesting and optimization:
- Unrealized gain/loss tracking
- Tax-loss harvesting opportunities
- Wash sale rule detection
- Replacement security suggestions
- Year-end tax strategy
ai-hedge-fund tax --lots '[{"ticker":"AAPL","shares":100,"purchase_date":"2024-01-01","purchase_price":150}]' --year-end
5. ESG Screening (esg_screener.py)
Environmental, Social, Governance screening:
- ESG score calculation (0-10 scale)
- Controversy detection
- Sector comparison
- Exclusion criteria checking
- Portfolio ESG scoring
ai-hedge-fund esg AAPL,MSFT,XOM,TSLA --portfolio --minimum-score 6.0
File Structure
ai-hedge-fund/
โโโ SKILL.md # This documentation
โโโ QUICKSTART.md # Quick start guide
โโโ ADVANCED.md # Advanced architecture
โโโ ai_hedge_fund.py # Basic rule-based analysis
โโโ ai_hedge_fund_advanced.py # AI-powered sub-agent analysis
โโโ portfolio_constructor.py # Portfolio optimization
โโโ backtester.py # Strategy backtesting
โโโ rebalance_monitor.py # Rebalancing alerts
โโโ tax_optimizer.py # Tax-loss harvesting
โโโ esg_screener.py # ESG screening
โโโ ai-hedge-fund-cli # Unified CLI
โโโ ai-hedge-fund # Basic CLI wrapper
โโโ ai-hedge-fund-advanced # Advanced CLI wrapper
โโโ portfolio-build # Portfolio CLI wrapper
โโโ .env # API keys
Related Resources
Version: 2.0.0
Author: OpenClaw Community
License: MIT