Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position quantity different from real quantity

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

    Position quantity different from real quantity

    Hi NT experts,

    I saw an issue that position quantity by OnPositionUpdate is different from real quantity.

    This morning i had 3 sell orders (0.05M each, total 0.15M) filled for USDCAD ~ 7:30AM. One of the orders following stop order was rejected by IB (explain later). My strategy exited position for that particular fill with market order, leaving total position as 0.10M.

    Then NT sent out close position and cancel strategy request based on its internal error handling logic. Up to this point so far so good.
    Then the OnPositionUpdate showed my remaining position as 0.06M, which was 0.04M fewer real remaining quantity.

    Following that, NT sent out close command with quantity 0.01M. So some part of NT's cancelling logic knew the real quantity. Up to this point, all my reaming position was bought back.

    Immediately following this close command, NT send out another close command with quantity 0.04M, leaving me a net long 0.04M on USDCAD. Obviously another part of NT found out my position was not 0.06M but 0.10M and tried to close it.

    Even so, I think NT should not have shut down my strategy without closing the long 0.04M position.

    Any idea what is going on?

    By the way, the issue with USDCAD is specific to IB which does not allow order submission at 5th deciaml but allows order fill at 5th decimal.

    #2
    binwang2, could you please contact me with your logs from today at our support email so I can review and respond? You can use the Help > Mail to Support feature to send those over.

    Thanks

    Comment


      #3
      binwang2,

      3/1/2010 7:30:03 AM|1|32|Order='107####35/U#######' Name='News_S1' New State=Cancelled Instrument='$USDCAD' Action=SellShort Limit price=1.0519 Stop price=1.052 Quantity=0.05M Type=StopLimit Filled=0 Fill price=0 Error=NoError Native error='Order Canceled - reason: (202)'

      This was in your logs at the beginning of the problems. Your order was rejected by the brokerage account. Everything afterwards is in response to trying to address this as everything falls out because of this cancellation.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        The order was cancelled because the price has been beyond the limit price by 5 pips. It is coded in the strategy.
        I think the problem started when the stop loss order was rejected by broker. The position for the rejected stop loss order was closed by the strategy. Then NT tried to close the whole strategy by closing the remaining 2 positions. IN the closing process, the close command was fired twice, closed more quantities than remaining position.

        Comment


          #5
          I think I have a better idea what is going on. I believe both broker and NT have issues.

          The overfilled 0.04M was due to IB partilly filling a rejected order. This order is the stop loss order for one of the 3 fills. Since IB does not allow USDCAD order submisssion at 5th decimal but allows order fills at 5th decimal, this particualr stop loss order, which calculates stop loss amount based on a filled price at 5th decimal, is put with a stop price at 0.0001. It does not show on IB side as rejected. On NT log, it says this order is rejected due to an invalid price. 2 seconds later after stop price is put at 0.0001, IB record says this stop order is partilly filled with 0.04M as quantity. One second after partil fill, it says the order is cancelled.

          I am querying into IB side on why such an order is filled.

          On NT side, i think the error handling logic should not shut down a strategy untill all live positions are closed. In this particular case, it does not.

          For your convenience, i recount order quantity here: 3 sell short orders filled, each with 0.05M, totally 0.15M. One order's stop loss order was rejected and strategy closed this particular position, leaving 0.10M. NT starts to close the trategy, buying back the remaining 0.10M. IB at the same time partilly filling the rejected stop loss order with 0.04M quantity. NT buys back the remaining 0.10M, closes the strategy. 0.04M net long position remains.

          Comment


            #6
            binwang2,

            Guessing, you likely ran into inflight executions. NT submitted its orders without knowledge of IB partially filling anything. By the time it came across it was too late.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X