How alanperry1/forex-bot works
This is an autonomous OANDA forex-trading bot. Its principal workflow is a recurring bot loop that gathers market and account data, filters and scores trade opportunities across Claude, RandomForest and PPO, sizes and validates a candidate, then executes it and tracks the position. Separate branches provide indicator strategies, model training, alerts and a live dashboard. Relationships follow the README’s documented pipeline and the shown bot/source-index references; several implementation details are unsampled.
Main entry points: bot.py Trading loops · data_layer.py Market data client · features.py Feature engineering · environment.py Trading environment
Components 27
Trading runtime
- Trading loops
bot.py - Session filter
session_filter.py - Correlation filter
correlation_filter.py - News blackout
news.py - Profitability gate
profitability_gate.py
Signals and models
- Indicator strategies
strategy_engine.py - Claude analysis
ai_brain.py - Feature engineering
ml/features.py - RandomForest inference
ml/predictor.py - RF training
ml/trainer.py - PPO inference
rl/agent.py - Trading environment
rl/environment.py - Reward function
rl/reward.py - PPO training
rl/trainer.py
Risk and execution
- Consensus sizing
lot_sizing_engine.py - Risk validation
risk_manager.py - Order execution
executor.py - Position tracking
position_manager.py
Monitoring and records
- Trade records
logger.py - Live dashboard
dashboard.py - Mobile alerts
alerts.py
External services
- Market data client
data_layer.py - Anthropic API
Other components
- Operator
- OANDA
- Pushover
- NewsAPI / calendar
Connections 32
- Operator → Trading loops: starts
README.md - Trading loops → Market data client: requests data
bot.py - Market data client → OANDA: calls REST API
data_layer.py - Trading loops → Session filter: filters by session
README.md - Trading loops → Correlation filter: checks pairs
bot.py - Trading loops → News blackout: checks blackout
README.md - News blackout → NewsAPI / calendar: fetches events
README.md - Trading loops → Profitability gate: prechecks trades
README.md - Trading loops → Indicator strategies: uses strategies
bot.py - Trading loops → Claude analysis: requests analysis
README.md - Claude analysis → Anthropic API: requests completion
README.md - Trading loops → Feature engineering: builds features
bot.py - Trading loops → RandomForest inference: scores trades
bot.py - RandomForest inference → Feature engineering: uses features
ml/predictor.py - Trading loops → PPO inference: requests signal
bot.py - PPO inference → Feature engineering: builds observation
- RF training → Feature engineering: uses feature schema
ml/trainer.py - PPO training → Trading environment: trains on environment
rl/trainer.py - Trading environment → Feature engineering: builds observations
rl/environment.py - Trading environment → Reward function: computes reward
README.md - Trading loops → Consensus sizing: combines consensus
bot.py - Trading loops → Risk validation: validates trade
README.md - Trading loops → Order execution: submits approved order
bot.py - Order execution → Market data client: uses broker client
executor.py - Trading loops → Position tracking: tracks positions
bot.py - Position tracking → Market data client: syncs open trades
position_manager.py - Trading loops → Trade records: records activity
bot.py - Live dashboard → Market data client: reads account data
dashboard.py - Live dashboard → Session filter: reads session
dashboard.py - Trading loops → Mobile alerts: sends trade alerts
README.md - Mobile alerts → Pushover: sends notifications
README.md - Operator → Live dashboard: views status
README.md