Add projects/mean_reversion_algo.md
This commit is contained in:
125
projects/mean_reversion_algo.md
Normal file
125
projects/mean_reversion_algo.md
Normal file
@@ -0,0 +1,125 @@
|
||||
# Mean Reversion Trading System for EUR/USD
|
||||
|
||||
Welcome to the Mean Reversion Trading System project, specifically tailored for the EUR/USD forex pair. This project combines the precision of machine learning (ML), the robustness of Backtrader for strategy evaluation, and the real-world applicability of trading via the Oanda platform. It’s structured for scalability, leveraging containerization for development consistency and serverless architecture for operational efficiency.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This system is designed for traders and developers interested in exploring and deploying automated trading strategies. It focuses on the mean reversion principle, a well-regarded concept in finance that suggests asset prices and returns eventually move back towards the mean or average. This project aims to capitalize on this phenomenon using historical EUR/USD data, predictive modeling, and live execution.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
/mean-reversion-trading
|
||||
|-- /data
|
||||
| |-- /raw # Store raw historical data from Oanda
|
||||
| `-- /processed # Processed data, ready for ML
|
||||
|
|
||||
|-- /models
|
||||
| |-- /trained # Location for storing trained models
|
||||
| `-- model_training.py # Script for ML model training
|
||||
|
|
||||
|-- /strategies
|
||||
| |-- mean_reversion_strategy.py # Strategy implementation for Backtrader
|
||||
|
|
||||
|-- /backtesting
|
||||
| |-- backtest.py # Backtesting script using Backtrader
|
||||
|
|
||||
|-- /trading
|
||||
| |-- live_trade.py # Live trading execution script
|
||||
|
|
||||
|-- /utils
|
||||
| |-- data_fetcher.py # Utility script for data retrieval
|
||||
| |-- feature_engineering.py # Data processing and feature engineering
|
||||
| `-- indicators.py # Custom technical indicators
|
||||
|
|
||||
|-- Dockerfile # For containerization
|
||||
|-- requirements.txt # Python package dependencies
|
||||
`-- README.md # Project documentation
|
||||
```
|
||||
|
||||
### Detailed Component Overview
|
||||
|
||||
- **/data**: Contains both raw and processed datasets. Raw data is directly fetched from Oanda, while processed data includes features engineered to enhance model training.
|
||||
- **/models**: This directory is pivotal for the ML lifecycle, encompassing scripts for training, validation, and serialization of models.
|
||||
- **/strategies**: Implements trading strategies within the Backtrader framework, enabling a seamless transition from theory to practical testing.
|
||||
- **/backtesting & /trading**: These separate concerns between historical strategy evaluation and real-world application, ensuring a clear pathway from concept to execution.
|
||||
- **/utils**: A collection of utility scripts support the data pipeline, from fetching and cleaning to feature engineering, alongside custom indicator development for strategic analysis.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
|
||||
Ensure Python 3.8+ is installed on your system. Clone this repository and navigate into the project directory. Set up a virtual environment and install the required dependencies:
|
||||
|
||||
```sh
|
||||
python -m venv venv
|
||||
source venv/bin/activate # or venv\Scripts\activate on Windows
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Environment Configuration
|
||||
|
||||
Create a `.env` file in the project root. Add your Oanda API credentials here:
|
||||
|
||||
```plaintext
|
||||
OANDA_ACCOUNT_ID=<your_account_id>
|
||||
OANDA_API_KEY=<your_api_key>
|
||||
```
|
||||
|
||||
### Running the Project
|
||||
|
||||
#### Data Preparation
|
||||
|
||||
Fetch and prepare your data for analysis and model training:
|
||||
|
||||
```sh
|
||||
python utils/data_fetcher.py
|
||||
```
|
||||
|
||||
#### Model Training
|
||||
|
||||
Train your model using historical data:
|
||||
|
||||
```sh
|
||||
python models/model_training.py
|
||||
```
|
||||
|
||||
#### Backtesting
|
||||
|
||||
Evaluate your strategy with Backtrader:
|
||||
|
||||
```sh
|
||||
python backtesting/backtest.py
|
||||
```
|
||||
|
||||
#### Live Trading
|
||||
|
||||
Execute your strategy in the live market:
|
||||
|
||||
```sh
|
||||
python trading/live_trade.py
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
For containerization, build the Docker image with:
|
||||
|
||||
```sh
|
||||
docker build -t mean-reversion-trading .
|
||||
```
|
||||
|
||||
To run the containerized application:
|
||||
|
||||
```sh
|
||||
docker run -it mean-reversion-trading
|
||||
```
|
||||
|
||||
For serverless deployment, refer to your cloud provider's documentation for deploying Docker containers and setting up serverless functions for tasks like scheduled data fetching and model retraining.
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions! Whether it's feature requests, bug reports, or code contributions, please feel free to reach out or submit a pull request.
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the MIT License. See `LICENSE` for more information.
|
||||
Reference in New Issue
Block a user