Back

Referencing specific orders

Hi there,
I found different code examples where an orderId is returned as a new Order object is created. This works perfect for what I need, but at the same time, I need to be able to reference a certain Id when selling. For example, if I opened an order with Id 1 and quantity 50, I want to be able to sell just by providing the Id, and letting the code to figure out the associated quantity. Is this possible? Any example is appreciated.
Thanks in advance!
Update Backtest








Welcome to QuantConnect @Angelina! Great question - the documentation is very poor on updating orders. If its a market order it processes immediately so the sell order goes straight through -- so I'll assume you're talking about limit and stops.

Limit and stops would only not process if their prices were not reached. So the minimum information required to update those orders would be the new price & order id.

You can do this relatively easily by submitting a new/updated order: e.g.
Transactions.Update(order);


I have attached the algorithm to demonstrate this here, and made a new algorithm in the QC University called "Creating and Updating Limit Orders". The example sets the price to 95% of MSFT's price every 20 days, until the order is hit.


Once we finish the open sourcing project it will be much easier to understand. Hopefully before the end of this week at the rate we're going!
0

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.


Update Backtest





0

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.


Loading...

This discussion is closed