Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Quantity on partial fill

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

    Order Quantity on partial fill

    Suppose I use the unmanaged approach to submit an order for say 5 futures contracts. When the order is accepted, I will get onOrderUpdate with that order for 5 contracts. Now suppose that this is a limit order and I get only a partial fill - say only 2 contracts get filled so 3 remain.

    Questions:
    In onOrderUpdate() i get the order passed in. Is order.Quantity always going to be 5 or will it now be == 3, ie the 3 remaining contrcats?

    What about OnExecutionUpdate? There i get passed an Execution object and I get the order from execution.Order. Does that order now have Quantity=5 or Quantity=3 (the 3 remaining).

    And if Quantity keeps going down, does that mean when the order is fully filled that Quantity will be 0 and filled will be 5?

    Please explain. Thanks.

    EDIT: My basic question is this: Suppose I have an original (unmanaged) Order for 5 contracts, and I also have a stop loss order to sell those 5 contracts if the market goes against me. Now suppose that in OnExecutionUpdate() I get notified that I have a partial fill for 2 contract out of the 5, so I want to change my stoploss order from the original 5 contracts down to the remaining 3 contracts. How do I specify the correct quantity in ChangeOrder(stopLossOrder)?
    Last edited by westofpluto; 09-28-2020, 11:19 AM.

    #2
    Hello westofpluto,

    Thanks for your post.

    Order.Quantity reflects the entire quantity of the order. Order.Filled reflects how many contacts of that order have filled.

    Execution.Order represents the order that is being executed.

    SampleOnOrderUpdate demonstrates how OnOrderUpdate and OnExecutionUpdate may be used to submit target/stop and this strategy also works well to handle partial fills.

    An unmanaged version of this strategy is attached.

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    To further observe these values, you can use Print()'s to see their output in the NinjaScript Output window.

    Note: This approach depends on Order/Execution events to follow: 1. OrderUpdate 2. ExecutionUpdate. When using Interactive Brokers or Rithmic based connections, the Order/Execution event ordering will be different and this sort of approach would not be reliable. We would suggest using OnOrderUpdate alone for those connection types.

    We look forward to assisting.
    Attached Files
    Last edited by NinjaTrader_Jim; 09-28-2020, 11:28 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      This helps but it doesn't really answer the question. Let me be very specific:

      What does execution.Order.Quantity represent for a partial fill? Is it the full quantity of the original order? (In my example, if the original order is 5 contracts then this is 5)? Or is this execution.Order.Quantity only the 2 contracts that have filled in a partial fill? Please answer directly rather than giving me code samples. Is this documented anywhere? Thanks.

      Comment


        #4
        What does execution.Order.Quantity represent for a partial fill? Is it the full quantity of the original order?
        Yes. Order.Quantity reflects the entire quantity of the order. If you have an order of 100 that gets a partial fill, Order.Quantity still shows the 100 when that order is executing.

        OnOrderUpdate and Order object can be referenced for what the properties mean. These documentation links are included in the SampleOnOrderUpdate link above. I have included them below for your convenience.

        https://ninjatrader.com/support/help...rderupdate.htm

        https://ninjatrader.com/support/help.../nt8/order.htm

        Testing prints in a working example like that given in post #2 can help to observe what you can expect these values to be.
        JimNinjaTrader Customer Service

        Comment


          #5
          The tricky part is this: execution.Order.Quantity is always the size of the original order, but (confusingly enough) execution.Quantity is the number of contracts that get filled in a partial fill (ie execution.Quantity is == execution.Order.filled)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by SuperDriveGuy, 10-23-2019, 07:13 AM
          23 responses
          1,346 views
          0 likes
          Last Post wadams
          by wadams
           
          Started by lmatiukas, Today, 07:09 PM
          1 response
          6 views
          0 likes
          Last Post lmatiukas  
          Started by ComfyCouch, Today, 06:04 PM
          0 responses
          13 views
          0 likes
          Last Post ComfyCouch  
          Started by Ousher, Today, 04:35 PM
          0 responses
          4 views
          0 likes
          Last Post Ousher
          by Ousher
           
          Started by Rugosoft, 11-17-2020, 08:22 AM
          3 responses
          38 views
          0 likes
          Last Post Shansen
          by Shansen
           
          Working...
          X