Currently Liquidate and Stop are the only options to stop an algo, but it would be nice if we could have a custom option to stop. This would enable us to stop an algo more elegantly, perhaps stopping new entry strategies while continuing to run exit strategies. Maybe there could be class which runs when the button is pressed:
class CustomStop { maximumEntriesReached = true }
Also, Liquidate only uses Market Orders I think, which is not helpful when trying to liquidate after hours.
Mia Alissi
Here is an example implementation to support a custom "stop" for your algorithm and a more flexible after-hours liquidation using stop-limit orders:
Usage:
set_maximum_entries_reached(True)(e.g., from a Research Notebook or via schedule) to prevent new entries but keep running exit logic.after_hours_liquidate()function will use stop-limit orders for positions, which is more suitable for after-hours than market orders.This lets you elegantly stop new entries and control liquidations without using platform-wide Stop or Liquidate buttons!
Sources: Stop Limit Order Regression Algorithm, Order Tickets - QuantConnect.com, Stop Limit Orders - QuantConnect.com, Future Stop Market Order On Extended Hours Regression Algorithm, Trailing Stop Orders - QuantConnect.com
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.
Bryan Lettner
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!