| 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): |