IB: API problems placing first order of the day (sometimes)

Discussion in 'Order Execution' started by tron_at, May 19, 2009.

  1. tron_at

    tron_at

    From time to time (1-2 a week) my application's first order is rejected with the following reason:
    Code:
    Error: id=3033, code=322, Error processing request:-'ub' : cause - jextend.ub.f(ub.java:1152)
    
    tws.log says:
    Code:
    GQ 09:29:09:377 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] Started reading message:
    GQ 09:29:09:378 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] Finished reading message:
    GQ 09:29:09:378 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] ub::[version=27,ID=3033,reqDesc=Symbol=CL  Type=FUT  Expiry=200907  Strike=0.0 Put/Call=?
                        Exchange=NYMEX  CompExch=null  Currency=USD  Multiplier=null  IbLocalSymbol=null  includeExpired=false  Legs=null,transmit=true,combo=null]
    GQ 09:29:09:379 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] [27;3033;CL;FUT;200907;0.0;2;null;NYMEX;null;USD;null;2;1;LMT;Value;
           60.6;Default;1.7976931348623157E308;1.7976931348623157E308;1.7976931348623157E308;1;Uxxxxxx;true;0;null;ExpireDateTime [null];
           Reduce on Fill without Block;null;StockRefPrice=1.7976931348623157E308;DeltaNeutralOrderType=None;
           StockRangeLower=1.7976931348623157E308;ReferencePriceType=None;Hidden=false;OptionAcctAttrib=c;OpenCloseAttrib=O;
           FirmQuoteOnly=false;SweepToFill=false;PercentOffset=1.7976931348623157E308;VolatilityType=None;
           StockRangeUpper=1.7976931348623157E308;AllOrNone=false;OutsideRth=false;NbboPriceCap=1.7976931348623157E308;
           DeltaNeutralAuxPrice=1.7976931348623157E308;MinimumQuantity=2147483647;OrderRef=null;ContinuousUpdate=false;
           BlockOrder=false;DisplaySize=2147483647;Delta=1.7976931348623157E308;TriggerMethod=Default;
           StartingPrice=1.7976931348623157E308;Volatility=1.7976931348623157E308;ETradeOnly=false]
    GQ 09:29:09:379 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] Start validating message:
    GQ 09:29:09:379 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] Finished validating message:
    GQ 09:29:09:379 JTS-EServerSocket-29: [1:42:44:1:0:0:0: DET] Started processing message:
    GQ 09:29:09:379 JTS-EServerSocket-29: [1:42:44:1:0:0:0:INFO] Placing orderId - 3033
    GQ 09:29:09:499 JTS-EServerSocket-29: [1:42:44:1:0:0:0:ERR] -'ub' : cause - jextend.ub.f(ub.java:1152)
    GQ 09:29:09:499 JTS-EServerSocket-29: Anticipated error
    GQ jextend.b
            at jextend.ub.f(ub.java:1152)
            at jextend.ab.j(ab.java:259)
            at jextend.ud.P(ud.java:916)
            at jextend.ud.run(ud.java:773)
            at java.lang.Thread.run(Thread.java:619)
    
    
    GQ 09:29:09:499 JTS-EServerSocket-29: [1:42:44:1:0:4:2: DET] Sending error.
    GQ 09:29:09:500 JTS-EServerSocket-29: [1:42:44:1:0:4:2: DET] [4;2;3033;322;Error processing request:-'ub' : cause - jextend.ub.f(ub.java:1152)]
    GQ 09:29:09:500 JTS-EServerSocket-29: [1:42:44:1:0:4:2: DET] Error sent.
    
    This happens randomly, but only on the first order of the day. Subsequent orders are working rock solid!
    Restarting TWS resolves the problem. Anybody else with the same problems?

    regards,
    tron_at
     
  2. Never seen anything like that.

    if you want to post the settings of the order, I'd be happy to take a look at it and see if i see anything out of the ordinary.

    Edit: maybe you can let us know if you call this from Java, C etc. Without more data I have no idea.
     
  3. tron_at

    tron_at

    First of all thanks your help. Any comments are welcome.
    My application uses the Java API (version 9.60). I do set the following order-fields:

    Code:
    Contract contract         = new Contract();
    contract.m_symbol         = future.getCode();
    contract.m_currency       = "USD";
    contract.m_secType        = "FUT";
    contract.m_exchange       = exchange;
    contract.m_expiry         =  String.valueOf(future.getExpiryYear() * 100 + future.getExpiryMonth());
    contract.m_includeExpired = true;
    contract.m_localSymbol	  = "";
    contract.m_exchange       = exchange:
    
    com.ib.client.Order order = new com.ib.client.Order();	
    order.m_orderId	          = ++orderId;
    order.m_clientId          = clientId;
    order.m_permId            = permId;
    order.m_action            = "BUY";  // or "SELL";
    order.m_totalQuantity     = Math.abs((int) size);
    order.m_tif               = "GTC";
    order.m_transmit          = true;	
    order.m_account           = account;
    order.m_orderType         = "LMT";
    order.m_lmtPrice          = PriceUtils.round(price, minTickSize);
    
    clientsocket.placeOrder(orderId, contract, order);
    
    ... which works fine most of the time.
    TWS version is 894.4 (May 6). Just for your interest, I am using a simplfied version to keep TWS running over midnight. Could the daily reset of IB-Servers cause this problem?
    Meanwhile, I found somebody with a similar problem: http://www.mail-archive.com/jbooktrader@googlegroups.com/msg01227.html
     
  4. maxpi

    maxpi

    I think it's a good idea to restart TWS and the computer in the premarket hours. There are known issues with P&L and that is the fix. Windows has had various issues that are best resolved by a restart so why not restart that mess as well...

    I saw one post that had to do with an auto restart program that was programmed to restart the TWS at the same time as the maintenance restart of the servers, that guy was confused by something or other, can't recall exactly what...
     
  5. tron_at

    tron_at

    Maybe you are right (at least restarting TWS). Meanwhile I have talked to an IB rep on the phone and he told me that keeping TWS running during server reset may cause the issue, another idea was to set:
    Code:
    order.m_overridePercentageConstraints = true;
    
    Since the first order is not rejected every day, I'll see what the next week or two will bring.

    thx & best regards,
    tron_at
     
  6. tron_at

    tron_at

    It seems that setting
    Code:
    m_overridePercentageConstraints=true;
    
    resolves the problem. I have not had any order transmission issues this week.
     
  7. travis

    travis

    Yes, I had the same problem. I don't know how you found out those error codes, but about a month ago, the first order of the day did not get executed for a reason unknown to me (I have the audit trail, but I can't detect the reason). Then the other orders didn't have any problems, and the same order the next (and previous) days was executed at the same time without any problems.
     
  8. nello

    nello

    We have had the same problem for months, and have been working with IB Professional Support to try and get it rectified.

    I can tell you that it definitely does NOT have anything to do with long-held TWS sessions. The IB guy who suggested this is just jerking you around, but that is nothing unusual.

    Their support people have to be the worst-informed bunch of bozos I have ever dealt with. Just as in your case, they continually make uneducated guesses without any evidence to back up their stupid hunches.

    Thanks for your settings suggestion. We will have a go with it.

    Are you running on Linux? Our guess (not IB's - they have absolutely no clue) is that TWS is having some problems with screen handling on Linux when API orders are processed for the first time in a day.
     
  9. It is almost the norm that IB's first order is hesitantly executed. This is a problem that I worry every morning. I didn't know you guys are having the same 1st order problem.
     
  10. I've never observed that.

    On Linux, I reckon it's a good idea to set system title bar option:

    Configuration -> Display -> Style -> Use system title bar
     
    #10     Feb 19, 2010