Hi
When submitting a StopMarketOrder, how to set the stop loss and profit target?
def buyStopOder(self, current_price, symbol, quantity, stopPrice, time, tag):
newTicket = self.StopMarketOrder(symbol, float(quantity), d.Decimal(stopPrice), tag)
self.openStopMarketOrders.append(newTicket)
self.Log("[buyStopOder]: ({0}, {1}, {2}, {3}, {4})".format(current_price, symbol, quantity, stopPrice, time, tag))
If a StopMarketOrder does not get filled, will it expire automatically after a certain period of time?
Thanks
Jared Broad
Hey CT! Profit targets and stop losses are not features of the StopMarketOrder but can be easily built into your algorithm with a few lines of code. e.g. You can use price and the order events to place the take profit with a market order; or use 2 in-market stop-limit orders to bracket your position and then cancel one of them when the other is filled. Please see the documentation for how to update and cancel orders with the order tickets.
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.
CloudTrader
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!