Something wrong with StopMarketOrder

Hi, could somebody explain to me behavior of this 5-line script?

  • I place one MarketOrder to buy 1 share of Microsoft
  • Then I place one StopMarketOrder to sell 1 share of Microsoft if pricehits $1000
  • Price never hits $1000 but two orders get filled, WHY???

Why stop market order acts like market order???


Update Backtest

Ok, I think I figured it out, in a perfect world I should be able to use LimitOrder and StopMarketOrder from the both sides of the price, but in a world of QuantConnect I can use LimitOrder as a Take Profit only, and StopMarketOrder as a Stop Loss only. Just in case, I think it is a bug, because if I can't use Limit Order as a stop loss it means that on a fast market with limited liquidity I can't actually limit my losses, my position will be closed way below the price that I set. Surprise.

Attached another simple script that shows working example with SL / TP. If somebody will try to exchange StopMarketOrder and LimitOrder in this script you willl see that they will silently ruin your strategy by executing as a Market Orders. They won't even show any info about execution, they just turn from Limit and Stop to Market immediately.


Update Backtest


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.


This discussion is closed