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

Method next

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

Source from the content-addressed store, hash-verified

425 name='exit portion', plot=plot, overlay=False, scatter=True, color='black')
426
427 def next(self):
428 super().next()
429
430 exit_portion = self.__exit_signal[-1]
431 if exit_portion > 0:
432 for trade in self.trades:
433 if trade.is_long:
434 trade.close(exit_portion)
435 elif exit_portion < 0:
436 for trade in self.trades:
437 if trade.is_short:
438 trade.close(-exit_portion)
439
440 entry_size = self.__entry_signal[-1]
441 if entry_size > 0:
442 self.buy(size=entry_size)
443 elif entry_size < 0:
444 self.sell(size=-entry_size)
445
446
447class TrailingStrategy(Strategy):

Callers 1

nextMethod · 0.45

Calls 3

buyMethod · 0.80
sellMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected