Event Driven Backtesting Framework
Visualizing a mean reversion.
This is a cmake project. Make sure you have some sort of c++ compiler that is detected by cmake. Steps :-
- git clone https://github.com/Stoozy/mercury.git
cd mercury
- mkdir build
cd build
- Run
cmake ..
. Makefile will be created in build directory. - Run
make
. Now, the executablebuild/mercury
should be created.
Mercury requires a config.json file to run. Here is a sample one:
{
"historical_data": "AAPL.csv",
"strategy": {
"name": "MEAN_REVERSION",
"moving_average": "EMA",
"days": {
"short_term": 10,
"long_term": 30
},
"smoothing": 2,
"output": "output.csv"
},
"capital": 10000,
"positions": [
{
"symbol": "AAPL",
"quantity": 0,
"price": 0
}
],
"slippage": 0.005,
"transaction_cost": 0.001,
"start_date": "2018-10-12",
"end_date": "2023-10-11"
}
- Download historical data from internet. You can use Yahoo Finance.
- Put the csv file in the same directory as
config.json
. Inconfig.json
, change the following fieldshistorical_data
to the file-name.csvstart_date
to the start date in your fileend_date
to the end date in your file.
- Go to the parent directory. Run
build/mercury -c config.json
. The file output.csv will be created. - Now, run
python visualize.py
to view plot of the output graphs. Note that you need pandas and matplotlib installed in your system.