(self)
| 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 |
no test coverage detected