[ts-gen] Repost from yahoo api list about shim

Bill Pippin pippin at owlriver.net
Thu Jul 15 11:51:16 EDT 2010


The following is a lightly edited copy of a post I made to the yahoo
TWSAPI list describing the shim.  It's interesting primarily for the
roadmap information about planned features, immediately following the
"Caveats" paragraph.

... about implementing the IB tws api via C++ ...  I work on a linux
platform using g++, and with a system called the trading-shim,
http://www.trading-shim.com/ ...

... there have been a number of posts recently about C++ for the IB
tws api, and I want to make sure readers know about what's already
been completed, so they can avoid reinventing wheels if they so desire.

The shim is ... written in C++; available as free code under
the GPL v3; and can be downloaded from http://www.trading-shim.com/ ,
which page also includes links to the mailing list. 

Caveats: the shim currently runs only on Linux; there is no support
for financial advisor features of the IB tws api, due to lack of
interest on our part; the database used for order journalling is
currently limited to Mysql; the symbols database is based on a
dated collection of IB symbols data from the net, due in part to
IB license restrictions; and the client-side api level is currently
quite stale, so that users don't yet have access to some of the
newer features of the api, such as commission costs.  As for
solutions to these limits:

Although the lack of a windows port is, absent someone else
porting the code, unlikely to change in the near future, addition
of Postgres support is likely soon, a complete revamping of symbols
handling to dynamically build the symbols database from contract
data queries will be ready sooner than that, and broadly increased
api level support over a range of api levels is next on our roadmap.
Now, on to a summary of existing features:

The shim is an interpreter, accepting commands in a simple text
format, which are then augmented with information from the database,
and mapped to IB tws api requests.  It logs command input, the
generated requests, and the resulting IB tws api messages to any
of a number of log channels.   These events are displayed using a
simple textual, newline-terminated record format that is faithful
to the layout of the IB tws api yet, unlike that api, trivial to
parse.  The shim takes complete responsibility for request timing,
with sophisticated controls to time the transmission of ordinary
requests, orders, and history in accord with the requirements of
the IB tws api.

It's meant to be driven by downstream applications written using
any available scripting language.  We use ruby, and there is the
beginnings of a ruby sample client available in the regression
test script directory of the release.

Since the source code is free under the GPL v3, it's of course
also possible to modify the sources as you wish and link in your
client C++ code, although I don't know of any users who have chosen
to go that route.  We prefer the greater flexibility and faster
development that comes from separating signal processing and order
generation logic out into downstream scripts.

The shim is powerful, due to the augmentation of a simple
textual command language with the order templates and symbols 
from the database; robust, with a parser that checks input
assiduously and recovers from message parse errors; efficient,
as demonstrated by the time stamps it prepends to log entries;
and simple to use, as it converts the binary tws request and
message streams to flat text records in the log.

There is a simple scrolling script with the release,
bin/tail.window, and watching the api events log scroll by in a
kde console is infinitely superior to the java window provided
by the IB java sample client, especially since the shim's log
is right there for either later text analysis, or immediate
processing by downstream scripts. ...

Thanks,

Bill


More information about the ts-general mailing list