Automated Investing — Infrastructure Plan
Purpose
Define the tools, libraries, data sources, directory layout, and discipline gates for moving through the 5-level quant curriculum from 06-reference/2026-04-10-gemchange-quant-from-scratch and building toward the 5-layer prediction-market production stack from 06-reference/2026-04-10-gemchange-simulate-like-quant-desk.
This plan sits under the Automated Investing project index. Experiments run in the venv defined here. Nothing in this project uses real capital until we beat the discipline gate (0.12 Brier score on a live event).
Local dev environment
Python runtime: uv-managed Python 3.12 (installed at 01-projects/automated-investing/.venv/). uv is the package manager — fast, reproducible, handles Python version pinning.
Why uv: consistent across Mac Mini / any future machine, lockfile gives reproducibility, can run scripts via uv run without manual activation. Installed at /Users/ray/.local/bin/uv.
Activation options:
- Direct:
.venv/bin/python scripts/level_1_coin_flip.py - Activated:
source .venv/bin/activate && python scripts/level_1_coin_flip.py - uv run:
uv run python scripts/level_1_coin_flip.py(auto-activates)
Requirements file: requirements.txt in the project root. Add libraries as we move up levels. Current state (L1-L2):
numpy>=2.0
scipy>=1.13
pandas>=2.2
matplotlib>=3.9
statsmodels>=0.14
yfinance>=0.2.40
jupyterlab>=4.2
ipykernel>=6.29
Future additions by level:
- L3:
cvxpy(convex optimization),scikit-learn - L4:
pymcorstan(Bayesian modeling),arch(GARCH),quantlibPython bindings - L5:
pyvinecopuliborcopulas(copula modeling),pyextremes(EVT) - Prediction markets specific:
websockets(already in the tree), custom CLOB wrapper,py-vollib(options pricing) - Later / optional:
pytorch(for neural SDEs, transformer time-series),cvxpylayers(differentiable convex optimization)
Directory layout
01-projects/automated-investing/
├── index.md # project overview + reference links
├── infrastructure-plan.md # this file
├── curriculum.md # (to create) level-by-level learning plan w/ milestones
├── requirements.txt # pinned Python libs
├── .venv/ # uv-managed Python env (gitignored)
├── scripts/ # runnable .py files per drill
│ ├── level_1_coin_flip.py
│ ├── level_1_bayesian_updater.py
│ └── ...
└── experiments/ # markdown writeups with results
├── level-1-probability.md
├── outputs/ # generated plots, CSVs, pickles
│ ├── level_1_lln.png
│ └── level_1_bayesian.png
└── ...
Convention: scripts are runnable and tiny (single-responsibility). Experiments are markdown writeups with embedded results, plots, and commentary. Scripts write plot outputs to experiments/outputs/.
Level progression plan
Each level has a concrete deliverable. We do not advance to the next level until the current level’s deliverable is working and documented.
| Level | Topic | Deliverables | Gate to next |
|---|---|---|---|
| L1 | Probability | Coin-flip LLN, Bayesian updater, Blitzstein Ch 1-6 drills | LLN converges; Bayesian updater’s MAP matches MLE on simulated data |
| L2 | Statistics | yfinance → fit Student-t via MLE, Fama-French 3-factor regression, permutation test | Demonstrate awareness of multiple-comparisons trap on a synthetic strategy sweep |
| L3 | Linear algebra | S&P 500 PCA, Markowitz mean-variance optimizer from scratch with cvxpy | Reproduce the “5 eigenvectors explain ~70% of variance” result |
| L4 | Calculus / optimization | Gradient descent on Rosenbrock, portfolio optimization with transaction costs | Solve a constrained problem cvxpy can’t handle directly (custom gradient) |
| L5 | Stochastic calculus | Black-Scholes from scratch, Monte Carlo convergence check, all five Greeks | Monte Carlo price matches analytical Black-Scholes within 0.5% |
| PM1 | Prediction market foundations | Monte Carlo binary contract simulator + Brier score calibrator | Simulator runs on a historical Polymarket contract and produces a Brier score |
| PM2 | Tail-risk pricing | Importance sampling via exponential tilting | ≥100x variance reduction on an extreme contract vs crude MC |
| PM3 | Live filtering | Particle filter on a live or replayed Polymarket contract | Filtered estimate beats raw market price in Brier score |
| PM4 | Dependencies | Student-t copula for correlated swing-state-style contracts | Reproduce the “2-5x higher joint tail probability vs Gaussian” result |
| PM5 | Production stack L1-L5 | Polymarket CLOB WebSocket subscriber + Monitor integration, probability engine, dependency model, risk, monitoring | Beat 0.12 Brier score on a live event (paper) |
Only after PM5 passes its gate do we deploy real capital, and only at size small enough to survive the estimation-error warning from the roadmap article.
Data sources
- L1-L2 free:
yfinance(equities), synthetic data for drills - L2-L5 free / cheap: Finnhub (60 calls/min), Alpha Vantage — only if we need them
- L3+ optional paid: Polygon.io ($199/mo, sub-20ms latency) — only when we have a working pipeline and a reason to pay for latency
- Prediction markets (PM1+): Polymarket public CLOB WebSocket (no API key for market data) — see https://docs.polymarket.com/ for endpoints
- On-chain (PM4+): Alchemy free tier (Polygon chain) for settlement event data
- Enterprise tier ignored: Bloomberg Terminal ($32K/yr) is out of scope; we optimize for math, not data moat
Compute
- L1-L4: Mac Mini handles everything. The ABM simulations and particle filters in the article run comfortably on CPU.
- L5+ equities: Mac Mini still fine for research; live tick ingestion is I/O-bound not compute-bound.
- PM5 neural / RL: if/when we pull in transformer time-series or RL for market making, spin up a cloud GPU (Lambda Labs, RunPod) per-run rather than keeping one on standing. Defer this decision.
Claude Code tooling we’ll lean on
- Monitor tool (06-reference/2026-04-10-claude-code-monitor-tool) — L1 of the production stack: stream Polymarket CLOB ticks via a subscriber CLI into the agent session
- Subagent delegation — long simulation runs go to subagents so the main session doesn’t fill with simulation output
- XcodeBuildMCP — irrelevant here, flagged only to remind me this project isn’t iOS
- qmd — vault search while working, for cross-linking to related notes
- Vault log + decisions.md — every significant decision in this project gets logged
Discipline gates (never compromise)
From both source articles, restated:
- First 10 backtested strategies will look good and be noise. Accept this upfront; don’t trust strategy #1.
- Use Newey-West standard errors for any financial regression. Default OLS SEs are wrong.
- Apply Bonferroni or Benjamini-Hochberg when testing multiple strategies.
- Beat 0.12 Brier score on a live event (paper trading) before any real capital touches Polymarket.
- No full-Kelly sizing. Estimation error destroys full-Kelly the moment true parameters drift from estimated ones. Fractional Kelly with a hard cap.
- Log every decision to
01-projects/automated-investing/decisions.mdso we can review whether the methodology held up over time.
Textbooks downloaded
06-reference/textbooks/bv_cvxbook.pdf— Boyd & Vandenberghe, Convex Optimization (6.6 MB, Stanford source). L4.- Blitzstein & Hwang, Introduction to Probability — the author’s Google Drive link (linked from probabilitybook.net) has editor-only permissions, so it can’t be downloaded programmatically. Needs a manual browser download from the founder’s side, or I can use the claude-in-chrome tool if approved. L1.
Open questions / deferred decisions
- Blitzstein download method: manual browser or approved Chrome automation?
- Polymarket account: do we need to register for WebSocket access, or is public market data truly open? (TBD — check their docs when we hit PM1)
- Cloud compute: defer until PM5.
- Commercial licenses: Gurobi has a free academic license; we’re not academic. Google OR-Tools is a capable free substitute for now.
- Funding source for real capital: when we eventually get to live trading, how much capital are we willing to put at risk? This should be a founder decision well before PM5.
What’s working already (as of 2026-04-10)
- uv venv live at
.venv/, Python 3.12.13, all L1-L2 libraries installed - Level 1 drill #1 (coin flip LLN) runs and converges: 10,000 flips → 0.4985
- Level 1 drill #2 (Bayesian updater) runs and produces MAP estimate matching sample mean on simulated coin data
- Plots saved to
experiments/outputs/level_1_lln.pngandexperiments/outputs/level_1_bayesian.png - Both scripts reproducible via
.venv/bin/python scripts/level_1_*.py
Next actions
- Create
curriculum.mdwith weekly study milestones mapped to the levels above - Write
experiments/level-1-probability.mdwriting up the two drills with commentary (in progress — see working-context) - Resolve Blitzstein PDF download (manual browser or approved Chrome)
- Start Level 2 prep: yfinance data pull, Student-t MLE on real returns, Fama-French 3-factor regression