Keyboard Shortcuts
Likes
Search
Intermittent IBGW connection problems 10.19.2a
¿ªÔÆÌåÓý
Since switching from IBGW
10.12.2v (support ends July, 18th) to 10.19.2a I observe
intermittent disconnects between IBGW and the IB server.
It is therefore not possible e.g. to get a continuous realtime tick-by-tick data supply (EUREX Futures). Remarkably, a second Paper account IBGW isnt' affected at the same time and continues to deliver tick-by-tick data. Maybe someone has the same problems or kindly enlightens me that I overlook something. Regards Greg Today (July 4th) my API log of the Live account says (requesting EUREX FDXM, GBL data): 00:55:17:693 -> ---15-1-Uxxxxxxx 00:55:17:700 -> ---9-1-1- 00:55:17:700 -> ---64-2--1-2104-Market data farm connection is OK:usfarm-- 00:55:17:700 -> ---84-2--1-2105-HMDS data farm connection is broken:euhmds-- 00:55:17:701 -> ---44-2--1-2106-HMDS data farm connection is OK:ushmds-- 00:55:17:701 -> ---94-2--1-2158-Sec-def data farm connection is OK:secdefnj-- and the Paper account: 00:52:42:430 -> ---15-1-DUxxxxxxxx 00:52:42:445 -> ---9-1-1- 00:52:42:445 -> ---64-2--1-2104-Market data farm connection is OK:usfarm-- 00:52:42:449 -> ---44-2--1-2106-HMDS data farm connection is OK:euhmds-- 00:52:42:449 -> ---44-2--1-2106-HMDS data farm connection is OK:ushmds-- 00:52:42:449 -> ---94-2--1-2158-Sec-def data farm connection is OK:secdefil-- Yesterday (July 3rd) tickdata ceases at 06:25:37 AM and the IBGW log says, that the connection to zdc1 disconnected. Then, it never re-connects while ndc1 re-connects within a second and stays healthy: 2023-07-03 06:26:56.740 [YN] INFO? [JTS-AsyncNonLocked-31] - disconnectAndReconnect due to routing change for euhmds state:NATIVE default:ccp dataType:NONE points:[useccphost] nativeViaCcp:null 2023-07-03 06:26:56.740 [YN] INFO? [JTS-AsyncNonLocked-31] - Disconnecting zdc1.ibllc.com:4000 [disconnectDetails=DisconnectDetails[sessionID=8,endPoint=zdc1.ibllc.com:4000,reason=DISCONNECT_ON_BROKEN_SOCKET,cause=null,systemMessage=null,keepSocketOpen=false]]... 2023-07-03 06:26:56.741 [YN] INFO? [JTS-euhmdsListenerS8-148] - Socket or stream for connection zdc1.ibllc.com:4000 was closed by another thread. 2023-07-03 06:26:56.741 [YN] INFO? [JTS-AsyncNonLocked-31] - Socket closed. 2023-07-03 06:26:56.741 [YN] INFO? [JTS-AsyncNonLocked-31] - Interrupting dispatcher [sessionID=8]... 2023-07-03 06:26:56.741 [YN] INFO? [JTS-AsyncNonLocked-31] - Interrupting listener [sessionID=8,disconnectSocket=true]... 2023-07-03 06:26:56.741 [YN] INFO? [JTS-AsyncNonLocked-31] - AuthTimeoutMonitor-euhmds: deactivate 2023-07-03 06:26:56.742 [YN] INFO? [JTS-euhmdsListenerS8-148] - Listener thread terminating [sessionID=8] [seen=20591,totalShifted=20591,moreAvailable=0] 2023-07-03 06:26:56.743 [YN] INFO? [JTS-euhmdsServicePingS8-153] - Terminating ping thread 2023-07-03 06:26:56.743 [YN] INFO [JTS-euhmdsDispatcherS8-149S8-150] - Dispatcher thread terminating [sessionID=8,interrupted=true]... 2023-07-03 06:26:56.744 [YN] INFO? [JTS-ResubscribeMarketData-79] - Resubscribing market data. desubscribe=false 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - Farm euhmds/NATIVE: Lost active connection with disconnect status DISCONNECT_ON_BROKEN_SOCKET 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - Farm euhmds/NATIVE: Resetting 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - CONN CALC: Last connection attempt time is cleared! 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - CONN CALC: Last connection set as now:06:26:56:747 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - HTBP Disconnected from live peer!::0 2023-07-03 06:26:56.747 [YN] INFO? [JTS-DisconnectedS8-275] - CONN CALC: Last disconnect time set as now:06:26:56:747 2023-07-03 06:26:56.748 [YN] INFO? [JTS-AsyncNonLocked-31] - Keep-alive scheduled for:euhmds 2023-07-03 06:26:56.748 [YN] INFO? [JTS-AsyncNonLocked-31] - cdebug: ROUTING | connTracker:euhmds@ab43b00 | Disconnected | 1688358414043 | true 2023-07-03 06:26:56.748 [YN] INFO? [JTS-AsyncNonLocked-31] - cdebug: ROUTING | connTracker:euhmds@5110d232 | Disconnected | 1688358414043 | true 2023-07-03 06:26:56.918 [YN] INFO [JTS-ushmdsDispatcherS20-269S20-270] - Compatible routing data: ... 2023-07-03 06:28:07.052 [YN] INFO? [JTS-usfarmListenerS3-47] - Socket for connection ndc1.ibllc.com:4000 was closed by peer. 2023-07-03 06:28:07.052 [YN] INFO? [JTS-usfarmListenerS3-47] - Disconnecting ndc1.ibllc.com:4000 [disconnectDetails=DisconnectDetails[sessionID=3,endPoint=ndc1.ibllc.com:4000,reason=DISCONNECT_ON_BROKEN_SOCKET,cause=null,systemMessage=null,keepSocketOpen=false]]... 2023-07-03 06:28:07.053 [YN] INFO? [JTS-usfarmListenerS3-47] - Socket closed. 2023-07-03 06:28:07.053 [YN] INFO? [JTS-usfarmListenerS3-47] - Interrupting dispatcher [sessionID=3]... 2023-07-03 06:28:07.053 [YN] INFO? [JTS-usfarmListenerS3-47] - Interrupting listener [sessionID=3,disconnectSocket=true]... 2023-07-03 06:28:07.053 [YN] INFO? [JTS-usfarmListenerS3-47] - AuthTimeoutMonitor-usfarm: deactivate 2023-07-03 06:28:07.053 [YN] INFO [JTS-usfarmDispatcherS3-48S3-49] - Dispatcher thread terminating [sessionID=3,interrupted=true]... 2023-07-03 06:28:07.053 [YN] INFO? [JTS-usfarmServicePingS3-77] - Terminating ping thread 2023-07-03 06:28:07.056 [YN] INFO? [JTS-DisconnectedS3-277] - Farm usfarm/CCP: Lost active connection with disconnect status DISCONNECT_ON_BROKEN_SOCKET 2023-07-03 06:28:07.055 [YN] INFO? [JTS-usfarmListenerS3-47] - Listener thread terminating [sessionID=3] [seen=422875,totalShifted=422875,moreAvailable=0] 2023-07-03 06:28:07.057 [YN] INFO? [JTS-DisconnectedS3-277] - Farm usfarm/CCP: Resetting 2023-07-03 06:28:07.057 [YN] INFO? [JTS-DisconnectedS3-277] - CONN CALC: Last connection attempt time is cleared! 2023-07-03 06:28:07.057 [YN] INFO? [JTS-DisconnectedS3-277] - CONN CALC: Last connection set as now:06:28:07:057 2023-07-03 06:28:07.058 [YN] INFO? [JTS-DisconnectedS3-277] - HTBP Disconnected from live peer!::0 2023-07-03 06:28:07.058 [YN] INFO? [JTS-DisconnectedS3-277] - CONN CALC: Last disconnect time set as now:06:28:07:058 2023-07-03 06:28:07.061 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - Farm usfarm/DISCONNECTED: Connecting via ccp conman (usfarm)... 2023-07-03 06:28:07.061 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - AsyncDisconnectNotifiers: 1 2023-07-03 06:28:07.061 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - Waiting asyncDisconnectNotifiers: JTS-DisconnectedS3-277 2023-07-03 06:28:07.063 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - Connecting ndc1.ibllc.com:4000 timeout=0... 2023-07-03 06:28:07.063 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - CONN CALC: Last connection set as now:06:28:07:063 2023-07-03 06:28:07.064 [YN] INFO? [JTS-AsyncNonLocked-31] - Keep-alive scheduled for:usfarm 2023-07-03 06:28:07.172 [YN] INFO? [JTS-Fuse-usfarm-ccppause-278] - Connected to ndc1.ibllc.com:4000 on local port 0 socket local addrs:port /192.168.178.50:50906 |
You saw this but did impact your code ? Otherwise said did you try to make a request anyway ? Also HDMS are for quering Data, this should not impact your trading capabilities |
¿ªÔÆÌåÓýWell, a trading algorithm based on realtime tick-by-tick data can
have a problem if the time series has gaps or even ceases. On 08.07.2023 21:33, Gordon Eldest via
groups.io wrote:
|
I maybe wrong,but from what I see and practice: |
Thanks for all informations which I carefully collect.
Some further questions came up which I found no answer for: 1) Is it harmful to operate the Real account and Paper account simultaneously with RTD supply (on different or same assets) with 2 IBGW/TWS operating? 2) The IB support told me, that European exchange data (Market or History) are always delivered from Switzerland server, independent where my account is hosted at. ???? When I request EUREX realtime tick-by-tick data (and nothing else) the IBGW GUI tells me ??? ??? Market Data Farm????? ON:usfarm ??? ??? Historical Data Farm? ON:ushmds, ON:euhmds? or ON:ushmds, OFF:euhmds when disconnected ??? So it seems to me, that realtime tick-by-tick data is delivered by EUHMDS (I guess Switzerland) and not 'EUFARM' Then, according to Gordon's mail I have to keep (EU)HMDS alive, albeit I do not need historical data. 3) A good idea to test if the TWS API provides a more stable tick-by-tick data supply. The time-and-sales list would be fragmentary, otherwise. |
If your server has enough memory, running multiple TWS/IBGW simultaneously works just fine. And sharing the same market data subscription between a TWS/IBGW real and paper account is no problem either. But you might want to take a quick look at this article: Real-time tick-by-tick data feeds and subscriptions are very reliable and completely unaffected by occasional historical market data farm disconnects. We have never experienced any gaps in tick-by-tick data feeds as long as our clients were behaving correctly. You can find several posts related to tick-by-tick data in the group archive, some of them even with performance details (such as this one). Your questions made me curios and I ran some additional stats on our 2023 tick-by-tick real-time data feeds:
So here the fun part. Year-to-date 2023 we received:
In my book that qualifies for rock-stable, considering the monthly data charge is negligible. If you do experience any tick-by-tick data interruptions, I'd suggest the following next steps: This is my interpretation of what Gordon called in a different post "Respect the basic API concepts":
´³¨¹°ù²µ±ð²Ô |
That's impressive ´³¨¹°ù²µ±ð²Ô. That's good to know for tick by tick data, what about lvl 1 reqMktData? same stats? Would be interested to know your thoughts on orders and positions tracking please, as neither work reliably in my humble experience: - Positions can go wrong all of a sudden requiring a re-subscription or a full restart altogether, so I just end up proactively cancelling and re-subscribing at regular intervals, which I find dirty. - Order executions are difficult to track given they can be partially filled or the "Filled" status can not be triggered. So I essentially track the execution of the order using a "done" Event and a timeout (the order validity end time), and then check if order.filled has something in it, which I also find convoluted. Thanks. class Order_: def orderStatus(...): def execution(self, order: Order_, timeout: int): |
In general, reqMktData feeds seem to be quite stable and timely, too, John. Though we use them only to give context to our TickByTick and Level II data feeds, so we have less analysis for them. Keep in mind that most reqMktData feeds are aggregated over various time periods. As an example, here a few highlights from a quick review of our June 2023 five second real-time bars (the ones you request via ). We get those for 50+ instruments and I looked at the arrival delay. Basically "arrival time" minus "bar time plus bar width":
Our API clients are not impacted since we have our own implementation of ¡°Position¡± and ¡°PNL¡±. The IBKR implementations may make sense for human traders but never worked for us (even when they are correct). Our biggest problem is that PNL resets around midnight. We work in ¡°units¡± of CME futures trading sessions (17:00 to 16:00 US/Central next day) and API clients get confused when position PNL suddenly resets ¡°around midnight¡±. We have found execution reports, commission reports, and even order status updates to be very reliable and timely. Our (Java) framework is multi-threaded, entirely event driven, broken into many small focused domain classes, models, and controllers/managers. It is completely separate from and unaware of TWS API. A thin adapter layer translates abstract framework operations (such as placing orders) into actual TWS API requests. That layer also converts TWS API responses into framework events that are independent of TWS API. Certain framework events (such as market price update events) are broadcast so that position controllers can easily maintain their own notion of current PNL. We rarely have partial order fills, but TWS API order status events and execution reports are very accurate and timely so that position controllers can adequately model reality based on streams of order state, order status, execution and commission reports, and market price update events. The framework uses a domain/class/model hierarchy that looks something like this: Accounts ¡ú [1:*] Account ¡ú Positions ¡ú [0:*] Position ¡ú Trades ¡ú [0:*] Trade ¡ú Orders ¡ú [0:*] Order Our API clients never have to restart or resubscribe during the trading session in response to TWS API activities. There are, however, controlled automatic daily restarts of TWS and API clients during the one hour per day when Chicago futures markets are closed.
You need to make sure your client does not assume any order or timing of events (order state, order status, execution reports, errors), can tolerate the occasional duplication of updates, takes all events into consideration (not just order status), and does not block the TWS API callback thread. We make heavy use of the Java built-in concurrency features from , specifically the (a Java language concept, has nothing to do with CME future contracts). I believe some of those concepts are available in Python through the . Another good source for ideas how you can better structure your Python clients may be Ewald de Wit¡¯s project. But we are meandering away from the scope of this post and and the group. ´³¨¹°ù²µ±ð²Ô On Wed, Jul 12, 2023 at 02:13 PM, John wrote:
|
Thanks Jurgen for the detailed reply.
?uses a similar approach to mine, with the two below sets, and monitoring order.fills. Unsure why Ewald chose to isolate the 'Inactive' state rather than adding it to the DoneStates btw. ? ? DoneStates: ClassVar[Set[str]] = {'Filled', 'Cancelled', 'ApiCancelled'}
? ? ActiveStates: ClassVar[Set[str]] = {'PendingSubmit', 'ApiPending', 'PreSubmitted', 'Submitted'} I don't like the asyncio module, and prefer to use a tailored combinations of Threads, Events and Timers, but we are essentially doing the same thing. I will play with the??to see if it adds any value over my current setup. I also trade futures and restart daily after the close, "units" that's a very interesting concept. I also considered monitoring positions myself, deducting them from order status updates, especially useful when 2 strategies trade the same contract on the same account, it allows differentiation. However I just preferred to avoid it so far in order to keep no stored info whatsoever on the client side, and rely solely on the server side info at all times. Indeed not the topic of this thread, thanks for sharing insights anyways, much appreciated. |