Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order submission issues on partial fills via InteractiveBrokers

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

    Order submission issues on partial fills via InteractiveBrokers

    Hi,

    I am running an automated strategy, trading Nasdaq stocks intraday. On entry, the strategy submits both a stop loss and a profit target limit order.

    The problem: The strategy often terminates itself. On execution of the stop-loss order, Ninja runs into some problem with managing the orders (Error message: "Can't modify a filled order" or "Order not in cancellable status", see NT log below). What's worse, on termination, Ninja submits a "Close" order for what it thinks is still an active long position (which by then is closed!), thus opening an irregular short position.

    How can I prevent this from happening?

    Many thanks
    Martin

    Log output:
    ------------------
    6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=Working Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:18 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PartFilled Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''

    6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=350 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=200 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=100 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=0 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Accepted Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

    6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Rejected Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=OrderRejected Native error='Can't modify a filled order" (104)'

    6/12/2008 8:43:19 PM|0|32|Can't modify a filled order" (104) Affected Order: Sell 350 Limit @ 25.76

    6/12/2008 8:43:19 PM|0|128|Strategy 'xxxxx' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

    6/12/2008 8:43:19
    PM|1|32|Order='797f914ceb764ff8b0ac0ae378698df7/U123456' Name='Close' New State=PendingSubmit Instrument='YHOO' Action=Sell Limit price=0 Stop price=0 Quantity=350 Type=Market Filled=0 Fill price=0 Error=NoError Native error='' [THIS CAUSES AN IRREGULAR SHORT RIGHT HERE]

    #2
    You should use the IOrder objects. You need to be wary of problems when filling orders and you need to code in error handling when orders get rejected and such. Please see the reference sample section for a sample on how to use OnOrderUpdate().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I get similar problems with very, very basic strategy. Enter on market order, use SetStopLoss and SetProfitTarget, which NT submits to IB as an OCO order.

      When one leg is triggered at IB, NT then attempts to cancel the other leg, but IB has already cancelled the other leg because it was an OCO hence NT logs a rejection message and shuts down the strategy.

      Very very basic. Surely you don't expect traders to delve into complex order handling to handle such a bread and butter situation?

      Logs and traces available if needed, however they're the same as previous posters.

      Peter

      Comment


        #4
        Peter, can you please review your IB account connection setup and make sure 'Local OCO simulation' is unchecked? Also please ensure you're on the recommended 897.2 release if TWS per this guide - http://www.ninjatrader.com/webnew/su...ivebrokers.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Peter, can you please review your IB account connection setup and make sure 'Local OCO simulation' is unchecked? Also please ensure you're on the recommended 897.2 release if TWS per this guide - http://www.ninjatrader.com/webnew/su...ivebrokers.htm
          Bertrand, Local OCO Simulation is unchecked, and I can confirm that the TWS screen shows that the orders are at IB with OCO set. Please re-confirm correct versions of software. Your post says 897.2 but your web page says 892. I am actually running 893.

          Thanks
          Peter

          Comment


            #6
            Thanks for the reply Peter, we recommend using 892.7 which is the installation file listed in our IB connection guide. Also, please ensure you're on NinjaTrader 6.5.1000.11 (if not the upgrade can be loaded by going to Help > Download Site in the Control Center).
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Thanks for the reply Peter, we recommend using 892.7 which is the installation file listed in our IB connection guide. Also, please ensure you're on NinjaTrader 6.5.1000.11 (if not the upgrade can be loaded by going to Help > Download Site in the Control Center).
              I installed 892.7 and 6.5.1000.11 and still get "Cancel attempted when order is not in a cancellable state" more often than not. Occasionally, it seems that NT is fast enough to send the cancellation to IB before IB has had a chance to cancel the other OCO leg, but this seems to happen rarely. Logs and trace available if needed.



              Peter

              Comment


                #8
                Hello,

                If this happens again please send us your logs and traces from help>mail to support and reference this thread link.

                This may be in-flight execution:
                DenNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Ben View Post
                  Hello,

                  If this happens again please send us your logs and traces from help>mail to support and reference this thread link.

                  This may be in-flight execution:
                  http://www.ninjatrader-support.com/H...njaTrader.html
                  I've sent the log and trace files just now. Problem seems to be happening fairly regularly but not on every trade exit. The trade hits its stop loss, then NT attempts to cancel the OCO Take Profit order at the IB server and receives a reject error because IB has already closed the Profit Target order. Perhaps because I'm in Australia, there will be hundred's of milliseconds delay between here and IB servers, so IB will have had plenty of time to close the Profit Target OCO order and have a completely clean slate before the NT order cancellation arrives at the IB server.

                  Peter

                  Comment


                    #10
                    Peter, which 'OrderHandling' setting are you using with the strategies? http://www.ninjatrader-support.com/H...tegiesTab.html
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      Peter, which 'OrderHandling' setting are you using with the strategies? http://www.ninjatrader-support.com/H...tegiesTab.html
                      Wait until flat before executing live is: Checked
                      Stop & Target submission is: By strategy position
                      Cancel strategy orders on strategy termination is: Unchecked

                      Note in the logs that I have sent you I'm not getting partial fills so I'm not sure how this is relevant. Please clarify.

                      Peter

                      Comment


                        #12
                        Thanks for sending those in Peter, will review and respond. Just checking routinely, correct in case of no partials it would not make a difference.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Any progress on this problem?

                          Comment


                            #14
                            Peter, I responded directly to the email you send to support - if you still see this happening, please forward me your current trace and logs using the Help > Mail to Support feature. Thanks.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Bertrand View Post
                              Peter, I responded directly to the email you send to support - if you still see this happening, please forward me your current trace and logs using the Help > Mail to Support feature. Thanks.
                              Bertrand, I'm not sure where NT picks up the return email address in the Help/Mail Support dialog, however it's wrong. Can you resend it please? My name has dyslexia, the "f" and "p" at the end of the email user should be reversed.

                              Many thanks
                              Peter

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              6 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by gbourque, Today, 06:39 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gbourque  
                              Started by rexsole, Today, 08:39 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post rexsole
                              by rexsole
                               
                              Started by trilliantrader, Yesterday, 03:01 PM
                              3 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by Brevo, Today, 01:45 AM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X