Skip to content

This project was driven by the need to provide our client Mela, a startup focusing on simplifying cryptocurrency investments, with a reliable and scalable platform for backtesting trading strategies. Additionally, leveraging advanced forecasting methods would enhance the platform's capability to predict future price trends with greater accuracy.

License

Notifications You must be signed in to change notification settings

10-academy-w-9/crypto-trading-backtesting

Repository files navigation

Crypto Trading Backtesting

Crypto Trading Backtesting: Scalable Backtesting Infrastructure for Cryptocurrencies

Overview

The Crypto Trading Backtesting project aims to provide a robust, large-scale trading data pipeline designed to help users backtest cryptocurrency trading strategies. The system uses historical candlestick data to simulate trades and evaluate strategies, providing valuable insights and reducing the risk associated with trading cryptocurrencies.

Features

  • Data Ingestion : Fetches historical candlestick data from Binance and Yahoo Finance.

  • Backtesting Engine: Utilizes advanced frameworks like Backtrader, Freqtrade, and Vectorbt to simulate trades based on various strategies.

  • Metrics Calculation: Evaluates strategies using metrics such as returns, number of trades, winning trades, losing trades, max drawdown, and Sharpe ratio.

  • Dynamic Scene Generation: Automates backtesting runs with customizable parameters.

  • MLOps Integration: Incorporates tools like Apache Airflow, Kafka, MLflow, and CML for seamless pipeline automation and monitoring.

  • Frontend Interface: Provides a user-friendly interface for running backtests and viewing results.

  • Index Fund: Algorithm that shows the best backtested strategy and implements a recommendation based on a combination of best returns.

Skills and Knowledge

  • Skills: Technical analysis, backtesting, trading, data pipeline building, structured streaming, workflow orchestration.
  • Knowledge: Financial prediction, enterprise-grade data engineering using Apache and Databricks tools.

Technical Skills

  • Python Programming
  • SQL Programming
  • Data & Analytics Engineering
  • MLOps
  • Software Development Frameworks

Project Structure

crypto-trading-backtesting/
│
├── .github/
│   ├── workflows/
│   │   └── ci-cd.yml
│   └── ISSUE_TEMPLATE.md
│
├── airflow/
│   ├── dags/
│   │   ├── backtest_dag.py
│   │   └── monitor_dag.py
│   └── plugins/
│
├── app/
│   ├── __init__.py
│   ├── main.py
│   ├── models/
│   │   ├── backtest.py
│   │   └── user.py
│   ├── routes/
│   │   ├── auth.py
│   │   ├── backtest.py
│   │   └── index.py
│   ├── services/
│   │   ├── backtest_service.py
│   │   ├── kafka_service.py
│   │   └── mlflow_service.py
│   └── templates/
│       └── index.html
│
├── config/
│   ├── airflow.cfg
│   ├── config.py
│   ├── kafka-config.yaml
│   └── mlflow-config.yaml
│
├── docs/
│   ├── DESIGN.md
│   └── USAGE.md
│
├── notebooks/
│   ├── backtesting_yfinance.ipynb
│   ├── backtesting.ipynb
│   ├── Chronos.ipynb
│   ├── data_exploration.ipynb
│   └── model_training.ipynb
│   └── moirai_forcast.ipynb
│
├── scripts/
│   ├── backtest_runner.py
│   ├── data_ingestion.py
│   ├── forecast_backtest_runner.py
│   ├── forecast.py
│   ├── mlflow_backtest.py
│   └── model_training.py
│   └── moirai_forcast.py
│
├── tests/
│   ├── unit/
│   │   ├── test_backtest_service.py
│   │   ├── test_kafka_service.py
│   │   └── test_mlflow_service.py
│   ├── integration/
│   │   ├── test_end_to_end.py
│   └── conftest.py
│
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
├── LICENSE
├── README.md
└── setup.py

Set up Instructions

  1. Clone the repository:

    git clone https://github.com/10-academy-w-9/crypto-trading-backtesting.git
    cd crypto-trading-backtesting
  2. Set up a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  #linux and Mac
    `venv\Scripts\activate`   #On Windows 
  3. Install Requirements:

    pip install -r requirements.txt
  4. Configure environmnet variables and configurations:

    .env
    app/config.py
    
  5. Run backend api and mlflow server:

    mlflow server --host 127.0.0.1 --port 5050
    python run.py
  6. Run frontend interface

    cd frontend/
    npm install
    npm run start
  7. Run Chronos

    pip install git+https://github.com/amazon-science/chronos-forecasting.git
    
    pip install pandas numpy torch sqlalchemy psycopg2-binary matplotlib chronos

Altenative

  1. Run run_project.sh file:
    sh run_prject.sh
    

Usage

  1. Provide input descriptions of the trading strategies, including scenarios and expected outputs.

  2. Run the backtesting system to simulate trades and evaluate strategies.

  3. Review the generated metrics to assess the performance of different trading strategies.

  4. Select the desired strategies for further use or real-time trading.

License

This project is licensed under the MIT License.

Contributors

Challenge by

10 Academy

About

This project was driven by the need to provide our client Mela, a startup focusing on simplifying cryptocurrency investments, with a reliable and scalable platform for backtesting trading strategies. Additionally, leveraging advanced forecasting methods would enhance the platform's capability to predict future price trends with greater accuracy.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •