forked from Adonis2115/Backtesting
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbacktest.py
More file actions
Latest commit
60 lines (49 loc) · 1.63 KB
/
Copy pathbacktest.py
File metadata and controls
60 lines (49 loc) · 1.63 KB
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
importdatetime
fromindicators.alligatorimportAlligator
importbacktraderasbt
importbacktrader.feedsasbtfeed
fromstrategies.dipimportBuyDip
fromstrategies.smaimportSmaCross
fromstrategies.goldenCrossimportGoldenCross
fromstrategies.supertrendStrategyimportSupertrendStrategy
fromstrategies.alligatorStrategyimportAlligatorStrategy
fromindicators.pivotsimportPivotPoint
fromstrategies.ArjunBhatiaFuturesimportArjunBhatiaFutures
fromstrategies.StopOrderSubmitimportStopOrderSubmit
fromstrategies.dipBuyimportDipBuy
cerebro=bt.Cerebro()
cerebro.broker.set_cash(1000000)
data=btfeed.GenericCSVData(
dataname='./Data/Custom/BANKNIFTY.csv',
fromdate=datetime.datetime(2020, 1, 1),
todate=datetime.datetime(2020, 12, 31),
nullvalue=0.0,
dtformat=('%Y/%m/%d'),
tmformat=('%H:%M'),
timeframe=bt.TimeFrame.Minutes, compression=1,
sessionstart=datetime.time(9, 15), sessionend=datetime.time(15, 30),
datetime=1,
time=2,
high=4,
low=5,
open=3,
close=6,
volume=-1,
openinterest=-1
)
data2=bt.feeds.YahooFinanceCSVData(
dataname='./Data/Yahoo/BTC-USD.csv',
fromdate=datetime.datetime(2018, 1, 4),
todate=datetime.datetime(2021, 9, 4),
reverse=False
)
# cerebro.adddata(data).plotinfo.plot=False
cerebro.resampledata(data,
timeframe=bt.TimeFrame.Minutes,
compression=15)
cerebro.resampledata(data,
timeframe=bt.TimeFrame.Days,
compression=1).plotinfo.plot=False
cerebro.addstrategy(DipBuy)
cerebro.run()
cerebro.plot(style='candle', barup='green')