MCPcopy Create free account
hub / github.com/kernc/backtesting.py / init

Method init

doc/examples/Multiple Time Frames.py:79–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

77 level = 70
78
79 def init(self):
80 # Compute moving averages the strategy demands
81 self.ma10 = self.I(SMA, self.data.Close, 10)
82 self.ma20 = self.I(SMA, self.data.Close, 20)
83 self.ma50 = self.I(SMA, self.data.Close, 50)
84 self.ma100 = self.I(SMA, self.data.Close, 100)
85
86 # Compute daily RSI(30)
87 self.daily_rsi = self.I(RSI, self.data.Close, self.d_rsi)
88
89 # To construct weekly RSI, we can use `resample_apply()`
90 # helper function from the library
91 self.weekly_rsi = resample_apply(
92 'W-FRI', RSI, self.data.Close, self.w_rsi)
93
94
95 def next(self):

Callers

nothing calls this directly

Calls 2

resample_applyFunction · 0.90
IMethod · 0.80

Tested by

no test coverage detected