Open
Description
Expected Behavior
Strategy closes the position at 720
Actual Behavior
Strategy closes the position on next candle at open price, 705.58
Steps to Reproduce
Run the following code. You can see the wrong behaviour on 2012-10-18
from backtesting import Backtest, Strategy
from backtesting.test import GOOG
class DummyStrategy(Strategy):
def init(self):
pass
def next(self):
if f"{self.data.index[-1]}" == "2012-10-17 00:00:00":
self.buy(sl=720)
if __name__ == "__main__":
data = GOOG.tail(100)
backtest = Backtest(data, DummyStrategy, cash=10000)
result = backtest.run()
backtest.plot()
Additional info
- Backtesting version: 0.2.0