Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

8.0.3.1 - OnExecutionUpdate Called Multiple Times w/ OrderState.Filled

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hello,

    After further review it appears this is to be expected based on a few factors.

    The first item would be that there is a difference in the way the adapter for IB and how the simulation engine fundamentally work. Due to the multithreaded nature of the IB adapter this causes a difference when using specifically the object reference to the order in question. There is a note regarding this in the help guide orders page, not specifically about IB but in general in the "Multi-threaded consideration" topic: http://ninjatrader.com/support/helpG...sub=orderstate

    Specifically the following two notes play into this question:
    • For the most current order state, use the core "order" object property (e.g., order.OrderState, order.LimitPrice, order.StopPrice, etc)
    • For the sequence of order states, use the updating method parameter value (e.g., orderState, limitPrice, stopPrice, etc)

    This would be the second item, for this test we are using the Order object which is the most current state which could be updated to a state we are not necessarily expecting at the given time. Instead you would need to use the second option or the parameter values that are supplied to the overrides.

    To see the direct progression you could use OnOrderUpdate and use the passed in orderState to determine what the state of the change was.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #17
      Thanks for looking into this. How did you initially get around this problem? Were you using a single threaded machine/VM?

      Does this mean that to accomplish what I'm trying to do (reporting and updating of internal metrics ONLY once orders are completely filled), I'd have to move my logic out of OnExecutionUpdate, and use the updating method in OnOrderUpdate instead? So I'd have to filter for orderState == OrderState.Filled?

      Can you confirm that by doing this method I'd only see B/an email once per filled order as expected?

      EDIT: Alternatively, I believe I could keep what I have in OnExecutionUpdate but use a filter as follows?

      Code:
      			if (execution.Order.OrderState == OrderState.Filled &&
      				LastOrder != orderId)
      			{
      				LastOrder = orderId;
      				
      				Print ("B = " + execution.Order.ToString());
      				SendMail("[email protected]", "TEST", "B = " + execution.Order.ToString()); 
      			}
      Thanks again.
      Last edited by wuileng; 02-08-2017, 11:51 AM.

      Comment


        #18
        Hello wuileng,

        I had not got around this as this was the expected outcome. Based on the specific objects used in the sample we are just seeing the updated state of the object as each event is called.

        Using a filter would likely be the way to go in this case knowing that you need to filter the events. In the case you need to check current state of the order you would reference the actual order object, this will likely be filled as the events are happening in a multi threaded environment. Otherwise you would need to use the passed in values from the overrides to get a more clear picture on the order of the events as they transition and fill. The syntax you provided seems to filter the event, if this works in your tests accurately then this looks to be a solution.


        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kawalecld, Today, 12:21 PM
        0 responses
        2 views
        0 likes
        Last Post kawalecld  
        Started by exjayess, Today, 11:04 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by robertlaub, Today, 11:11 AM
        2 responses
        4 views
        0 likes
        Last Post robertlaub  
        Started by sdauteuil, Today, 10:28 AM
        0 responses
        6 views
        0 likes
        Last Post sdauteuil  
        Started by KirkHammett, Today, 08:11 AM
        0 responses
        7 views
        0 likes
        Last Post KirkHammett  
        Working...
        X