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

OnOrderUpdate bug with Unmanaged on IB

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

    OnOrderUpdate bug with Unmanaged on IB

    When using Unmanaged code when connected to IB:
    OnOrderUpdate gets called twice for each order status update, even though the iOrder object is exactly the same on the second (duplicated) call.

    The iOrder object has the same values in the duplicated call, according to order.ToString().

    This problem does not not occur when connected to Sim, or if using Managed code.

    This is using NT v7...16

    #2
    Dave,

    Is this a live account with IB or a Paper Account?

    Can you share the OnOrderUpdate() code that you have programmed?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Testing on paper trading account.


      Code:
      		protected override void OnOrderUpdate(IOrder order)
      		{
          		if (entryOrder != null && entryOrder == order)
          		{
      				if (dBug)
      				{
      					Print(string.Format("OnOrderUpdate: entryOrder.OrderState={0}, {1}",order.OrderState, DateTime.Now));
      					Print(order.ToString());
      				}
      				
      			}
      		}
      Using Unmanaged:
      SubmitOrder .. to set up a limit order causes:
      PendingSubmit
      PendingSubmit
      Accepted
      Accepted
      Working
      Working

      then using CancelOrder(entryOrder) causes:
      PendingCancel
      PendingCancel
      Cancelled
      Cancelled

      But using Managed:
      equivalent EnterLongLimit(,,,) causes:
      PendingSubmit
      Accepted
      Working

      (as expected)

      then using CancelOrder(entryOrder) causes:
      PendingCancel
      Cancelled

      (as expected)

      Comment


        #4
        Dave,

        With the IB Paper account, it is expected to have random or obscure Order Updates, such as the double print you have.

        The OnOrderUpdate is being called when the API sends an order update to NT, in this case from the Paper account with IB.

        It is a known issue with the IB Paper accounts and expected behavior.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Cal,

          This is not an acceptable response.
          You are trying to blame the IB paper account as being 'random', just like you did on a previous thread when I tried to report inability to recover Position after reconnection.

          However there is nothing random about either behaviour.
          Below I have shown that Managed works correctly for CancelOrder, but Unmanaged does not (both on exactly the same IB account).
          On the previous thread I showed that Managed correctly calls OnPositionUpdate after reconnect (so Position gets updated if position changed at broker during disconection), whereas this does not happen when Unmanaged (leaving Position incorrect).

          In both cases there is a repeatable (not random) problem with UnManaged, whereas Managed has a repeatable (not random) success. Please report both these problems as bugs to development.

          Comment


            #6
            Dave,

            I have tested this out on my end with the demo account, as well as a live account and was not able to reproduce this.

            The IB Paper account will update differently versus the Sim or Live accounts, this is known and matches prior experiences and customer feedback on those differences as well. These order states are not something that is thrown by NinjaTrader but rather received from the brokerage API.

            You provided print statements of the double printing however, I would like you to test this with adding DateTime.Now to the second Print for order.ToSring() to see if these are printed at the same time or different times.

            Here is the script that I ran -
            Code:
             protected override void OnBarUpdate()
                    {
            			if(Historical)
            				return;
            			
            			if(myEntry == null && Position.MarketPosition == MarketPosition.Flat)
            			{
            				myEntry = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, 10.00, 0, "", "Long");	
            			}
                    }
            		
            		protected override void OnOrderUpdate(IOrder order)
            		{
            			if(myEntry != null && myEntry == order)
            			{
            				Print(string.Format("OnOrderUpdate: myEntry.OrderState={0},{1}", order.OrderState, DateTime.Now));
            				Print(order.ToString());
            				Print(" ");
            				if(myEntry != null && order.OrderState == OrderState.Filled)
            				{
            					myEntry = null;
            				}
            			}
            		}
            Last edited by NinjaTrader_CalH; 11-22-2013, 11:55 AM.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Cal,
              Once again you seem to be ignoring that the difference I am talking about is between Managed vs Unmanaged on the same account (not one type of account against another).

              When setting up the Limit order, using Unmanaged, the duplicate OnOrderUpdate() usually have the same apparent time. Examples:
              OnOrderUpdate: entryOrder.OrderState=PendingSubmit, 22 Nov 2013 19:18:01:0000000
              OnOrderUpdate: entryOrder.OrderState=PendingSubmit, 22 Nov 2013 19:18:01:0000000

              Once again these duplicates do not occur when using Managed on the same account. If the IB paper account is really sending duplicate events then how do you explain the fact that the duplicates do not show up when using Managed?

              Comment


                #8
                DaveE,

                My script attached in my previous post shows that I did test this out with the Unmanaged code in both with the Paper account and Live account. I was not able to reproduce this with either account. meaning that this is an isolated case.

                You will need to attach your script or send me an email to support[at]ninjatrader[dot]com so I can test this with your code.

                Additionally, we cannot support any test with the IB Paper Account. If there is an issue it needs to manifest to the Sim101 or with a live account.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Cal View Post
                  DaveE,
                  Additionally, we cannot support any test with the IB Paper Account.
                  This was not the policy when I paid for a licence for NT with IB.
                  I would not have paid for a licence if I had known this.
                  I am unable to backtest my strategy since it relies on information from other strategies.
                  I am unable to test on IB Paper trade account since you are not providing support.
                  If this is really NTs new policy then I will be considering ditching NT and asking for my money back.

                  Comment


                    #10
                    Hi Dave,

                    Our policy on the IB Paper environment has not changed and I can confirm the information provided by NinjaTrader_Cal.

                    These accounts have severe limitations which prevent us from moving forward with any bug reports in this regard. The reason for this is that the sequence of API events such as Order, Executions and Positions are not guaranteed and this has always been the case.

                    You are free to use these accounts for your testing purposes, however as a result of these limitations, it is not guaranteed to work the same as we have designed for a live account.

                    For local simulation testing for your purposes, we'd encourage you to use the Sim101 account.

                    Thanks for your understanding.
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      Not a bug

                      I see in IBs API docs
                      they say
                      Note: It is possible that orderStatus() may return duplicate messages. It is essential that you filter the message accordingly.
                      So I assume that in Managed mode NT is filtering out subsequent orderStatus() duplicates (so they dont raise OnOrderUpdate), whereas in Unmanaged mode NT is not doing this filtering.
                      Assuming this I can simply do my own filtering.
                      But It would be good if when someone asks a question regarding Unmanaged behaviour, that NT support could address the real differences between Unmanaged and Managed (instead of just focusing on Paper Account issues). In this particular case the difference seems to be exactly the same regardless of whether Live or Paper account. All Cal needed to say was "you need to do your own filtering of duplicate OnOrderUpdate if using Unmanaged on IB"

                      I was told by NT that I needed to pay for a licence in order to use IB Paper Trading. I was not told this would not be supported. Since I was not told I reserve my case in this matter.

                      Indeed if the IB Paper trading environment is as bad as you imply, should you really be charging people a lot of money to get access to it?

                      Comment


                        #12
                        Hi DaveE,

                        The live license gives you access to both paper and your live account and there is no cost difference between these. We would rather not further complicate our license model by providing different tiers of live/paper license keys. If you wish to submit orders to an external order, a live key is required.

                        It should be understood that a paper environment will never give you the same results as a live environment. With that said, you're free to have your live license key switched over to any other brokerage paper account should these limits of the paper environment be unacceptable for your testing.

                        In our testing, there is no difference between the order calls seen on the unmanaged or managed. There is no additional filtering being done on the adapter level between strategy modes.

                        We've spent considerable time testing the Paper vs Live accounts in IB and the behavior you are reporting and cannot duplicate at this time. This in our experience can be attributed to the randomness of the IB paper accounts and we cannot resolve this behavior. If you ever see this behavior on the live account with unmanaged or managed strategies, please let us know and we'll be more than happy to look into such a report.
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          Originally posted by DaveE View Post
                          I see in IBs API docs
                          they say
                          So I assume that in Managed mode NT is filtering out subsequent orderStatus() duplicates (so they dont raise OnOrderUpdate), whereas in Unmanaged mode NT is not doing this filtering.
                          Assuming this I can simply do my own filtering.
                          But It would be good if when someone asks a question regarding Unmanaged behaviour, that NT support could address the real differences between Unmanaged and Managed (instead of just focusing on Paper Account issues). In this particular case the difference seems to be exactly the same regardless of whether Live or Paper account. All Cal needed to say was "you need to do your own filtering of duplicate OnOrderUpdate if using Unmanaged on IB"

                          I was told by NT that I needed to pay for a licence in order to use IB Paper Trading. I was not told this would not be supported. Since I was not told I reserve my case in this matter.

                          Indeed if the IB Paper trading environment is as bad as you imply, should you really be charging people a lot of money to get access to it?
                          I've been experimenting similar issues, in my case under a "live NT simulation" ( not even the IB paper account ) . I'm trying to figure this out through doing due forensics in log and trace files
                          Last edited by pstrusi; 06-27-2017, 08:43 AM.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by TraderBCL, Today, 04:38 AM
                          2 responses
                          17 views
                          0 likes
                          Last Post TraderBCL  
                          Started by martin70, 03-24-2023, 04:58 AM
                          14 responses
                          106 views
                          0 likes
                          Last Post martin70  
                          Started by Radano, 06-10-2021, 01:40 AM
                          19 responses
                          609 views
                          0 likes
                          Last Post Radano
                          by Radano
                           
                          Started by KenneGaray, Today, 03:48 AM
                          0 responses
                          5 views
                          0 likes
                          Last Post KenneGaray  
                          Started by thanajo, 05-04-2021, 02:11 AM
                          4 responses
                          471 views
                          0 likes
                          Last Post tradingnasdaqprueba  
                          Working...
                          X