QTSBE - Quantitative Trading Strategy Backtesting Environment
QTSBE is an open-source project aimed at providing a robust environment for backtesting quantitative trading strategies. It includes an API developed in Python using Flask and an interface built with Python.
Features
- Comprehensive backtesting environment for quantitative trading strategies.
- API for strategy implementation and testing.
- Visualization tools for strategy performance.
Getting Started
Installation
-
Clone the repository:
git clone https://github.com/simonpotel/QTSBE
-
Install dependencies:
cd QTSBE
pip install -r requirements.txt
Usage
-
Create Your Strategy:
- Create your strategy based on the default structure found in
api/strategies/default.py
, or use the simple base example in api/strategies/rsi_example
.
- Implement your strategy by creating a new Python file and defining the
analyse
function that returns the required data. You can choose to use indicators within the code without passing them in the JSON response.
-
Start the API:
- Run the API using
api/api.py
.
python api/api.py
-
Access the API:
- Get the API response in your web browser:
http://127.0.0.1:5000/QTSBE/<data_set>/<your_strategy_name>
.
-
Visualize Results:
- Start the GUI for visualizing the API response by running
display/python/main_gui.py
.
python display/python/main_gui.py
- The display tool allows you to select your strategy and the dataset to apply it to.
Example of the default strategy:
![image](https://github.com/simonpotel/QTSBE/assets/155122848/c276e11b-043b-4d45-a58c-a0d776ac9da2)
-
Real Strategy Stats:
Scanner
BinanceScanner
Powerful tool for analyzing Binance trading pairs within the quantitative trading strategy backtesting environment. It conducts comprehensive scans of all Binance pairs, queries the API with the specified strategy, and consolidates the results into a single file.
- Comprehensive Analysis: Analyzes all Binance trading pairs to provide insights into their performance.
- Strategy Integration: Executes API queries with the user's specified strategy to evaluate pair performance.
- Key Metrics: Calculates and presents essential metrics such as best and worst ratios, highest CR (Cumulative Ratio), and lowest drawdowns.
- Efficient Execution: Conducts scans efficiently, enhancing productivity in strategy assessment and optimization.
Usage
To use the scanner, edit strategy_scanner/scan.py
to specify your desired strategy and adjust any relevant arguments. Then, run the following command:
python strategy_scanner/scan.py
![image](https://github.com/simonpotel/QTSBE/blob/doc/files/strategy_scanner/BinanceScanner/scan_example.png)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Note: The contents of the files in the indicators folder are not guaranteed to be completely accurate. Always review the code of each indicator before use.
Librairies
- customtkinter: A custom themed version of Tkinter, providing enhanced visual elements and features for GUI development.
- matplotlib: A comprehensive library for creating static, animated, and interactive visualizations in Python.
- loguru: A logging library that provides an easy-to-use interface for logging in Python applications.
- ccxt: A cryptocurrency trading library that provides unified APIs for accessing trading data and executing trades across multiple cryptocurrency exchanges.
- tables: A package for managing hierarchical datasets and storing large data arrays efficiently in HDF5 format.
- plotly: An open-source graphing library for creating interactive, publication-quality graphs and charts.
- pandas: A powerful data manipulation and analysis library, providing data structures and functions for working with structured data.
- flask: A lightweight web application framework for Python, providing tools for building web applications and APIs.
- flask_cors: A Flask extension for handling Cross-Origin Resource Sharing (CORS), allowing web applications to make requests to domains outside of their own.
- mysql: A MySQL database connector for Python, enabling interaction with MySQL databases using Python code.
- mysqlclient: A Python interface to MySQL, providing access to MySQL database servers from Python applications.
Contact
For questions or inquiries, feel free to contact me on LinkedIn.