(self)
| 130 | def test_assertions(self): |
| 131 | class Assertive(Strategy): |
| 132 | def init(self): |
| 133 | self.sma = self.I(SMA, self.data.Close, 10) |
| 134 | self.remains_indicator = np.r_[2] * np.cumsum(self.sma * 5 + 1) * np.r_[2] |
| 135 | |
| 136 | self.transpose_invalid = self.I(lambda: np.column_stack((self.data.Open, |
| 137 | self.data.Close))) |
| 138 | |
| 139 | resampled = resample_apply('W', SMA, self.data.Close, 3) |
| 140 | resampled_ind = resample_apply('W', SMA, self.sma, 3) |
| 141 | assert np.unique(resampled[-5:]).size == 1 |
| 142 | assert np.unique(resampled[-6:]).size == 2 |
| 143 | assert resampled in self._indicators, "Strategy.I not called" |
| 144 | assert resampled_ind in self._indicators, "Strategy.I not called" |
| 145 | |
| 146 | assert 1 == try_(lambda: self.data.X, 1, AttributeError) |
| 147 | assert 1 == try_(lambda: self.data['X'], 1, KeyError) |
| 148 | |
| 149 | assert self.data.pip == .01 |
| 150 | |
| 151 | assert float(self.data.Close) == self.data.Close[-1] |
| 152 | |
| 153 | def next(self, _FEW_DAYS=pd.Timedelta('3 days')): # noqa: N803 |
| 154 | assert self.equity >= 0 |
nothing calls this directly
no test coverage detected