-
Notifications
You must be signed in to change notification settings - Fork 73
/
run.py
79 lines (62 loc) · 1.83 KB
/
run.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import backtrader as bt
from FearGreedStrategy import FearGreedStrategy
from PutCallStrategy import PutCallStrategy
from VIXStrategy import VIXStrategy
cerebro = bt.Cerebro()
cerebro.broker.setcash(100000)
class SPYPutCallFearGreedVixData(bt.feeds.GenericCSVData):
lines = ('put_call', 'fear_greed', 'vix')
params = (
('dtformat', '%Y-%m-%d'),
('date', 0),
('open', 1),
('high', 2),
('low', 3),
('close', 4),
('adj', 5),
('volume', 6),
('put_call', 7),
('fear_greed', 8),
('vix', 9)
)
class PutCallData(bt.feeds.GenericCSVData):
params = (
('dtformat', '%Y-%m-%d'),
('date', 0),
('put_call', 4),
('volume', -1),
('openinterest', -1)
)
class FearGreedData(bt.feeds.GenericCSVData):
params = (
('dtformat', '%Y-%m-%d'),
('date', 0),
('fear_greed', 4),
('volume', -1),
('openinterest', -1)
)
class VIXData(bt.feeds.GenericCSVData):
params = (
('dtformat', '%Y-%m-%d'),
('date', 0),
('vix', 4),
('volume', -1),
('openinterest', -1)
)
spy_combined_csv_file = "datasets/spy-put-call-fear-greed-vix.csv"
put_csv_file = "datasets/put-call.csv"
vix_csv_file = "datasets/vix.csv"
fear_greed_csv_file = "datasets/fear-greed.csv"
spyCombinedFeed = SPYPutCallFearGreedVixData(dataname=spy_combined_csv_file)
putCallFeed = PutCallData(dataname=put_csv_file)
fearGreedFeed = FearGreedData(dataname=fear_greed_csv_file)
vixFeed = VIXData(dataname=vix_csv_file)
cerebro.adddata(spyCombinedFeed)
cerebro.adddata(putCallFeed)
cerebro.adddata(fearGreedFeed)
cerebro.adddata(vixFeed)
cerebro.addstrategy(FearGreedStrategy)
#cerebro.addstrategy(PutCallStrategy)
#cerebro.addstrategy(VIXStrategy)
cerebro.run()
cerebro.plot(volume=False)