[ts-gen] Blowup in Paper Account due to failed reception of OrderStatus 3/3/6 Filled

Nils Gebhardt mail at ngebhardt.de
Thu Sep 24 14:10:44 EDT 2009


On Thu, 2009-09-24 at 20:49 +0900, Ken Feng wrote:

> Today, while paper trading, my shim --risk failed to detect responses  
> in OrderStatus through a 3/3/6 after 15:00.  This caused a cascade of  
> problems as my system continued to submit orders thinking that nothing  
> was filled, when indeed, there were fills, according to TWS.

> At first I thought it was a problem with my Ruby code so I looked at  
> the OrderStatus table.  However, OrderStatus did not detect any fills  
> after 12:30:55, either.  My third check in the .log file for 3/3/6  
> confirmed that "Filled" was received by the shim.  So I conclude that  
> the IB server did not send me a proper 3/3/6 Filled, for whatever  
> reason.  In other words, I can't seem to rely on 3/3/6 or the  
> OrderStatus table to detect my fills.

to my current knowledge the most probable reason is a uniqueness
constraint violation. 
You can follow Bill's hints on the list from Sep, 15 ("Debugging
intermittent lost posts"). I found useful a 

fprintf(stderr, "PerQ: %s\n", q);

in fill.c around line 82. 

This might give you an indication what shim tried to insert into
OrderStatus, but maybe couldn't because of a duplicate key. You can
verify this if you take corresponding insert statements from stderr,
provided you can reproduce an error case - and try to insert it without
ignore clause.  The problem seems to be that the order_tag value is not
as unique as it seems at the first glance. 
I will try to rebuild the database without uniqueness constraint in 
OrderStatus and see what happens. 
I hope the order_tag is unique at least for a single day so that one
still can make useful joins with other journal tables. 

If you want to verify key uniqueness for fills, which are in the log but
not in OrderStatus, you can pick up the order_tag value from the 7th
field of log, e.g. if you have something like 

29575|41427| 178589666|3| 3| 6|1245|Submitted|0|1|0.000000|60488164|0|

then '1245' should correspond to order_tag, as I understand. From the
remaining fields it should be possible to reconstruct the whole
OrderStatus insert message. 

> However, I have noticed that clicking on the "ACCOUNT" button on TWS  
> does show the correct positions in the FX Portfolio section (eg aaa  
> QUESTION:  Does anyone know the command to submit to the shim to get  
> the same information that is on this screen?

select acct; 

should give the corresponding information - and should always give the correct information, 
even if other tables or even the GUI is out of sync. 



More information about the ts-general mailing list