Open peilinnnnnn opened 1 year ago
Indeed, equity
is computed only once per bar, taking into account only the last_price
(i.e. close) for trade P/L computation. Nice catch!
https://github.com/kernc/backtesting.py/blob/0ce24d80b1bcb8120d95d31dc3bb351b1052a27d/backtesting/backtesting.py#L802-L813 https://github.com/kernc/backtesting.py/blob/0ce24d80b1bcb8120d95d31dc3bb351b1052a27d/backtesting/backtesting.py#L788-L790
As depicted in the picture, the first trade generated a profit, but during the trade, a bar had a significantly low "Low Price", indicating that in reality, the first trade would have been subject to forced liquidation due to my margin setting of 0.01. Is there a way to fix this issue now?