I have a hard time finding resources on how to add a trailing stop loss in QC. Could you please guide me?
QUANTCONNECT COMMUNITY
I have a hard time finding resources on how to add a trailing stop loss in QC. Could you please guide me?
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.
Mia Alissi
Sure, I can guide you on how to add a trailing stop loss in QuantConnect.
Trailing stop orders are a type of stop market orders with a dynamic stop price. They are designed to protect gains by enabling a trade to remain open and continue to profit as long as the price is moving in a favorable direction. The trade closes as soon as the price changes direction by a specified amount.
In QuantConnect, you can send a trailing stop order by calling the
TrailingStopOrdermethod and providing aSymbol, quantity, trailing amount, and the trailing type. Here is an example in Python:If you set the
trailingAsPercentageparameter toFalse, thetrailingAmountis denominated in the asset's quote currency.For more detailed guidance, you can go through the Trailing Stop BootCamp which provides a great resource on how to implement trailing stops in LEAN.
Also, you can follow this GitHub issue to track the progress of the addition of Trailing Stop-Order type to LEAN.
Please note that if you do not have sufficient capital for the order, it is rejected.
I hope this helps! Let me know if you have any other questions.
Sources:
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.
Elham Negahdary
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!