Can random stock picks beat professional fund managers?
MonkeyBeat generates equi-weighted portfolios of 10 randomly selected stocks from NSE indices and compares their performance against the underlying benchmark.
Test the "monkeys throwing darts" hypothesis yourself!
# Requires Python 3.12+ and uv
uv run app.pyFirst run takes 5-10 minutes to fetch 5 years of stock data from Yahoo Finance.
- Single file app - Everything in
app.py(~850 lines) - Zero setup - Embedded DuckDB, no external database
- 9 NSE indices - From NIFTY 50 to Smallcap 250
- Monte Carlo simulations - 100 random portfolios per request
- Fast - ~150ms response after data is loaded
- Shareable - UUID-based links with social sharing
| Index | Stocks | Category |
|---|---|---|
| NIFTY 50 | 50 | Large Cap |
| NIFTY Next 50 | 50 | Large Cap |
| NIFTY 100 | 100 | Large Cap |
| NIFTY 200 | 200 | Large Cap |
| NIFTY 500 | 500 | Large Cap |
| NIFTY Midcap 100 | 100 | Mid Cap |
| NIFTY Midcap 150 | 150 | Mid Cap |
| NIFTY Smallcap 100 | 100 | Small Cap |
| NIFTY Smallcap 250 | 250 | Small Cap |
- Select an index from the dropdown
- App randomly picks 10 stocks from that index
- Calculates returns over 1M, 6M, 1Y, 3Y, and 5Y periods
- Compares against the benchmark index
- Runs 100 Monte Carlo simulations to show win rate
monkeybeat/
├── app.py # FastAPI app (uv inline dependencies)
├── templates/ # Jinja2 templates
│ ├── base.html # Layout with HTMX, Tailwind, Lightweight Charts
│ ├── portfolio.html # Results page
│ └── error.html
├── scripts/
│ ├── download_indices.sh # Fetch latest index constituents
│ └── ind_*.csv # Index constituent lists
├── static/ # Logo, favicon
└── data/ # DuckDB database (auto-created)
- FastAPI - Web framework
- DuckDB - Embedded analytics database
- yfinance - Yahoo Finance data
- HTMX - Dynamic HTML
- Tailwind CSS - Styling
- Lightweight Charts - TradingView charts
- uv - Python package manager
./scripts/download_indices.sh- Equal weighting - Your portfolio weights each stock equally, while indices are cap-weighted
- Survivorship bias - Current index members are "survivors"; poor performers were removed
- Concentration - 10 stocks can get lucky with 1-2 multibaggers
- Logo by @hashfyre
This is for educational/entertainment purposes only. Not financial advice. Past performance does not guarantee future results.
