As my response is more "how the API works" oriented I'll risk being on topic.? Also I think there was a question about this awhile back that was not completely answered. Another approach running your own on-line ema,obv, D+/- ADX, ADR etc and minimizing bookkeeping is to use the HistoricalBars API with the KEEPALIVE option. You request historical bar data back as many periods as you need to seed or warmup the indicator up to "now".? At which point the IB's API will start sending still open Bar Ticks i.e. Tick-by-Tick but for the current open Bar.? The AFAIK undocumented key observation is noting that IB sends an undocumented START_OF_NEW_OPEN_BAR message which is a Bar Tick with a count value of -1 and the high,low,open,close all the same value (as this is the open of the new bar window).? The previous Bar Tick is the last tic of the Bar with that Bar's final closing values. i.e.? Keep saving the last open bar tick received until you see a START_OF_NEW_BAR tic and then the last save Bar tic is the _full_ just closed bar. One caveat is that every so often you get an open bar tic with the count value with some very large negative number.? Best guess is this some "correction" bar tic in the open bar and IB has a bug in the serialization.? Maybe it's the neg 2-complement or something.? Doesn't matter as all I care about is when the Bar closes in most cases so I just toss those. One final observation.? If you do a HistoricalBar 5-min request you are getting a live bar stream of the 5 min bars.? Merge 2 5min and you have a 10min bar.? Merge 3x 5 you have a 15 min bar.? Merge 2x 15 for a 30 etc. In other words with a single HistoricalBar request (open connection) you can say monitor an instrument 5,10,15,20,30 min ema, obv, DI+/-, ADX, ADR ect. online without constantly recalculating the historical stream all the time (as asy EMA(t) is a function of EMA(t-1).? For an hour ema I just call HistoricalBars every hour with KEEPALIVE=NO. On and final final observation.? According to the IBK docs on HistoricalBars you could go down as low as 5-sec bars with this.? Also they have generously relaxed the HistoricalBar rate limiting constraints. ? Hopefully my sharing of this technique does not result in someone abusing it and having the constraints re-applied. On Thu, Jul 29, 2021 at 9:38 PM ebtrader <jsiddique@...> wrote:
|