[ts-gen] Do API history queries require the same-symbol market data line?

pippin at owlriver.net pippin at owlriver.net
Wed Nov 8 13:11:16 EST 2006


Although I've been using the tws api to make history queries for quite awhile
now, our first use case had prior market data subscriptions in place before
making the history query, so that I wasn't testing until recently for the
issue I'm curious about, of dependencies between market data line
subscriptions and history queries.

It's only in the last couple of days that I've tried to discard the
market data subscription, and when I do the query is ignored.  Or, if I
send a market data request prior to the query, the query fills right away,
and if I send it afterwards, the query response is delayed until the
subscription occurs.

Have those of you who use the api also found that you had to accompany 
history queries with market data subs, or do you know of a way around
this limitation?

The following script fragments that I feed to the trading-shim command
listener provide examples.  In the following, note that the tick and
past verbs make market data subscription and history query requests,
respectively, that the contract index 166 refers to dec YM, and that the
trailing 1 defines the dbms lookup index for market data configuration or
history filter information.

The 1st script fragment does not lead to a query response, the 2nd does,
and the 3rd delays for the duration of the sleep before providing the
response: 

#______________________________________________________________________________

# query response does not occur:

    echo 'past add 166 1;'

#______________________________________________________________________________

# query response is sub-one-second:

    echo 'tick add 166 1;'
    echo 'past add 166 1;'

#______________________________________________________________________________

# query response is delayed according the length of the sleep:

    echo 'past add 166 1;'   ; sleep 8
    echo 'tick add 166 1;'

#______________________________________________________________________________

For the 3rd case above, the text below gives log excerpts from the beginning
of the session until history data appears.  The lines with numeric indices in
the left margin indicate trading-shim commands, or api requests and messages,
while the dated text reflects log lines inserted by a controlling script.

#______________________________________________________________________________

1|9|1|1|
1|4|2|      -1|2104|Market data farm connection is OK:usfarm|
1|4|2|      -1|2107|HMDS data farm connection is inactive but should be availa

Nov  8 11:54:24 devel :
Nov  8 11:54:24 devel logger: 18233 YM history query
3|20|3|1|166|1|
1|4|2|       166| 165|Historical Market Data Service query message:HMDS server
1|4|2|      -1|2106|HMDS data farm connection is OK:ushmds2a|

Nov  8 11:54:32 devel :
Nov  8 11:54:32 devel logger: 18233 add YM subscript
3|1|5|       166|YM|FUT|200612|0.00||1|ECBOT||USD||
1|17|2|       166|30|
1|0|1|1|20061108  11:53:54| 2166.0| 2166.0| 2166.0| 2166.0|     0| 2166.0|fals
1|0|1|1|20061108  11:53:55| 2166.0| 2166.0| 2166.0| 2166.0|     0| 2166.0|fals
1|0|1|1|20061108  11:53:56| 2167.0| 2167.0| 2167.0| 2167.0|     7| 2167.0|fals

  ... more lines deleted

1|0|1|1|20061108  11:54:21| 2165.0| 2165.0| 2164.0| 2164.0|    35| 2165.0|fals
1|0|1|1|20061108  11:54:22| 2164.0| 2164.0| 2164.0| 2164.0|     1| 2164.0|fals
1|0|1|1|20061108  11:54:23| 2164.0| 2164.0| 2164.0| 2164.0|     0| 2164.0|fals

#______________________________________________________________________________

In the log text above, the next available id, and market data and history
farm access info status messages occur first; then two log inserts, a history
request, and more data farm status info; and finally another pair of log
inserts, the market data request, and right away, before even receiving the
market data, the response to the history query.  (I've munged the price
information to respect the IB license restriction on price info
redistribution.)

Note that the history query was received by the tws around 11:54:23, as
indicated by the time of the last history detail line; noted in the log a
second later, at 11:54:24; the market data subscription made at 11:54:32,
eight seconds later; and the history response, immediately following.  I
realize the Linux logger is not synchronous, but I can insert arbitrary sleep
delays, and response delay increases accordingly.

What protocol do those of you who use the api to make history queries 
follow?  Do you always provide market data subscriptions to accompany
those queries, or do you know of an alternative?

Thanks,

Bill



More information about the ts-general mailing list