Get QuantStack running in under 10 minutes.
| Tool | Version | Install |
|---|---|---|
| Python | 3.11+ | python.org |
| PostgreSQL | 14+ | brew install postgresql |
| tmux | any | brew install tmux |
| Claude Code CLI | latest | npm install -g @anthropic-ai/claude-code |
| uv | latest | curl -LsSf https://astral.sh/uv/install.sh | sh |
git clone https://github.com/kbichave/QuantStack.git
cd QuantStack
uv sync --all-extras # creates .venv and installs all dependenciesOr with pip:
pip install -e ".[all]"cp .env.example .envEdit .env and set at minimum:
TRADER_PG_URL=postgresql://localhost/quantstack # your PostgreSQL DSN
ALPACA_API_KEY=your_key
ALPACA_SECRET_KEY=your_secret
ALPACA_PAPER=true # paper trading (safe default)
ALPHA_VANTAGE_API_KEY=your_key
USE_REAL_TRADING=false # keep false until you're readyCreate the database if it doesn't exist:
createdb quantstack./start.shstart.sh will:
- Validate all prerequisites and credentials
- Run DB migrations (idempotent — safe to re-run)
- Bootstrap the trading universe if empty (~700 symbols)
- Run preflight checks (kill switch, data freshness, broker connectivity)
- Display the current credit regime (informational)
- Compact oversized memory files
- Launch 4 tmux windows:
trading,research,supervisor,scheduler
# Attach to the tmux session and watch the loops
tmux attach -t quantstack-loops
# Switch windows: Ctrl-b 0 (trading) Ctrl-b 1 (research) Ctrl-b 2 (supervisor)
# Detach without stopping: Ctrl-b dAfter ~5 minutes, verify heartbeats were written:
python3 -c "
from quantstack.db import open_db
conn = open_db()
rows = conn.execute('''
SELECT loop_name, MAX(iteration) AS iter, MAX(finished_at) AS last_seen
FROM loop_heartbeats GROUP BY loop_name
''').fetchall()
for r in rows: print(r)
conn.close()
"Expected output (timestamps ~5 min apart for trading, ~2 min for research):
('trading_loop', 1, datetime.datetime(2026, 4, 1, 9, 35, ...))
('research_loop', 1, datetime.datetime(2026, 4, 1, 9, 33, ...))
Verify loop state is being persisted (stateless mode working):
python3 -c "
from quantstack.db import open_db
conn = open_db()
rows = conn.execute('SELECT loop_name, context_key, updated_at FROM loop_iteration_context').fetchall()
for r in rows: print(r)
conn.close()
"./report.shOr query directly:
python3 -c "
from quantstack.db import open_db
conn = open_db()
# Open positions
positions = conn.execute('SELECT symbol, qty, avg_entry_price FROM positions WHERE status=\'open\'').fetchall()
print('Open positions:', positions)
# Recent fills
fills = conn.execute('''
SELECT symbol, side, qty, fill_price, realized_pnl, filled_at
FROM fills ORDER BY filled_at DESC LIMIT 5
''').fetchall()
print('Recent fills:', fills)
conn.close()
"tmux kill-session -t quantstack-loopsOr activate the kill switch (stops new orders, leaves positions open for manual review):
python3 -c "
from quantstack.db import open_db
conn = open_db()
conn.execute(\"UPDATE system_state SET value='active', updated_at=NOW() WHERE key='kill_switch'\")
conn.commit()
conn.close()
print('Kill switch activated')
"start.sh fails at preflight — read the error output. Common causes: PostgreSQL not running, TRADER_PG_URL wrong, Alpaca keys invalid, quantstack package not installed.
No heartbeats after 10 minutes — attach to tmux and check the trading window for errors. The most common cause is an expired Alpaca paper account or an invalid Alpha Vantage key.
loop_iteration_context empty — the loops may be failing on the first tool call. Check data/logs/trading_loop.log for Python exceptions.
Bug-fix watcher not triggering — check that record_tool_error() is being called in the loop (the loop prompts include the pattern). Query the bugs table:
python3 -c "
from quantstack.db import open_db
conn = open_db()
rows = conn.execute('SELECT tool_name, consecutive_errors, status FROM bugs ORDER BY created_at DESC LIMIT 10').fetchall()
for r in rows: print(r)
conn.close()
"- Architecture overview — how the components fit together
- Deployment guide — environment variables, data paths, utility scripts
- Execution setup — broker config, risk limits, kill switch