Please explain 'self.data0' and 'self.data1' in detail
Could anyone please explain to me the concept of self.data0 and self.data1?
I am trying to understand by reading documents but it seems not quite clear to me on how the values are construct and how can we use them.
I would like to use bt.indicators.OLS_Slope_InterceptN which it seems that it needs both variables.
Member Attributes datas: array of data feeds which have been passed to cerebro - data/data0 is an alias for datas - dataX is an alias for datas[X]
Thank you for your information.
Could you please have a look on how we can pass data to this indicator?
For example, if we load Yahoo 'AAPL' data and want to find the slope and intercept.
Calculates a linear regression using
squares) of data1 on data0
prepend_constantto influence the paramter
_mindatas = 2 # ensure at least 2 data feeds are passed
packages = ( ('pandas', 'pd'), ('statsmodels.api', 'sm'), ) lines = ('slope', 'intercept',) params = ( ('period', 10), ('prepend_constant', True), ) def next(self): p0 = pd.Series(self.data0.get(size=self.p.period)) p1 = pd.Series(self.data1.get(size=self.p.period)) p1 = sm.add_constant(p1, prepend=prepend_constant) slope, intercept = sm.OLS(p0, p1).fit().params self.lines.slope = slope self.lines.intercept = intercept
There has been a discussion on this just 2 days ago:
Thank you @Paska-Houso for your actively help.