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

Partfilled vs Filled

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

    Partfilled vs Filled

    I would be most grateful for clarification of the correct way to handle partial order fills (Order.OrderState == OrderState.PartFilled) and order fills (Order.OrderState == OrderState.Filled) for the same submitted order to ensure an accurate fill count (using Order.Quantity) and average fill price (using Order.AvgFillPrice) across multiple partial fills. This is using a Managed order approach.

    Here is my understanding of the situation -- please correct me where I am in error:
    • The PartFilled Quantity is the quantity of that partial fill only, not the accumulated quantity of all partial fills to date
    • The Filled Quantity is either:
      • The full quantity of the original submitted order if there are no partial fills, or
      • The remainder of the submitted quantity after all partial fill quantities have been accumulated

    • To determine when a submitted order has been completely filled, the fill update and any partial fill updates must all be used
    • To accurately calculate the quantity when there is one or more partial fills, sum the quantities of every partial fill and the final fill
    • To accurately calculate the average fill price when there is one or more partial fills, pro rata the average fill price of each fill to obtain a final average fill price
    • The way partial fills and fills work is identical for all order types (i.e. the same for Enter and Exit orders for Market, Limit, Stop and StopLimit, as well as Trailing Stop and Profit Target)
    • When handling partial fills and fills in OnOrderUpdate, sometimes a fill update may arrive before a partial fill update -- one must compare the submitted quantity against the fill update quantity to determine if partial fill updates may follow.

    Here are some examples of calculating quantities and average fill price:
    • Fill only (no partial fills)
      • Enter Quantity = 100
      • Fill, Quantity = 100 @ 1.12 avg fill price

    • PartFill + Fill
      • Enter Quantity = 100
      • Partial fill, Quantity = 20 @ 1.00 avg fill price
      • Fill Quantity = 80 @ 1.20 avg fill price
      • Total Quantity = 20 + 80 = 100
      • Average fill price = ((20 x 1.00) + (80 x 1.20)) / 100 = 1.16

    • PartFills + Fill
      • Enter Quantity = 100
      • First partial fill, Quantity = 20 @ 1.00 avg fill price
      • Second partial fill, Quantity = 20 @ 1.10 avg fill price
      • Fill Quantity = 60 @ 1.20 avg fill price
      • Total Quantity = 20 + 20 + 60 = 100
      • Average fill price = ((20 x 1.00) + (20 x 1.10) + (60 x 1.20)) / 100 = 1.14


    Many thanks for advice to correct any misunderstandings I may have.
    Last edited by jeronymite; 05-17-2014, 05:58 AM. Reason: Update to say it's a Managed approach
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Jeronymite,

    an accurate fill count (using Order.Quantity)
    Order.Quantity will return the order's quantity. Instead you would want to use Order.Filled This will represent the filled amount of the order

    To determine when a submitted order has been completely filled, the fill update and any partial fill updates must all be used
    The OrderState.Filled will get called in a complete fill of the order. You would not need to use the PartFill for this.

    The rest would be an accurate assessment.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Order.Filled is all you really need?

      Many thanks, Cal.

      The Order.Quantity was a typo on my part -- Order.Filled is obviously what is needed.

      As for the use of Order.Filled, I presume that one does not need to explicitly handle partial fills (unless one wants to for some reason), and one can simply wait for the Order.Filled and it will contain an accurate count equal to the submitted Quantity and an accurate average fill price, equal to the appropriately pro rata'ed individual fills if partial fills occur. Is that correct?

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello Jeronymite,

        Your understanding is correct here. The Filled will return when the order has been completely filled and you will get the Avg price of that orders' entries.

        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sgordet, Today, 05:24 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Board game geek, Today, 02:20 AM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by ZeroKuhl, Yesterday, 04:31 PM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by knighty6508, Today, 01:20 AM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by cupir2, Yesterday, 07:44 PM
        2 responses
        21 views
        0 likes
        Last Post cupir2
        by cupir2
         
        Working...
        X