Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Question regarding OnExecution Update

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

    Question regarding OnExecution Update

    Hi,
    I came across some issues with the IB Connection and I can see that IB is having a "creative" way of sending order updates. I have a question regarding your sentence in your online help.
    In your help is written for OnExecutionUpdate:

    "Rithmic and Interactive Brokers Users: Due to provider API design these adapters do not guarantee the sequence of events of OnOrderUpdate, OnExecution, and OnPositionUpdate. Therefore, when working on a strategy that will run on these connections it is best practice to only work with passed by value data from that callback to eliminate the dependency on the sequence of events."

    Am I understanding this correct, that when I use passed by value data that the sequence of events (OnOrderUpdate, OnExecution, OnPositionUpdate) is guaranteed?

    I am sorry if this is a stupid question. I just want to make 100% sure that I understand this correct, as this is crucial for my strategy.
    Thanks,
    Klaus

    #2
    Originally posted by klaus w View Post
    Hi,
    I came across some issues with the IB Connection and I can see that IB is having a "creative" way of sending order updates. I have a question regarding your sentence in your online help.
    In your help is written for OnExecutionUpdate:

    "Rithmic and Interactive Brokers Users: Due to provider API design these adapters do not guarantee the sequence of events of OnOrderUpdate, OnExecution, and OnPositionUpdate. Therefore, when working on a strategy that will run on these connections it is best practice to only work with passed by value data from that callback to eliminate the dependency on the sequence of events."

    Am I understanding this correct, that when I use passed by value data that the sequence of events (OnOrderUpdate, OnExecution, OnPositionUpdate) is guaranteed?

    I am sorry if this is a stupid question. I just want to make 100% sure that I understand this correct, as this is crucial for my strategy.
    Thanks,
    Klaus
    No, your logic is incorrect. Don't say it that way.

    For IB and Rithmic, the sequence is not guaranteed, there is no way to change that.
    Period. Full stop. End of story.

    Ok, now what about that "passed by value" data comment?

    What they're saying is: you can better insulate your code from caring about this
    lack of guaranteed order if you use the pass by value data from the callback.

    Comment


      #3
      Hello klaus w,

      Thanks for your post.

      bltdavid's insight is correct. The order of Order, Execution, Position events are not guaranteed with Interactive Brokers or Rithmic, so strategies should be written to used the passed by parameter values in each method rather than [for example] using information that is updated in OnOrderUpdate within OnExecutionUpdate.

      Our SampleOnOrderUpdate strategy is written to use information from Orders (referenced from execution.Order, but still depending on Order information to be updated before OnExecutionUpdate) and this framework could exhibit issues with partial fills because it depends on the Order information to be updated before the Execution.

      You can compare the implementation in SampleOnOrderUpdate to the new example strategies that we have attached here. The examples use private variables and information from the Execution in OnExecutionUpdate to get average entry prices per entry, so it does not depend on OrderUpdates to come first.

      SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm
      Attached Files
      JimNinjaTrader Customer Service

      Comment


        #4
        Thanks Jim,
        I was checking your samples before and did program my strategy to only be depended on ONORDERUPDATE event. I also did develop my own position object, execution event, etc.
        I was just wondering if I did misunderstand the explanation in the help as I do not speak English as native language.
        Thanks for your help and the additional samples!
        Klaus

        Comment


          #5
          Hello Klaus,

          My UnmanagedOnOrderUpdateOnly example is a path forward, but is more difficult than taking the approaches shared in post #3.

          Using OnOrderUpdate only means that the strategy Position object would also need to be calculated on your own from order updates, and Unmanaged must be used because the Managed Approach is tied to the internal Position object, which is updated from Execution events.

          The examples posted here allow using the Managed Approach and still allow using the internal strategy Position object, because they depend on Execution events exclusively for target/stop submission. OnOrderUpdate is then just used for Order object handling.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fafafdenis, Today, 04:56 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_EricB  
          Started by pjsmith, 07-18-2019, 04:21 AM
          7 responses
          249 views
          0 likes
          Last Post aligator  
          Started by ark321, Today, 05:12 PM
          0 responses
          11 views
          0 likes
          Last Post ark321
          by ark321
           
          Started by futurenow, Today, 04:49 PM
          0 responses
          9 views
          0 likes
          Last Post futurenow  
          Started by ofer1964spivak, Today, 04:27 PM
          0 responses
          5 views
          0 likes
          Last Post ofer1964spivak  
          Working...
          X