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

Questions about exact set of order updates that occur on an order with partial fills

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

    Questions about exact set of order updates that occur on an order with partial fills

    In the interest of saving time, I figured I'd ask here before I set up a test example to determine the complete truth of things. None of the doc, the examples, or the forum posts I've seen yet quite seem to fully answer my question definitively, though it's certainly possible I am missing something.

    Let's pretend I submit a market order to buy 10 shares. This gets resolved with two partial fills, the 1st with a quantity of 7 and the 2nd with a quantity of 3. What order and execution updates do I get, and in what order?

    Is it:

    OnOrderUpdate PartFilled Q=7
    OnOrderUpdate PartFilled Q=3
    OnOrderUpdate Filled Q=10
    OnExecutionUpdate Q=10

    Or is it:

    OnOrderUpdate PartFilled Q=7
    OnOrderUpdate Filled Q=7
    OnExecutionUpdate Q=7

    OnOrderUpdate PartFilled Q=3
    OnOrderUpdate Filled Q=10
    OnExecutionUpdate Q=10

    Or is it something else?

    I have an AddOn so I am listening to OrderUpdate and ExecutionUpdate events on the Account object.

    Cheers.
    Last edited by carnitron; 11-01-2023, 09:13 PM.

    #2
    Hello carnitron,

    Thank you for your post.

    You will see an order update and execution update for each part fill (execution) in the order that the fills are occurring.

    From the Help Guide:

    "OnExecutionUpdate is typically called after OnOrderUpdate() is called" and "An order can generate multiple executions (partial fills)."

    OnExecutionUpdate() - https://ninjatrader.com/support/help...tionupdate.htm

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    Please let me know if you have any other questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      So what I'm hoping to achieve in this post is an exact picture of what happens in this case. I hope you can help me with that.

      From what I can gather from your reply, it sounds like maybe it's this?

      OnOrderUpdate PartFilled Q=7
      OnExecutionUpdate Q=7

      OnOrderUpdate PartFilled Q=3
      OnExecutionUpdate Q=3

      OnOrderUpdate Filled Q=10
      OnExecutionUpdate Q=10

      If that's not it, can you write out the exact sequence of events, along with the states and quantities as I've done here?

      If worse comes to worse, I'll just create an example and figure it out myself and then share the results here.

      Comment


        #4
        Hello,

        You might see something like:

        OnOrderUpdate PartFilled Q=7
        OnExecutionUpdate Q=7

        OnOrderUpdate Filled Q=10
        OnExecutionUpdate Q=3

        However, there is no guarantee to the sequence of these events.

        If you have any further questions, please let me know.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Ok, perfect, thank you for the help, this is exactly what I was looking for.

          When you say no guarantee as to the order of these events, though, the only real difference we might see is something like:

          OnOrderUpdate PartFilled Q=7
          OnOrderUpdate Filled Q=10

          OnExecutionUpdate Q=7
          OnExecutionUpdate Q=3

          Right? I've never seen an OnExecutionUpdate arrive before the OnOrderUpdate it belongs to. And I'm assuming these are queued on the server, so we'd also never see:

          OnExecutionUpdate Q=3
          OnExecutionUpdate Q=7

          in the above scenario.

          That said, these messages are traveling over the internet, so perhaps you are saying that b/c of that, individual events might take different paths through the internet, and therefore an event that launched later from the server could arrive before an event that launched earlier from the server, due to the vagaries of the internet?
          Last edited by carnitron; 11-03-2023, 11:20 AM.

          Comment


            #6
            Hello,

            Yes, you are correct with your first scenario. We can't guarantee when part fills will happen and if they happen, what quantity the partial fill will be. However, while typically OnExecutionUpdate will occur after OnOrderUpdate, this is not guaranteed.

            From the Help Guide:

            Rithmic and Interactive Brokers Users: When using a NinjaScript strategy it is best practice to only work with passed by value data from OnExecution. Instances of multiple fills at the same time for the same instrument might result in an incorrect OnPositionUpdate, as sequence of events are not guaranteed due to provider API design. For an example on protecting positions with this approach, see OnExecutionUpdate()

            OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm


            When using Rithmic or IB, OnExecutionUpdate() can occur before OnOrderUpdate().

            Please let me know if you have any other questions.
            Gaby V.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,403 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            94 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            6 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X