Skip to content

patrickjchen/TradingWithAlpaca

Repository files navigation

Trading-With-Alpaca

An Alpaca crypto paper-trading pipeline whose Python and HTML files are generated by an AG2 (autogen) multi-agent system. The generator (alpaca_codegen.py) drives a Researcher → Coder → Verifier loop with Gemini via OpenRouter; the generated code lives in generated/.

Generate the pipeline

pip install -r requirements.txt
python alpaca_codegen.py            # writes any missing files in generated/
python alpaca_codegen.py --stage all   # regenerate everything

Run the pipeline

Needs Redis on localhost and Alpaca paper-trading API keys.

export ALPACA_API_KEY_ID=...  ALPACA_API_SECRET_KEY=...
docker run -p 6379:6379 redis             # or any other way

python generated/subscriber.py      # market data  -> Redis
python generated/trade_stream.py    # trade events -> Redis Stream
python generated/persister.py       # Redis Stream -> SQLite
python generated/webgui.py          # http://127.0.0.1:5000

CLI alternative:

cd generated
python cli.py symbols
python cli.py latest BTC/USD
python cli.py account
python cli.py buy BTC/USD 0.001     # paper by default; --live to opt in

Web UI

Three tabs:

  • Escalator — live 10-bid / 10-ask depth ladder per symbol. Click a row to open a pre-filled limit-order modal.
  • Activity — recent orders + fills (with $ notional), from SQLite.
  • Summary — account, positions, realized PnL by symbol.

More

  • slides.html — project overview deck (open in any browser).
  • DESIGN.md — agents, stages, sequence + use-case diagrams.
  • CLAUDE.md — repo conventions, when to edit a file directly vs. re-run the codegen.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors