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

Method next

backtesting/lib.py:496–506  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

494 self.set_trailing_sl(pct_in_atr)
495
496 def next(self):
497 super().next()
498 # Can't use index=-1 because self.__atr is not an Indicator type
499 index = len(self.data) - 1
500 for trade in self.trades:
501 if trade.is_long:
502 trade.sl = max(trade.sl or -np.inf,
503 self.data.Close[index] - self.__atr[index] * self.__n_atr)
504 else:
505 trade.sl = min(trade.sl or np.inf,
506 self.data.Close[index] + self.__atr[index] * self.__n_atr)
507
508
509class FractionalBacktest(Backtest):

Callers

nothing calls this directly

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected