Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Possible bug in TWS API when requesting auction price, volume, and imbalance data for ASX-listed securities
Hi,
When requesting auction price, volume, and imbalance data for ASX-listed securities in the pre-auction period, I'm getting the same number returned to me for both auction volume and auction imbalance, even though the tick type is different. I've put together an MWE to help anyone else look into this possible bug. I also just ran this MWE during the pre-close period today and I've pasted some of the output produced below so you can see what I mean. Anyway, the code is: On my machine, this snippet will start printing auction price, volume, and imbalance data to the terminal for NAB (National Australian Bank) - which is one of the big banks listed on the ASX. I ran the snippet in the pre-close period today (just after 4pm Sydney time) and here is a snippet of the output produced:from ibapi.client import EClient tickSize? triggered. reqId=5, tickType=36, size=897951My understanding is that tickType 34 is supposed to be the volume, and tickType 36 is the imbalance. However, as can be seen here, they are both returning exactly the same number each time. Note, I've verified this behaviour across multiple securities on multiple days. Cheers all, any help would be most appreciated. Colin |
I just thought I'd add to my original message: I'd be very interested in hearing whether anyone has experienced this bug on exchanges other than the ASX, and also whether anyone has experienced this bug using languages other than Python? I've joined the github project for TWS API, so if I could confirm that this behaviour only happens on Python that would certainly narrow things down.
I also should have added to the original post that the auction imbalance displays correctly in the TWS GUI, which suggests fairly strongly that the problem is occurring somewhere in the API. Cheers, Colin |
Nick
You could enable the api log and see what TWS is sending over the socket.
toggle quoted message
Show quoted text
I haven't looked at the latest api but earlier versions did not inform TWS of the language used to implement the client api. In other words TWS does not know whether a client is python or Java or C++. If the data is correct in the api log but incorrect in python then that is useful. If the data is wrong in the api log it would be wrong in all languages. On 4/10/2022 7:35 PM, colintbowers@... wrote:
I also should have added to the original post that the auction imbalance displays correctly in the TWS GUI, which suggests fairly strongly that the problem is occurring somewhere in the API. |
Great suggestion thanks Nick. I'll try that and report the results back to this thread. Cheers, Colin On Mon, 11 Apr 2022 at 10:26, Nick <news1000@...> wrote: You could enable the api log and see what TWS is sending over the socket. |
Following Nick's suggestion, I made some requests in the pre-close period today and examined separately the TWS log file and the API log file. As it turns out, examining the API log file was unnecessary, since we can already see the bug in the TWS log file, before the data ever reaches the API. Here is a short excerpt:
``` 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Sending tick size. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:DET] [2;6;2070488;34;37031] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Tick size sent. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Sending tick size. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:DET] [2;6;2070488;36;37031] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Tick size sent. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:1:6:INFO] Sending tick price. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:1:6:DET] [1;6;2070488;35;0.70999998;non-eligible;0;0;0] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Sending tick size. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:DET] [2;6;2070488;61;0] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Tick size sent. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Sending tick size. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:DET] [2;6;2070561;34;200000] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Tick size sent. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Sending tick size. 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:DET] [2;6;2070561;36;200000] 2022-04-11 16:04:40.267 [UN] INFO? [JTS-afarmDispatcherS8-111S8-112] - [0:151:151:1:0:2:6:INFO] Tick size sent. ``` As can be seen, tick types 34 and 36 are both sending the same number, even though the imbalance number in the GUI is most definitely not the same number as the auction volume. So it seems that the bug is in the TWS section of the codebase itself, rather than in the Python API, which is a bit unfortunate because I probably could have done something about it via github if it was in the Python API. So I guess this probably has to be lodged as a ticket with the IB TWS team. Does anyone have any experience with this? Are they particularly responsive or is this one of those things that could take years for them to address? Cheers, Colin |
Hi all,
Just thought I would add that I've verified that the bug is definitely in TWS itself. My earlier assertion that the numbers in the GUI were correct was actually incorrect. I was looking at imbalance percentage rather than raw imbalance. When you compare raw imbalance and auction volume in TWS GUI for ASX listed stocks pre-auction, those two fields are always identical (which obviously they shouldn't be). I've submitted a bug report to IB directly with a screenshot and we'll see how responsive they are. Cheers, Colin |
¿ªÔÆÌåÓýHi JurgenThanks for responding. Yes I read your other thread about 10.x and double checked what version I was on, but I¡¯m still in 9.x. Also this was on a live account not paper. I think this bug has been around for a while. The imbalance field is supposed to be red or green depending on bid or ask surplus, but now that I think about it, I have never in the last few years seen it be any colour other than green for ASX stocks, which fits with the narrative that they are accidentally putting the volume in that field instead (which will always be positive). Cheers, Colin On 13 Apr 2022, at 5:00 pm, ´³¨¹°ù²µ±ð²Ô Reinold via groups.io <TwsApiOnGroupsIo@...> wrote:
|
to navigate to use esc to dismiss