Recently we deployed a new version of the LEAN engine. In this new version there are load of new goodies. Here I showcase an updated version of the canonical QCU algorithm, How Do I Use Limit Orders. We've spent some time to make this easier, so I hope you guys like it!

In the new deploy, the standard order functions (MarketOrder, LimitOrder, ect...) will return you an OrderTicket object. The OrderTicket is your reference to your order. You can use it to update, cancel, and even check the status of the order.OrderTicket limitOrderTicket = LimitOrder("SPY", 100, 205);

In order to perform updates, you can call the Update method on the OrderTicket. The Update method takes an UpdateOrderFields object which defines what properties of the order should be updated. We can easily change the limit price using the following line of code: limitOrderTicket.Update(new UpdateOrderFields{LimitPrice = 207.50};

This will submit a request to update the order in our system.

Likewise, you can easily cancel your order using the Cancel method:limitOrderTicket.Cancel();

Check out the attached algorithm which shows updating of the limit price. Check out the UpdateOrderFields class for the other properties that can be updated.