realtimeBar subscription stops during the trading session
Experiencing this issue almost every trading day. Using TWSProxy. At the start of the day multiple reqRealTimeBars requests are issued for different contracts (not much - 5-6 requests). However during the session one or more such subscriptions cease to work. For example the following API log shows that the subscription for AMD (contract id 16777225) stops working after 20:23:05 UTC and doesn't resume till eos (other subscriptions continue working): (relevent log lines are marked with ***)
Looking at the gateway logs around the same time always shows the following strange log lines (handleBustEvent):
No API notification is sent to the application (as you may see from the API log). Would appreciate if anybody could shade a light on a possible cause of the failure. Thanks Vlad
|
|
Nick
RealTimeBars has always had an issue where data sometimes stopped being sent when a session closed.
toggle quoted messageShow quoted text
The only solution was to unsubscribe and re-subscribe. You will probably have to experiment on what time works best for the re-subscribe. For futures it used to work if I subscribed 15 minutes before the start of the next session. I haven't used realtime bars for a while and never for stocks so I can't give a specific recommendation for what might work best.
On 1/20/2020 3:37 PM, VladD wrote:
|
|
Josh
Vlad can you try upgrading to a current version of TWS/IB Gateway v978 or v979? It should be ok there.
|
|
Thanks Josh, I've upgraded to 978.1h - still experiencing the problem of subscriptions deactivation. However now there is an additional error notification sent to the application, explicitly stating that subscription was deactivated and should be renewed. See the API log quote below for MU contract subscription (contract id = 16777221) (relevant entries are marked with ***):
Gateway logs still show the same (BustEvent) events:
Will update the application to handle the above error events of cause. The question though - is there anything that could be done to avoid those 'Bust' events from the application side ? And what do those 'Bust' events mean at all ? Thanks Vlad
|
|
Josh
the busts occur when the datastream is interrupted or modified in the middle of a bar and the subscription is cancelled by the backend. They should be relatively uncommon but unfortunately no can't be avoided completely. By checking for the error code you should be able to resubscribe automatically.
|
|
Thank Josh for the explanation. I've updated my system to re-subscribe for the realtimeBar upon receiving the 10225 error. It works in most of the cases (see the log below - relevant lines are marked with ***)
However in some cases it doesn't. The re-subscription is issued but no other realtimeBar packets are received for the re-subscribed contract.
What could be wrong? Re-subscription failed? Any way to know about it in this case? Should the application wait for some timeout to re-subscribe ? Thanks Vlad
|
|
Nick
Just FYI, the other live data streams don't have this issue. Building bars from ticks might be preferable to random and unpredictable failures with realtime bars.
toggle quoted messageShow quoted text
On 1/29/2020 1:53 PM, VladD wrote:
|
|
Josh
Yes I would try a slight delay (though the message says to resubscribe 'immediately') but also agree with what Nick said.
It wouldn't hurt to contact API Support with detailed logs and your findings, the message is a new feature.
|
|
Just FYI, I've contacted the API Support and here the answer I've got: ''' The existing request may not have terminated. When bust event occurs please try using cancelRealTimeBars() then call reqRealTimeBars() again. ''' Will update my application and test it for few days - will update after that.
|
|
Update: after a week of testing - realtimeBars seems to be working flawlessly. Re-subscribing after bust events doesn't require any delay to be added by the application - just make sure to cancel the previous subscription before re-subscribing, as was mentioned above.
|
|