[ts-general] Problem(s) 403 and 524 - shim..start - possible fix

Paul paul.analytic at gmail.com
Mon Sep 3 11:55:23 EDT 2012

On Tue, May 01, 2012 at 07:27:40AM -0400, G wrote:
> Hi all,
> I'm using Lion (osx 10.7.3) while attempting to use the shim. I have the
> database setup, the tws setup, but I keep getting the following error when I
> start the shim:
> Gauravs-MacBook-Pro:shim-101126 G$ ./shim --data
>           The trading shim has connected to the database server and
>           loaded  51624 products.  
> For line number 192 of the code in open.c:
> Problem: 421 the client id  1 is ignored by the IB tws
> Read:    1    6   19 <15>
> Problem: 403 probe failed: no rule exists for index 15
> 15|1|DU15017|9|1|1|
> Problem: 524 the IB tws server version is contradictory
> Exiting

It seems that new versions of the TWS (and IB gateway) server are
sending a 'list of managed accounts' where the shim client is
expecting to see the next valid order id.

Attached is a patch for the shim src/ files that seem to fix this
(along with a previous patch for src files as detailed in a posting
last year dated August 1st 2011 which may also be needed to prevent
errors when sending orders). 

To install I (i) backup the ./src directory; (ii) copy the patch(s) to
the shim root directory (e.g.  shim-101126/, not the ./src
subdirectory); and (iii) from there run:

   patch -Np0 -i shim-101126_patchSep2012.patch 

NOTE: It may also be necessary to to go to the TWS/Gateway API
Settings page and UNcheck the 'Download open orders on connection' box
as this could also prevent the shim starting (not sure yet).

NOTE: DONT'T apply these changes if the shim currently works for you
(i.e. with older versions of TWS).  These changes prevent the shim
from talking to older versions of the TWS which don't send the list of
managed accounts; but to make it work again for old TWS, just change
the "#if 1" on line 337 of src/open.c to "#if 0" and recompile.

Technical NOTE: As I'm no expert in the shim source code I can't be
sure this fix will always work. I started off trying to process the
list of managed accounts properly, but ended up modifying the part of
open.c that deals with the nextid/NextTick data sent at startup. It's
obviously not the way the developers would have fixed it, but it seems
to work for me: the shim starts, I get data, and can send orders.

Note, all my testing is done with 
   let ApiLevel = 47;
in ~/.shimrc



> . . .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shim-101126_patchSep2012.patch
Type: text/x-diff
Size: 7086 bytes
Desc: not available
Url : http://www.trading-shim.org/pipermail/ts-general/attachments/20120903/764bfe07/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shim-101126_patchAug2011.patch
Type: text/x-diff
Size: 2145 bytes
Desc: not available
Url : http://www.trading-shim.org/pipermail/ts-general/attachments/20120903/764bfe07/attachment-0001.bin 

More information about the ts-general mailing list