You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah I noticed the same. It seems the equity and cash attributes are not being updated correctly for each new candle.
I think the fix would be as follows. Under the Broker class we have to fix:
the equity property should be changed from
@property
def equity(self) -> float:
return self._cash + sum(trade.pl for trade in self.trades)
to
@property
def equity(self) -> float:
return self._cash + sum(trade.value for trade in self.trades)
on the _close_trade method we should replace self._cash += trade.pl
for self._cash += trade.value
on the _open_trade method we should add at the end the following line: self._cash = self._cash - trade.size*trade.entry_price
Expected Behavior
Equity value should be same as of starting equity value
Actual Behavior
It changes based on number of data points
Steps to Reproduce
`class SmaCross(Strategy):
# Define the two MA lags as class variables
# for later optimization
n1 = 10
n2 = 20
`
Additional info
Backtesting version: 0.3.3
bokeh.__version__
:The text was updated successfully, but these errors were encountered: