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

Quantity of PartFilled and Filled Orders

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

    Quantity of PartFilled and Filled Orders

    Sirs,

    Let's presume that I go long 4 contracts and that the order gets filled in two phases (e.g. first 3 and then 1).

    In OnOrderUpdate(), I would expect the Quantity to be first 3 (OrderState == OrderState.PartFilled), right? But when the order gets competely filled (OrderState == OrderState.Filled), should the Quantity be 1 or 4?

    JP

    #2
    Hello,

    I don't completely understand your question. OrderState.[etc...] represents a state not a quantity.
    DenNinjaTrader Customer Service

    Comment


      #3
      IOrder.Quantity, when OrderState == 1) PartFilled 2) Filled.

      Comment


        #4
        Hello,

        From this link:


        It says that IOrder's properties will be dynamic when returned from an order method and static when passed from OnOrderUpdate().

        Since you are looking at it in OnOrderUpdate, it will NOT refect changes inside this method and should not be stored for comparison in other methods if you take it from OnOrderUpdate.

        So, generally yes, they should update, but not in some case as mentioned in the link and above. Does that make sense?
        DenNinjaTrader Customer Service

        Comment


          #5
          Hmmm- not really, perhaps because of my limited undertanding of the system

          Let's take a concrete example: I place the following order inside OnBarUpdate():

          entryOrder = EnterLong(0, 4, "ENTER_LONG");

          i.e. my intention is to go 4 contracts long. Let's then presume that I'll get a series of partial fills: first one contract, then another one, and finally the remaing two.

          In such a case, I think, the OnOrderUpdate() method should get called several times during the execution of my entryOrder, whenever its state changes. Now my assumption regarding the behaviour of IOrder.Quantity is the following:

          OrderState == OrderState.PartFilled
          Quantity == 1

          OrderState == OrderState.PartFilled
          Quantity == 2

          OrderState == OrderState.Filled
          Quantity == 4


          In other words, does IOrder.Quantity contain the cumulative number of contracts bought or sold within the context of the order being processed (in this case: Token == entryOrder.Token), or does it indicate the number of contracts bought or sold as a result of the latest fill (ie. if this was the case, the value of Quantity in the example above would have been 1, 1, and 2), or does it remain constant (i.e. in this example 4). Does this clarify my question?

          JP
          Last edited by jp_kettunen; 12-27-2009, 08:44 AM. Reason: Typo, and the development of my understanding during the writing process!

          Comment


            #6
            Hello,

            I will have someone reply to you on Monday. Thank you for your patience.
            DenNinjaTrader Customer Service

            Comment


              #7
              Thanks,

              I am trying to count contracts (not trades), and want to be aware of partial fills in case the order never gets completely filled. Just occured to me that perhaps I should use OnExecution() instead of OnOrderUpdate(): how would IExecution.Quantity behave in my example (Order qty 4, partial fills 1, 1 and 2)?!

              Comment


                #8
                JP, IExecution.Quantity is probably the way to go. In your example, OnExecution() would be called 3 different times, with one for the quantity for the first two times and two for the quantity for the last call.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Will proceed with IExecution.Quantity, but also keep tracking IOrder.Quantity for comparison... Thanks again.
                  JP

                  Comment


                    #10
                    Empirical data: At least with Zen-Fire IExecution.Quantity holds the quantity of the latest fill (i.e. if partial, then the number of contracts actually bought / sold), while IOrder.Quantity seems to remain constant thru the entire execution process, irrespective of the order status (PartFilled, Filled).

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by dmking, 11-12-2019, 12:31 PM
                    4 responses
                    4,139 views
                    0 likes
                    Last Post jasonw
                    by jasonw
                     
                    Started by roblogic, Today, 04:31 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post roblogic  
                    Started by morrnel, 05-12-2024, 06:07 PM
                    4 responses
                    52 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by xepher101, 05-10-2024, 12:19 PM
                    6 responses
                    69 views
                    0 likes
                    Last Post xepher101  
                    Started by gbourque, Today, 04:11 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post gbourque  
                    Working...
                    X