A comprehensive backtesting framework for evaluating cryptocurrency trading strategies using academic research methodologies. Implements four distinct strategies with configurable parameters and robust performance metrics.
cryptotrade/
│
├── strategy/ # Strategy implementations
│ ├── results/ # Backtest results, metrics, summaries
│ │ ├── SmaCross_10runs_metrics_20250510_0007.csv
│ │ ├── SmaCross_10runs_summary_20250510_0007.csv
│ ├── SmaCrossStrategy.html
│ ├── strategy_buyandhold.py
│ ├── strategy_macd.py
│ ├── strategy_randomwalk.py
│ └── strategy_sma.py
│
├── utils/ # Utility modules
│ └── technicals.py # Contains CryptoDataProcessor class
│
├── cryptotrade/processed_data/ # Saved processed datasets
│ └── CryptoDataProcessor_BTC_USD_2021-01-01_to_2024-01-01.csv
│
├── .gitignore
├── README.md
├── requirements.txt- Multiple backtest iterations for statistical significance
- Parameter optimization with constraints
- Transaction cost modeling (commission/slippage)
- Walk-forward testing capability
-
Absolute Metrics:
- Total Return (%)
- Max Drawdown (%)
- Win Rate (%)
- Number of Trades
-
Risk-Adjusted Metrics:
- Sharpe Ratio
- Sortino Ratio
- Calmar Ratio
- Risk-Return Ratio
- Automated OHLCV data fetching via OpenBB
- Local caching of historical data
- Flexible timeframes (daily/hourly)
- Python 3.8+
- pip package manager
# Clone repository
git clone https://github.com/wahidur028/cryptotrade.git
cd cryptotrade
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Set up OpenBB credentials (if needed)
obb account login# Run SMA strategy with default parameters
python strategy_sma.py
# Run MACD strategy with optimization
python strategy_macd.pyEach strategy file contains these configurable parameters:
# Backtest Parameters
NUM_ITERATIONS = 10 # Number of independent runs
OPTIMIZE = False # Enable parameter optimization
CASH = 20000 # Initial capital (USD)
COMMISSION = 0.001 # 0.1% per trade
# Data Parameters
SYMBOL = 'BTC-USD' # Trading pair
START_DATE = '2021-01-01' # Backtest start
END_DATE = '2024-01-01' # Backtest end
INTERVAL = '1d' # Timeframe ('1d', '4h', '1h')results/
├── [Strategy]_[Iterations]runs_metrics_[timestamp].csv
├── [Strategy]_[Iterations]runs_summary_[timestamp].csv
├── [Strategy]_optimized_[params]_[timestamp].csvMetric Description
Return [%] Total percentage return
Sharpe Ratio Risk-adjusted return
Max. Drawdown [%] Largest peak-to-trough decline
Win Rate [%] Percentage of winning trades
# Trades Total number of trades executed
Exposure Time [%] Percentage of time in marketAuthor: Wahidur Rahman
Email: sm.wahidur@gm.gist.ac.kr
GitHub: @wahidur028
Project Link: https://github.com/wahidur028/cryptotrade