How jaq1b/alpaca_trader works
alpaca_trader runs a risk-first Alpaca trading workflow: the CLI configures and dispatches commands; live trading reconciles the broker’s open positions with a SQLite ledger, scans market data, evaluates signals, sizes orders, and manages stops. Separate commands replay historical bars, summarize performance, and resample backtest trades with Monte Carlo. The map retains documented capabilities whose implementation excerpts were not available; those links are omitted where a caller or data flow cannot be evidenced.
Main entry points: cli.py Command router · bot.py Trading loop · broker.py Alpaca client · backtest.py Historical replay
Components 19
Command entry
- Python entry
main.py - Command router
tradingbot/cli.py
Live trading
- Trading loop
tradingbot/bot.py - Alpaca client
tradingbot/broker.py - Signal strategy
tradingbot/strategy.py - Trade ledger
tradingbot/memory.py
Replay and analysis
- Historical replay
tradingbot/backtest.py - Bar snapshots
tradingbot/snapshots.py - Performance metrics
tradingbot/metrics.py - Monte Carlo
tradingbot/montecarlo.py
Shared domain services
- Configuration
tradingbot/config.py - Risk and stops
tradingbot/sizing.py - Trade and orders
tradingbot/models.py - Market hours
tradingbot/market_hours.py - Symbol universe
tradingbot/universe.py - Trading display
tradingbot/display.py - Technical indicators
tradingbot/indicators.py
Other components
- Operator
- Alpaca services
Connections 33
- Operator → Python entry: runs commands
README.md - Python entry → Command router: delegates to
main.py - Command router → Configuration: loads settings
tradingbot/cli.py - Command router → Trading loop: starts trading
tradingbot/cli.py - Command router → Alpaca client: builds client
tradingbot/cli.py - Command router → Historical replay: runs replay
tradingbot/cli.py - Command router → Performance metrics: requests report
README.md - Command router → Monte Carlo: runs resampling
README.md - Command router → Trading display: formats output
tradingbot/cli.py - Command router → Market hours: checks session
tradingbot/cli.py - Trading loop → Alpaca client: reads positions
tradingbot/bot.py - Trading loop → Alpaca client: sends orders
README.md - Trading loop → Trade ledger: reconciles ledger
README.md - Trading loop → Signal strategy: evaluates signals
tradingbot/bot.py - Trading loop → Risk and stops: sizes positions
tradingbot/bot.py - Trading loop → Market hours: checks session
tradingbot/bot.py - Trading loop → Symbol universe: selects symbols
tradingbot/bot.py - Alpaca client → Alpaca services: requests data and trades
README.md - Alpaca client → Trade and orders: uses order models
tradingbot/broker.py - Market hours → Alpaca client: queries calendar
tradingbot/market_hours.py - Trade ledger → Trade and orders: builds trade records
tradingbot/memory.py - Signal strategy → Technical indicators: computes signals
tradingbot/strategy.py - Signal strategy → Trade ledger: checks recent results
tradingbot/strategy.py - Historical replay → Alpaca client: downloads bars
- Historical replay → Signal strategy: replays decisions
tradingbot/backtest.py - Historical replay → Risk and stops: sizes replay trades
tradingbot/backtest.py - Historical replay → Bar snapshots: uses bar snapshots
tradingbot/backtest.py - Historical replay → Symbol universe: uses symbol set
tradingbot/backtest.py - Bar snapshots → Technical indicators: computes features
tradingbot/snapshots.py - Performance metrics → Trade ledger: reads ledger
tradingbot/metrics.py - Performance metrics → Alpaca client: reads portfolio history
tradingbot/metrics.py - Performance metrics → Trade and orders: uses trade records
tradingbot/metrics.py - Monte Carlo → Historical replay: resamples replay trades
README.md