A comprehensive trading system that combines reinforcement learning, risk management, and real-time execution.
- PPO-based trading agent
- Custom trading environments
- Multi-agent support
- Hyperparameter optimization with Ray Tune
- MLflow experiment tracking
- Position size control
- Portfolio VaR monitoring
- Multi-asset correlation tracking
- Dynamic risk adjustment
- Advanced backtesting
- Real-time execution via CCXT
- Paper trading support
- Order types: limit, stop-limit, trailing-stop
- Rate limiting and error handling
- Network resilience
- OHLCV data processing
- Technical indicators (TA-Lib)
- Market scenario simulation
- Multi-asset data handling
- Real-time data streaming
pip install -r requirements.txt
- Training an Agent
from training.agents import PPOAgent
from training.environments import TradingEnv
# Initialize and train agent
agent = PPOAgent(config)
env = TradingEnv(data)
agent.train(env)
- Backtesting
from training.utils.risk_backtest import RiskAwareBacktester
from training.utils.risk_config import RiskConfig
# Run backtest
backtester = RiskAwareBacktester(data, risk_config)
results = backtester.run(agent)
- Live Trading
from trading.live import LiveTradingEnvironment
# Start live trading
live_env = LiveTradingEnvironment(
exchange_config=config,
risk_config=risk_config
)
live_env.run(agent)
trading_bot/
├── training/
│ ├── agents/ # RL agents (PPO, etc.)
│ ├── environments/ # Trading environments
│ └── utils/
│ ├── risk_backtest.py
│ └── hyperopt.py # Ray Tune integration
├── trading/
│ ├── live/ # Live trading
│ ├── paper/ # Paper trading
│ └── data/ # Data handling
├── risk/
│ └── risk_manager.py # Risk management
├── tests/
│ ├── test_agents/
│ ├── test_trading/
│ └── test_risk/
└── scripts/
├── train.py
├── backtest.py
└── live_trade.py
python -m pytest tests/
- Follow PEP 8
- Add docstrings
- Update CHANGELOG.md
- See class/method docstrings
- Check CHANGELOG.md
- Review test files
- Fork repository
- Create feature branch
- Add tests
- Update documentation
- Submit pull request
MIT License