Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Stop loss on the same day the position was opened #119

Open
Labels
bugSomething isn't working
@datek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /