[ts-gen] Reconciling Trades (Building Failsafes)

Ken Feng kfmfe04 at gmail.com
Thu Sep 24 23:27:24 EDT 2009


After my recent incident (see "Blowup in Paper Account due to failed  
reception..." thread), I am looking to institute various failsafes  
into my system.

The first one I am working on involves downloading the trades from the  
TWS GUI through View/Trades/File/Export Today's Reports into a .csv  
file, as suggested by Paul C in the "Handling Commissions and Fees"  
thread.  As Bill has mentioned previously in a different thread, the  
"Order Ref." field is particular useful here.  You may need to  
"Customize Report" to select the column for export.  This "Order Ref."  
is the unique sequenceID that we pass to the Shim through the bind key  
command when we initially create the order; too bad this "Order Ref."  
doesn't seem to show up anywhere else (like in 3/3/6 responses in the  
logs for example).

Sometime this weekend, I will have to add some Jemmy (java) code to  
download trades through the TWS GUI periodically - it's an ugly pull  
mechanism, but I am in desperate need for multiple failsafes at this  
point.

Once dumped to disk, you can use Mysql's LOAD DATA INFILE to read it  
into a staging table for further manipulation, or add views to  
aggregate partial fill trades into a complete order.  Doing so will  
make it easier to compare TWS trades with your internal orders.  I  
plan to use this information to confirm that my internal state of  
orders (filled, canceled, etc...) is not out-of-whack.  I can use this  
mechanism as a failsafe before sending any additional/new orders back  
upstream through the Shim pipe.

It sounds complicated, but it's not that hard - only a few hours work,  
if you know what you are clear about what you are trying to do.

I don't have any questions in this post - just sharing some thoughts  
and aggregating some information in case anyone else may find this  
useful.

- Ken




More information about the ts-general mailing list