Back

Orderticket.value .stop .limit - I can't get any helpful value

Hey experts,

I'm starting off with Lean in C# and I'm stuck to receive the actual purchase price of my submitted orders.

I place my orders with a StopLimitOrder which works fine.

Every 10 minutes I dumb a log with all my open positions:

foreach (var v in Portfolio.Transactions.GetOpenOrders())
  {
  var orderTicket = Transactions.GetOrderTicket(v.Id);
  var price = orderTicket.AverageFillPrice;
  Log("Text: " + v);
  Log("order: " + v.Id + " " + price + v.Quantity + v.Status);
  }

This creates e.g. following log:

2017-01-03 03:00:00 :Text: OrderId: 1 Submitted StopLimit order for -47785 units of EURUSD at stop 1.04484 limit 1.04784

2017-01-03 03:00:00 :order: 1 0-47785Submitted

Where I just dumb v into the log I get stop and limit values

when I drill down into the fields the price is always 0, same as I I would use v.Value

v.Stop and v.Limit seems to be wrong as the build moans that this is not available for order type.

 

How can I manually extract the stop and limit value (and perhaps the actual purchase price)?

 

It's probably something simple/silly but whatever I try it results to 0 or invalid to build.

Update Backtest







Thanks for sending the log. The var price being 0 means that no fills have been processed by that log time entry. orderTicket.AverageFillPrice gets the average price for this ticket, but if no fills have been processed then this will return a value of 0. Once the ticket is filled, the AverageFillPrice will be properly calculated. For the case above, the OrderTicket OrderStatus can be used. This checks the full status of the order so a conditional statement could be used to inform when a trade has been submitted, partially filled, filled, and even cancelled. Please follow the link and click on OrderTicket (highlighted in red) to read more about the OrderTicket class members and OrderStatus (also highlighted in red) to read more about the OrderStatus class members. And when determining the stop and limit prices of a StopLimitOrder, the commands StopLimitOrder.StopPrice can be used to determine the specific StopPrice and StopLimitOrder.LimitPrice can be used to determine the specific LimitPrice. It is important to note that during the log the orderTicket was never filled so purchase prices can’t be provided yet.

https://www.quantconnect.com/docs/algorithm-reference/trading-and-orders
0

Thanks, I tried a little try and error and realized my stopmarketorder is not defined right therefore not filing. With above description it now makes more sense and I#m back to properly define my order :)

0

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