For financial reinforcement learning (FinRL), we provide a way to address the dreaded overfitting trap and increase your chances of success in the wild world of cryptocurrency trading. Our approach has been tested on 10 different currencies and during a market crash period, and has proven to be more profitable than the competition. So, don't just sit there, join us on our journey to the top of the crypto mountain!
Our paper
This repository is ready for work with Binance API for cryptocurrency trading using Deep Reinforcement Learning (DRL).
β
Updated Dependencies - All packages are compatible with Python 3.8+ (and recommended for Python 3.10).
β
Fixed Deprecated Methods - Code is compatible with new versions of pandas and numpy.
β
Added Error Handling - Improved stability during execution.
β
Optimized Performance - Replaced outdated pandas methods with more efficient alternatives.
- Python 3.10 (Recommended version)
- Binance API keys
For Python 3.10 (Recommended):
pip install -r requirements-python310.txtFor Python 3.11+:
pip install -r requirements.txt- Log in to your Binance account β API Management
- Create new API keys
- Open
config_api.pyand replace placeholders:
API_KEY_BINANCE = 'YOUR_PUBLIC_API_KEY'
API_SECRET_BINANCE = 'YOUR_SECRET_API_KEY'Main settings are configured in config_main.py:
- TIMEFRAME:
'5m'- 5-minute candlesticks - TICKER_LIST: List of cryptocurrencies for trading (e.g.,
['BTC', 'ETH'])) - TECHNICAL_INDICATORS: Technical indicators (MACD, RSI, CCI, DX)
python 0_dl_trainval_data.py # Download training/validation data
python 0_dl_trade_data.py # Download trade dataChoose one of the following optimization schemes:
- Combinatorial Purged Cross-validation:
python 1_optimize_cpcv.py
- K-Fold Cross-validation:
python 1_optimize_kcv.py
- Walk-forward validation:
python 1_optimize_wf.py
python 2_validate.py python 4_backtest.py config_main.py: Main configuration file.config_api.py: Binance API keys.processor_Binance.py: Data processing for Binance API.environment_Alpaca.py(Note: Alpaca is a separate trading environment; this project focuses on Binance).drl_agents/: DRL algorithms (e.g., PPO, A2C, DDPG, TD3, SAC).
- AAVE, AVAX, BTC, ETH, LINK, LTC, MATIC, NEAR, SOL, UNI
- New cryptocurrencies can be added to
config_main.py.
- MACD (Moving Average Convergence Divergence)
- RSI (Relative Strength Index)
- CCI (Commodity Channel Index)
- DX (Directional Movement Index)
- API Keys: Never store API keys in public repositories.
- Testing: Test on a demo account first.
- Risks: Cryptocurrency trading involves high risks.
- Versions: Ensure you are using Python 3.8+.
- Check
config_api.py - Ensure API keys are entered correctly
- Check internet connectivity
- Ensure cryptocurrency symbols are correct
- Check Binance API rate limits
# Install TA-Lib (if needed)
conda install -c conda-forge ta-lib # For Anaconda
# or for macOS:
brew install ta-lib Results are saved in the /plots_and_metrics/ folder.
- Modify dates in
config_main.py - Tune technical indicators (e.g., MACD parameters)
- Adjust cryptocurrency lists in
config_main.py
If you encounter issues:
- Check error logs for clues.
- Verify all dependencies are installed (run
pip install -r requirements.txtorpip install -r requirements-python310.txt). - Confirm Binance API keys are correctly configured in
config_api.py.
Ready to Go! π
This project is fully configured for cryptocurrency trading on Binance using advanced Deep Reinforcement Learning algorithms.
