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

Method next

backtesting/backtesting.py:854–869  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

852 return max(0, self.equity - margin_used)
853
854 def next(self):
855 i = self._i = len(self._data) - 1
856 self._process_orders()
857
858 # Log account equity for the equity curve
859 equity = self.equity
860 self._equity[i] = equity
861
862 # If equity is negative, set all to 0 and stop the simulation
863 if equity <= 0:
864 assert self.margin_available <= 0
865 for trade in self.trades:
866 self._close_trade(trade, self._data.Close[-1], i)
867 self._cash = 0
868 self._equity[i:] = 0
869 raise _OutOfMoneyError
870
871 def _process_orders(self):
872 data = self._data

Callers 1

runMethod · 0.45

Calls 2

_process_ordersMethod · 0.95
_close_tradeMethod · 0.95

Tested by

no test coverage detected