Hello all,

I'm using the Algorithm Framework for an alpha and I'm trying to modify the SpreadExecutionModel to use limit orders instead of market orders. 

My intention with limit orders is not to get a good fill but rather to guarantee I'm not getting a terrible fill if the security I'm trading happens to be illiquid at that moment in time.

For example, if the closing price for a security is P, limit orders might use 0.995 x P to save a couple cents per share on a large order. What I'm trying to do is actually set the limit to 1.10 x P to ensure that the purchase price of the share is never more than 10% of the current price. This is to handle rare scenarios when a market order can execute from an insane Ask price for illiquid stock (e.g. Ask = 5 x Bid). 

I've been using Market Orders up to this time. My understanding is that if I set the limit price significantly higher than the current price, it should act just like a Market Order since the buy condition is immediately met (except in those rare situations). This is why in the SpreadExecutionModel, I updated 

if self.SpreadIsFavorable(security):
  algorithm.MarketOrder(symbol, unorderedQuantity)

to 

if self.SpreadIsFavorable(security):
  if unorderedQuantity > 0: # different limits for short and long orders
    algorithm.LimitOrder(symbol, unorderedQuantity, security.Close * 1.1)
  elif unorderedQuantity < 0:
    algorithm.LimitOrder(symbol, unorderedQuantity, security.Close * 0.9)

However, I'm finding that these Limit Orders with a limit significantly higher than the market close lead to fills different than market orders and the results are frequently worse than just sticking with Market Orders. I find it hard to believe that every order is this “rare” situation.

I've attached a backtest below using limit orders. If you comment out the limit order logic and replace it with the original market order logic, you can see the difference/issues firsthand (6% returns vs 22% returns).

I'm guessing my understanding of limit orders in LEAN might be incorrect, but any explanation how would be helpful.

Thanks.