Keyboard Shortcuts
Likes
Search
reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
On Tue, Dec 24, 2024 at 03:40 AM, buddy wrote:
Of course, what's also interesting, is this could actually be a bug w/ 10.19 instead. That is, 10.19 might be providing bad data in a timely manner instead of timing out. Unfortunately, it's difficult to be certain without digging much much deeper into the IBKR infra and the TWS/IBGW code. |
We are talking about entirely different cases
The first case smells like a bug (as long as data should be available), while the second case is simply a change in systemic behavior. Even if that behavior change, in the eyes of the user, is a degradation and causes previously working timeouts to now fail. That is the crux with timeouts - they are always too long until they are suddenly not long enough. During my due diligence before switching from V9 TWS/IBGW to the first stable V10 (probably around TWS 10.10) I found that timing for certain operations had changed. Some for the better and some for the worse. So it is not unreasonable to assume that something similar happened between 10.19 and 10.30+. To quickly check that hypothesis I went back to my records and compared all reqMkt() subscriptions for SPY ETF in December 2023 (when I used stable TWS/IBGW 10.19) with those from MTD December 2024 (with stable TWS/IBGW 10.30). And guess what:
Small things other than the TWS version have changed on my side since December 2023, but I cannot imagine that any of those changes could cause the longer time to first tick. But I will run tests with 10.19 to confirm when the markets are closed later in the week. Attached a quick xlsx with the raw results. I still would not call this a bug (though this change of behavior may have not been intended by the developers) 闯ü谤驳别苍 ?
On Mon, Dec 23, 2024 at 09:40 PM, buddy wrote:
|
On Tue, Dec 24, 2024 at 06:53 AM, 闯ü谤驳别苍 Reinold wrote:
Well, for practical purposes, whether it's a "bug" or not is a moot point. But, just as you wouldn't call it a bug, I wouldn't necessarily call it a great improvement either ;-) That said, I understand your viewpoint, and would simply remind future readers that it's wise to distinguish between so-called "hard" vs "soft" real-time requirements when building these types of programs. |
On Mon, Dec 23, 2024 at 10:31 PM, 闯ü谤驳别苍 Reinold wrote:
Twenty seconds seems to be a pretty long time (see attached). How long do you think we should wait before crossing over from thinking this is a "feature" to "bug"? Ah... good old Sorites paradox, never fails to amuse :-) |
I still believe there is no bug or anything wrong with reqMktData real time feeds. And snapshots are probably what you are looking for in the first place. TWS API documentation says about reqMktData snapshots that: ... it is possible to request a snapshot of the current state of the market once instead of requesting a stream of updates continuously as market values change. What you experience is likely that, at times, not all of the market values you are interested in change during the 20 seconds you are looking at the market. You could easily verify that yourselves by downloading TickByTick historical data for the time periods that fail your test. I took a quick look at the "missing" BID price for MTDR on 20241217:
I don't have enough data about your 10.19 vs 10.30+ comparisons to explain the differences your are seeing. It may very well be that IBGW/TWS 10.19, upon subscription, send some "recent historical values" and 10.30+ are now cleaner and send "only market values that changed". But that is just a guess and there may be other explanations. 闯ü谤驳别苍 ? ? ?
On Thu, Dec 19, 2024 at 11:56 AM, ajn wrote:
|
On Thu, Dec 26, 2024 at 05:36 AM, 闯ü谤驳别苍 Reinold wrote:
The above is an interesting thought. But, I feel obligated to note it would be a breaking change to the interface. So basically still a pretty big "bug/problem"... just not in the implementation. And even if it's "cleaner" over the wire, changing an interface without also changing its signature is terrible practice because it silently breaks end user applications (as @ajn may have found out). With all due respect 闯ü谤驳别苍, dismissing this or trying to spin it as a good thing(tm) strikes me as extremely forgiving or just naive. Finally, if this speculation is correct, it makes me think that extra caution should be exercised prior to using 10.30+ in production. Since, I wouldn't want to have any code running the relied on defaults being set to "recent historical values" and didn't immediately fail loudly when such an assumption quietly disappeared; which seems like a possibility. |
On Thu, Dec 26, 2024 at 05:36 AM, 闯ü谤驳别苍 Reinold wrote:
I thought this was an interesting observation as well. So, I changed the input list to just 800 of the most liquid stocks (see attached) and specified SMART as the exchange instead. Additionally, I changed the timeout to 45 seconds. Failure occurred in the same manner. Of course, your theory that the semantics w.r.t. reqMktData have mysteriously changed still holds water. And, even though the professional way to distribute such a change would have been to implement reqMktData2 and optionally deprecate reqMktData (so that there were no unpleasant surprises), at least there appears to be some form of sour logic to what's going on. However, without confirmation from IBKR there's no way to know this with absolute certainty, and that's not great. Regardless... it seems the best advice, at the present time, might be as previously suggested, to first initialize things with a snapshot. If IBKR takes responsibility for any of this I'd absolutely love to know about it. Keep us posted @ajn. |
?I have executed the short file you posted multiple times through IB_Gateway. Final result in prompt: ? done symbols: 1283 Number of not done symbols: 0 In about 52 seconds. Also, gateway is sending with each ticker 2024-12-27 13:09:32.976 [OQ] INFO ?[JTS-usfarmDispatcherS3-52S3-53] - Sending for ticker=1001373 market data info: bboExchangeAndSecType=a60001, snapshot perms=REALTIME_TOP ? I noticed that I don't have any output files from this script. Could you send the code you used to write the bid data to file. I am on TWS 10.30.1, did you recently update to 10.30 or have you been fighting with this for a while? |
jy.yngbld@...,
1. first loop of the test not always gives the errors. If you run several loops, then it is more likelly to repeat the issue Program_get_bid.py -f symbols.csv -m REALTIME --data-lines 75 --loops 5 --port 4001
2. "I noticed that I don't have any output files from this script." if you scroll in this discussions, the very first message has the app which outputs much more?
3. "I am on TWS 10.30.1, did you recently update to 10.30 or have you been fighting with this for a while?" I had this issue for more than 2 months now. Ever since 10.30 was promoted to "stable". I updated and immidiatelly run into this. |
Interestingly the documentation on what reqMktData (both old and new). Have this statement "A tickPrice value of -1 or 0 followed by a tickSize of 0 indicates there is no data for this field currently available". Which I read as: if there is no data I get -1, if there is data I get some number. I guess this is there IB could be much more explicit. If one subscribes to market data in the middle of the trading session what happens? Does one get a "snapshot" of data = the latest data IB has (some might be very old) and then updates only then changes happen (which I believe how 10.19 and older worked). OR the "snapshot" part never happens now (10.30 and later?). ? However, a couple of observations from live environment which make me doubt the above explanation and make me lean on "some resource optimization went wrong". Is more likelly explanation. Here is a problem from one of live environments? 1. if the above is true, then high/low would be really rarelly updated. And this is not the case. Once asked for data those (high/low) get streamed, most of the time. Ok, it could be that for high/low there is an exception 2. In real env I often see?lastTimestamp missing (timestamp of the last trade) yet the price is present. For me it points to that "timestamp" stream got dropped by IB somehow in this case.? Of course, the way API is setup we should not expect a perfect synchronicity here. but not getting within 20 seconds a timestamp is really a bug and probably of the same nature as we discuss here.? 3. Another fact that points to optimization problem. In this test app one needs to run several loops to consitently see the problem. With the first loop is likelly to be fine, only in later loops the issues will pop up.? ? No updates from IB on the issue yet (I reported end of Nov). I keep asking for progress and they keep replying that "they cannot repeat the issue". I of course sent all the test code and tips and tricks...?
I keep wondering, since IB is silint of the issue I have no other choice but to continue guessing that this is an "optimization went wrong". Makes me wonder (untill IB proves otherwise): what els is not stable in 10.30? Like if you "push API too much you might only get a fraction of you account reported or you order will not be posted"-
|
Thank you very much Andrei, your research (troubleshoot) is very helpful..!!! Rgds, Idjoel On Fri, Dec 20, 2024 at 12:56?AM ajn via <andrei.jefremov=gmail.com@groups.io> wrote:
|