AI-powered stock analysis agent using fundamental investing principles. Built on agent-kit.
Analyzes stocks through the lens of capital allocation excellence:
- High-quality businesses: ROIC ≥15%, ROE ≥15%, margins ≥10%
- Owner-operator mindset: Management quality and insider ownership
- Smart capital allocation: Buybacks, M&A track record, low share dilution
- Sustainable moats: Competitive advantages and pricing power
- Valuation discipline: Price matters, even for great businesses
# Install
git clone https://github.com/pradeepiyer/allocator-agent.git
cd allocator-agent
uv sync
# Configure
export OPENAI_API_KEY="sk-..."
uv run agent-kit init
# Run
uv run python -m allocator.mainScreen for opportunities (scans 3000+ stocks from Russell 3000 database):
/screen
/screen tech stocks with high margins
Analyze a stock (generates comprehensive report + similar companies):
/analyse AAPL
Chat mode (natural language queries):
What's NVDA's capital allocation track record?
Compare META and GOOGL
All analysis generates PDF reports in reports/.
- Two-stage LLM-powered screening (broad filter → detailed analysis)
- Cached database of 3000+ stocks with fundamentals, ownership, technical data
- Quality scoring (0-100) across 8 dimensions
- Automatic PDF export with ranked results
- Comprehensive investment analysis (management, financials, moat, valuation)
- Programmatic similar company discovery
- Side-by-side comparison tables
- Clear recommendation (Strong Buy / Buy / Hold / Sell / Pass)
- SQLite cache with Russell 3000 data
- Annual fundamentals (ROIC, ROE, margins, cash flow, balance sheet)
- Quarterly share counts, insider ownership, institutional holdings
- Technical indicators (RSI, MACD, trends)
- yfinance API (free, no key required)
The agent evaluates stocks across 8 dimensions:
- Management Quality: Insider ownership, skin in the game, track record
- Capital Allocation: Buybacks, M&A, share dilution, capital efficiency
- Financial Quality: ROIC, ROE, margins, cash flow, balance sheet
- Shareholders: Institutional holders, insider transactions
- Valuation: P/E, P/B, P/S, EV/EBITDA, PEG relative to quality
- Business Quality: Moat, competitive dynamics, resilience
- Market Position: Consensus view, hidden assets, opportunity type
- Technical: Trend, momentum, entry/exit points
agents/allocator/
├── agent.py # AllocatorAgent (analyze, screen, similar stocks)
├── tools.py # 13 financial data tools
├── models.py # Pydantic models for structured outputs
├── export.py # PDF generation
├── console.py # Interactive CLI
├── db.py # Database cache layer
├── main.py # Entry point
├── data/market.db # SQLite cache (~3000 stocks)
└── prompts/
├── analyzer.yaml # Stock analysis principles (6 prompts total)
├── similarity.yaml
└── screener.yaml
Tools (tools.py):
get_stock_fundamentals()- ROIC, ROE, margins, balance sheetget_insider_ownership()- Insider %, transactionsget_institutional_holders()- Major shareholdersget_share_data()- Share count history, buybacksget_management_compensation()- Executive pay, SBCget_technical_indicators()- RSI, MACD, trendsget_valuation_metrics()- P/E, P/B, P/S, EV/EBITDAget_financial_history()- Multi-year trendsfind_similar_companies()- Sector/industry discoveryscreen_database_initial()- Stage 1 screeningget_detailed_metrics()- Stage 2 screeningweb_search- News, filings, research
agents/allocator/config.yaml:
max_iterations: 25 # Complex multi-step analysis~/.agent-kit/config.yaml:
openai:
api_key: "${OPENAI_API_KEY}"
model: "gpt-4o"# Refresh all cached data
uv run python scripts/refresh_market_data.py
# Refresh specific symbols
uv run python scripts/refresh_market_data.py AAPL MSFT
# Download initial dataset
uv run python scripts/download_market_data.pymake lint # Run linter
make test # Run tests
make ci # Full CI checkExtension pattern (following agent-kit):
- Add async tool function in
tools.py - Register in
get_tool_definitions()andexecute_tool() - Update YAML prompts in
prompts/to guide tool usage - Define Pydantic models in
models.pyfor structured outputs
- Dependent on yfinance data quality
- No real-time data (15-min delays)
- Historical metrics only (not predictive)
- For educational/research purposes only (not financial advice)
MIT
Educational and research purposes only. Not financial advice. Do your own research and consult qualified advisors before investing.
Built with agent-kit | Powered by OpenAI