I updated my stop loss using the UpdateStopPrice function and confirmed that the update order event has been submitted, However, when I run the backtest, the updated stop loss doesn't ever seem to trigger.
For example from the logs line 30 to 33:
2020-05-18 12:00:00 buy 285 GE at 6.28
2020-05-21 12:00:00 updating SL from 5.97 to 6.28.
2020-05-21 12:00:00 SL update submitted: 6.28
2020-05-22 11:00:00 sl 285 GE at 5.97
GE is bought at 6.28, stop loss is then adjusted from 5.97 to 6.28 after price has moved. Order event was submitted, but the stop loss was triggered at 5.97 instead of the updated price of 6.28.
What am I doing wrong here?
Shile Wen
Hi Jonathan,
If you could simplify the code and eliminate the helper class and the dictionary, it might make it easier to debug and understand the code. If you are still having troubles after this, please post the updated code so we can help identify the problem.
Best,
Shile Wen
Jonathan Pung
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!