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

Method test_data_extra_columns

backtesting/test/_test.py:108–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

106 Backtest(df, SmaCross).run()
107
108 def test_data_extra_columns(self):
109 df = GOOG.copy(deep=False)
110 df['P/E'] = np.arange(len(df))
111 df['MCap'] = np.arange(len(df))
112
113 class S(Strategy):
114 def init(self):
115 assert len(self.data.MCap) == len(self.data.Close)
116 assert len(self.data['P/E']) == len(self.data.Close)
117
118 def next(self):
119 assert len(self.data.MCap) == len(self.data.Close)
120 assert len(self.data['P/E']) == len(self.data.Close)
121
122 Backtest(df, S).run()
123
124 def test_data_invalid(self):
125 with self.assertRaises(TypeError):

Callers

nothing calls this directly

Calls 2

BacktestClass · 0.90
runMethod · 0.45

Tested by

no test coverage detected