Announcement

Collapse
No announcement yet.

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

      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.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          58 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X