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 mmckinnm, Today, 01:34 PM
          0 responses
          1 view
          0 likes
          Last Post mmckinnm  
          Started by f.saeidi, Today, 01:32 PM
          0 responses
          1 view
          0 likes
          Last Post f.saeidi  
          Started by traderqz, Today, 12:06 AM
          9 responses
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          117 responses
          2,766 views
          1 like
          Last Post jculp
          by jculp
           
          Started by Mongo, Today, 11:05 AM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X