Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order repriced -> Order rejected -> strategy disabled -> overfill error with IB

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

    Order repriced -> Order rejected -> strategy disabled -> overfill error with IB

    I started to experience the following sequence of errors recently with my strategies.
    I'm running NT7 (v35) with IB (TWS 960).

    1) when the strategy closes a position (either by reaching the condition to close, or closing at the end of the day), I get the following error:
    "Warning: your order was repriced so as not to cross a related resting order (399)"
    2) right after that, my strategy will issue an error saying my order was rejected and terminates:
    "Strategy X submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempting to close the position and terminated itself."
    3) Despite of the above error, the order is actually executed at IB and my position is in fact closed
    4) because my position is in fact closed, and the strategy is still trying to cancel to order, I receive a false overfill error in the last step.

    Related piece of info: I do have standing orders for the same instrument, but they are by no means would be crossing my current order. Those standing orders are profit target limit and stop loss order, much further away from the current price. I suspect this has something to do with the error, even though it shouldn't, the price differential is too large to be able to cross these orders.

    #2
    Hello mic414,

    Thanks for opening the thread and providing that detail.

    It looks like the strategy submitted an order to close a position and it broke IB's rules which then resulted in a native error where they repriced your order, and then caused NinjaTrader to take its Realtime Error Handling action.

    As the order submission error resulted from one order interfering with the other, a solution will have to come from modifying the way you exit a position (considering any active orders you have) or to handle the error if/when it is received. If there is any confusion with the state of your position and any active orders when the error occurred, we could take a look at your log and trace files to provide further input. If that is the case, Please write into platformsupport [at] ninjatrader [dot] com with your log and trace files so we may better analyze what had happened. Please include the text "Attention Jim" and the thread URL.

    You can add logic to handle order rejections and overfills by setting the RealtimeErrorHandling property and the IgnoreOverFill property. You will need to use the OnOrderUpdate() method to identify these occurrences and then to take action.

    RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm

    IgnoreOverFill - https://ninjatrader.com/support/help...reoverfill.htm

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      All my overfill errors are 100% false positive.

      Hello:

      I use NT7 with IB. I have the following codes in my strategy and I still have false positive overfill errors about 10 times over the past two years, from FESX, FGBL to 6E. It is very discouraging. Is it a known bug, Jim? What else can I do?



      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
      SetProfitTarget(CalculationMode.Ticks, Profit);
      SetStopLoss(CalculationMode.Ticks, Stop);
      IgnoreOverFill = true;
      }


      Thanks!

      Comment


        #4
        Hello reubenlasky,

        Thanks for your reply.

        OverFills occur after an order gets returned as Filled or PartFilled from your broker after it has been marked for cancellation. This could be an issue with OCO orders if you are using the Unmanged Approach or an issue where an order was marked for cancellation by CancelOrder() and the position was already closed.

        The issue with over fills surrounds order of events that are controlled by the strategies logic. The events can be managed appropriately in your strategy if you use the properties mentioned above. You will have to look for PartFilled or Filled events in OnOrderUpdate() which occur after an order has been canceled.

        I would suggest to fully analyze the order of events that occurred when you received your overfill so you can appropriately handle the situation in your strategy.

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

        Please let me know if I may be of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello reubenlasky,

          Thanks for your reply.

          OverFills occur after an order gets returned as Filled or PartFilled from your broker after it has been marked for cancellation. This could be an issue with OCO orders if you are using the Unmanged Approach or an issue where an order was marked for cancellation by CancelOrder() and the position was already closed.

          The issue with over fills surrounds order of events that are controlled by the strategies logic. The events can be managed appropriately in your strategy if you use the properties mentioned above. You will have to look for PartFilled or Filled events in OnOrderUpdate() which occur after an order has been canceled.

          I would suggest to fully analyze the order of events that occurred when you received your overfill so you can appropriately handle the situation in your strategy.

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

          Please let me know if I may be of further assistance.
          Hi Jim:

          I looked up the Ninjatrader online manual and found out that my strategy qualified to be run 'unmanaged'. So I do need to declare it as "unmanaged = true", am I right? Just adding an extra line of code in addition to the ones I had shown in my previous post? Thanks!

          Comment


            #6
            Hello reubenlasky,

            Thanks for your reply.

            IgnoreOverFill requires the Unmanaged approach while RealtimeErrorHandling does not.

            If you would like to convert your strategy to use the Unmanages Approach, yes you would set Unmanaged = true; in Initialize(), and then you would convert any Manged Approach Order methods to SubmitOrder() methods.

            Those Order methods can be referenced in the help guide as well. I will provide some links for quick reference:

            Managed - https://ninjatrader.com/support/help...d_approach.htm

            UnManaged - https://ninjatrader.com/support/help...d_approach.htm
            JimNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jim View Post
              Hello reubenlasky,

              Thanks for your reply.

              IgnoreOverFill requires the Unmanaged approach while RealtimeErrorHandling does not.

              If you would like to convert your strategy to use the Unmanages Approach, yes you would set Unmanaged = true; in Initialize(), and then you would convert any Manged Approach Order methods to SubmitOrder() methods.

              Those Order methods can be referenced in the help guide as well. I will provide some links for quick reference:

              Managed - https://ninjatrader.com/support/help...d_approach.htm

              UnManaged - https://ninjatrader.com/support/help...d_approach.htm
              Thanks Jim. So I added an extra line of code --

              protected override void Initialize()
              {
              Unmanaged = true;
              CalculateOnBarClose = true;
              RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
              SetProfitTarget(CalculationMode.Ticks, Profit);
              SetStopLoss(CalculationMode.Ticks, Stop);
              IgnoreOverFill = true;
              }

              Is that correct, for an unmanaged strategy?

              Comment


                #8
                Hello reubenlasky,

                Thank you for your response.

                Unmanaged strategies do require you to set 'Unmanaged = true;' yes, but you also need to implement the Unmanaged order methods and in general this is reserved for advanced programmers.

                Please review the details on Unmanaged at the following link: http://ninjatrader.com/support/helpG...d_approach.htm

                Please let me know if you have any questions.

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello reubenlasky,

                  Thank you for your response.

                  Unmanaged strategies do require you to set 'Unmanaged = true;' yes, but you also need to implement the Unmanaged order methods and in general this is reserved for advanced programmers.

                  Please review the details on Unmanaged at the following link: http://ninjatrader.com/support/helpG...d_approach.htm

                  Please let me know if you have any questions.
                  Thanks Patrick, I am no expert. But I have to do something, I trade 6-7 markets with IB TWS, and the overfill happens 2-4 times a week, all false-positive. It is frustrating, when you think of the loss of opportunities in the markets.

                  Comment


                    #10
                    Hello reubenlasky,

                    Thank you for your response.

                    Please send me your log and trace files so that I may look into what occurred.

                    You can do this by going to the Control Center-> Help-> Mail to Platform Support.

                    Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                    Please list 'ATTN: Patrick H' in the subject line and reference this thread in the body of the email.

                    I look forward to assisting you further.

                    Comment


                      #11
                      Originally posted by NinjaTrader_PatrickH View Post
                      Hello reubenlasky,

                      Thank you for your response.

                      Please send me your log and trace files so that I may look into what occurred.

                      You can do this by going to the Control Center-> Help-> Mail to Platform Support.

                      Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                      Please list 'ATTN: Patrick H' in the subject line and reference this thread in the body of the email.

                      I look forward to assisting you further.
                      OK, will do. There was one today, in TF. Let me do it after work. Thanks, PartrickH.

                      Comment


                        #12
                        Hello reubenlasky,

                        Thank you for your patience.

                        We did not receive your log and trace files. Please follow the steps below to manually attach your log and trace files to your email so I may investigate this matter further.
                        • Open your NinjaTrader folder under Documents.
                        • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
                        • Send the 2 compressed folders as attachments to this email.
                        • Once complete, you can delete these compressed folders.

                        Please send the files to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H' in the subject line and a reference to this thread in the body of the email.

                        I look forward to your response.

                        Comment


                          #13
                          Hello reubenlasky,

                          Thank you for your patience.

                          From your Log we can see the orders attempted to cancel at the same time that it filled. This in turn generated the over fill as the order should not have filled based on the strategy logic. If you would like we can look into the strategy on our end.

                          I will follow up with you on your email as well.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by gemify, 11-11-2022, 11:52 AM
                          6 responses
                          803 views
                          2 likes
                          Last Post ultls
                          by ultls
                           
                          Started by ScottWalsh, Today, 04:52 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post ScottWalsh  
                          Started by ScottWalsh, Today, 04:29 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post ScottWalsh  
                          Started by rtwave, 04-12-2024, 09:30 AM
                          2 responses
                          22 views
                          0 likes
                          Last Post rtwave
                          by rtwave
                           
                          Started by tsantospinto, 04-12-2024, 07:04 PM
                          5 responses
                          70 views
                          0 likes
                          Last Post tsantospinto  
                          Working...
                          X