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 :-
cd mercury
cd build
cmake ..
. Makefile will be created in build directory.make
. Now, the executable build/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"
}
config.json
. In config.json
, change the following fields
historical_data
to the file-name.csvstart_date
to the start date in your fileend_date
to the end date in your file.build/mercury -c config.json
. The file output.csv will be created.python visualize.py
to view plot of the output graphs. Note that you need pandas and matplotlib installed in your system.