This repository contains a comprehensive cryptocurrency trading strategy implemented using Backtrader. The strategy leverages various machine learning algorithms to enhance trading decisions, optimizing for returns while managing risk effectively. The project includes detailed backtesting and performance analysis, utilizing historical market data, and offers a robust framework for both development and production environments.
Data Ingestion and Processing: Integration with Binance and Yahoo Finance APIs for historical and real-time data fetching.
Technical Indicators: Implementation of moving averages, volume analysis, and other technical indicators.
Machine Learning Models: Utilization of machine learning models (LSTM, Random Forest, SVM, etc.) for predicting market movements.
Strategy Execution: Customizable trading strategy with adjustable parameters and leverage.
Backtesting: Extensive backtesting capabilities using Backtrader with detailed logging and performance metrics.
Performance Metrics: Calculation of Sharpe Ratio, Sortino Ratio, Value at Risk (VaR), and other key performance metrics.
Visualization: Comprehensive visualizations using Matplotlib, Seaborn, and Plotly for analyzing trading performance and model predictions.
Modular Structure: Well-organized project structure for easy maintenance and scalability.
│
├── data/
│ ├── historical/ # Historical data files
│ ├── processed/ # Processed data files
│
├── models/
│ ├── saved_models/ # Saved machine learning models
│ ├── training_scripts/ # Scripts for training machine learning models
│
├── notebooks/
│ ├── data_exploration.ipynb # Jupyter notebook for data exploration
│ ├── model_training.ipynb # Jupyter notebook for training models
│ ├── backtesting.ipynb # Jupyter notebook for backtesting strategies
│
├── strategies/
│ ├── init.py # Initialization script for strategy package
│ ├── base_strategy.py # Base strategy class with common functionality
│ ├── bitcoin_strategy.py # Bitcoin trading strategy implementation
│ ├── custom_indicators.py # Custom technical indicators
│
├── utils/
│ ├── data_fetcher.py # Utility script for fetching data from APIs
│ ├── data_preprocessor.py # Utility script for data preprocessing
│ ├── logger.py # Custom logging functionality
│
├── main.py # Main script for running the trading strategy
├── requirements.txt # List of required Python packages
├── README.md # Project description and setup instructions
├── .gitignore # Git ignore file
└── LICENSE # Project license
###Clone the repository:
Copy code
git clone https://github.com/yourusername/cryptocurrency_trading_strategy.git
cd cryptocurrency_trading_strategy
Install dependencies:
Copy code
pip install -r requirements.txt
Fetch historical data:
Modify the data_fetcher.py script with your API keys and run it to download historical data.
Train machine learning models:
Use the Jupyter notebooks in the notebooks directory to explore data and train models. Save the trained models in the models/saved_models directory.
Run backtesting:
Execute the backtesting.ipynb notebook to backtest the trading strategy with historical data.
Deploy the strategy:
Use the main.py script to deploy the trading strategy in a live or paper trading environment.