-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_bt.py
53 lines (43 loc) · 1.56 KB
/
run_bt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 21:52:32 2019
@author: jacobsolawetz
"""
#when we vary the roll day much different behavior occurs...
#to do: add in a market shift by day parameter. As if the market ran in an alternative time series.
#this disambiguates the fact that roll_day 5 is closer to expiration and delta pops up.
import warnings
#toggle pandas future warnings off
warnings.filterwarnings('ignore')
from backtester import Backtester
from visualizer import Visualizer
from visualizer_multi_roll import Visualizer_Multi_Roll
backtest_name = '15x_2.0_ml60_fan_out_rolls'
#in order to do constant_margin now we need to also write the bought call in there with arbitrary z-score
strategy = [['P', 2.0, 'SELL'], ['P', 2.0, 'BUY']]
#backtest_type = 'normal'
backtest_type = 'constant_margin'
#roll_day = 14
leverage = 15
max_loss = .6
#tester = Backtester(roll_day, strategy, leverage, backtest_type, max_loss)
#tester.load_data()
#tester.set_up_calendar()
#tester.get_roll_days()
#tester.backtest()
tester_results = []
for roll_day in [5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]:
#for roll_day in [5,10]:
tester = Backtester(roll_day, strategy, leverage, backtest_type, max_loss)
tester.load_data()
tester.set_up_calendar()
tester.get_roll_days()
tester.backtest()
tester_results.append(tester.results)
print('backtested roll day ' + str(roll_day))
viz = Visualizer_Multi_Roll(tester_results, backtest_name)
viz.save_figs()
#viz = Visualizer(tester.results,backtest_name)
#viz.save_figs()
#viz.print_results()