Back

OrderStatus

Hi,

I need to know if an Order has been "Submitted" or "Filled". This isn't working:

First attempt)

if( ticket.Status.ToString() == OrderStatus.Submitted.ToString() )

Second attempt)

if( ticket.Status.ToString() == "Submitted" )

Thanks !

Update Backtest








if I try this:

if ( ticket.Status == OrderStatus.Filled )

 

0

HI Raimon! Please share your algorithm for us to be able to help further. If you're not able to share please see this forum thread for examples of how to use the order event system.

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.


Write comment here.

0


First, to compare strings, avoid using string1 == string2, instead use string1.Equals(string2), whose result is more guaranteed. This is true for many programming languages, you can google it for more detail.Second, in your specificase, you should probable do this:ticket.Status == OrderStatus.SubmittedPlease try it! ;)

0

Thanks Guanting Liu for the comment. 

But I have tryied this two ways and aren't working. If you look at my backtest code you can see this. 

Really don't know what's the problem with:

ticket.Status == OrderStatus.Submitted

 

Thanks again!

 

0

Its failing because you don't have 2 orders, so the if (openOrders.count == 2) isn't returning true.

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.


So gratefull for the assistance,

but:

(openOrders.Count == 2)

is returning true as you can see in this backtest ->

 

0


The backtest I shared, shows it is >2 most of the time so your scan/checks

are never being called



Feel free to share a simpler algorithm proof if you think there's a bug.
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