A Python implementation of the "Enhanced Bollinger Band Stock Quantitative Trading Strategy Based on Random Forest".
src/bollinger_forest: Source code.data/: Local cache for stock data (CSV).evaluation/: Output plots and summary CSVs.
- Clone the repository.
- Install in editable mode:
pip install -e .Run the command line tool:
bollinger-forest --tickers 2888.HK 0005.HK 0939.HK --start 2011-01-01 --end 2021-12-31--tickers: List of Yahoo Finance tickers (default: 2888.HK 0005.HK).--start: Start date for data (YYYY-MM-DD).--end: End date for data.--split: Date to split Training and Testing data (default: 2019-01-01).
- Classical Strategy: Buys when price < Lower Band, Sells when price > Upper Band.
- Enhanced Strategy:
- Uses Random Forest to predict the 3-day Weighted Moving Average (WMA) change.
- Uses Predicted WMA to trigger Bollinger Band signals.
- Uses ATR (Average True Range) for Stop Loss logic.
- Create the folder structure as shown above.
- Paste the code into the respective files.
- Open your terminal in the root folder.
- Install:
pip install -e . - Run:
bollinger-forest --tickers 2888.HK 0005.HK