Above is an example of two orders,
My orders look like this:
self.LimitOrder(self.ticker, -self.orderQuantity, (1 + self.targetPercent) * self.Securities[self.ticker].Close)
self.StopMarketOrder(self.ticker, -self.orderQuantity, (1 - self.targetPercent) * self.Securities[self.ticker].Close)
I am confused why when using these functions they have such a long delay between execution. Is there a class in charge of the order execution that is not using minute resolution or has a configuration that is causing this? I cannot seem to find it in documentation. I am using minute resolution by the way.
Shile Wen
Hi Kyle,
The stop took a long time to fill because the price after 9:42 was above the stop price until 10:22 on April 9th. Furthermore, the limit order took a long time to fill because the price after 10:54 didn't reach the limit price until 11:20. For future reference, we can simply plot the price of our security to determine why the orders aren't getting filled. If this doesn't fully address the issue, please attach a backtest.
Best,
Shile Wen
Kyle L
Thanks Shile Wen that makes sense. If you don't mind could you also touch on how the execution works? I have set both the slippage and fee models to zero:
self.Securities[...].SetFeeModel(ConstantFeeModel(0)) self.Securities[...].SetSlippageModel(ConstantSlippageModel(0))
However, the orders I am submitting still do not execute at the price they are triggered at. Is this possibly due to my use of minute resolution instead of by tick?
Shile Wen
Hi Kyle,
This is because the stop and limit orders fill at the worse price. For example, buy limit order fill price is the minimum between the last bar high and the limit price.
Best,
Shile Wen
Arthur Asenheimer
I have one thing to add to what Shile has already mentioned:Â
Keep in mind that there is also the Bid-Ask spread. Setting ConstantSlippageModel(0) does not cause spreads to disappear. (relevant for MKT orders only of course)
Kyle L
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!