¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date

Re: Edge browser says Client Portal API is not secure

 

Hi Brian,

It is secure on localhost. Using such self-signed certs are at least as secure as the CA signed ones, since it uses the same encryption technology. The self-signed certs are just not publicly trusted by EVERYONE during a??You may add your to the browser's root certificate store, if that red sign bothers you. Maybe you could use rather tool like mkcert to create one and you may use it with the Client gateway app. Look for the jks file in app and replace it with one created by mkcert.

We use such self-signed cert mechanism for our app (quantdroid.com) in the localhost communication. Even the communication is only on localhost, and such self-signed certs are mostly used nowadays, because there are browsers like Chrome (maybe chromium based, so the Edge) that by default enforces https communication (and CORS mechanism) and it would be an extra effort for the users (~mostly developers who uses them) to start the browser in insecure mode or hack it with settings.

hope it helps,
David


Re: Confusion between "adjustedStopPrice" and "adjustedTrailingAmount" when attaching "Adjusted to Trail" to a Stop order.

 

Yeah, you are right, apologies for pushing further confusion about this topic, I should have been more careful commenting on a feature that I only played around with too little to fully understand.


--
Best,
DS


Edge browser says Client Portal API is not secure

 

I'm making the transition from TWS API to Client Portal API. When I login to the Edge browser says Client Portal API is not secure. Why? Does this even matter? If it does matter, how can I fix this?

Other details: OpenJDK 11 from Microsoft (not Oracle). Paper trading account, for the time being (while the new app is developed). Windows 11.


Re: Impossible to reconnect after TWS restart, please help!

 

That shouldn't be too hard. Something like this:
  • Pick a good time for TWS/IBKR restart based upon the trading schedule for the instruments you are working with. For example some time between 16:00 and 17:00 US/Central for Chicago traded futures (say 16:30) or after 20:00 US/Eastern for NYC traded stocks (say 20:30). Keep an eye on the IBKR daily reset/maintenance window for your region and stay away from that.
  • Start your client a little before trading starts for the instruments you are interested in.
  • At client start, make calls to for all instruments your client works with. That way, you get fresh Contract objects that you can use for all requests that take a Contract parameter and you know the actual trade schedule for that day (and the next few days). That takes care of any last minute exchange hour changes or holiday hours.
  • Now you know the time when trading ends and you can stop your client shortly after hat time (but before your scheduled TWS/IBGW restart). Your client can save enough state so that it can start again before the next session.
  • Any error 502 received before markets close is unscheduled should probably trigger some kind of alert and possible needs some kind of manual interaction. There are ways to automate TWS/IBGW and client restart (see IBC for example) should this really happen, but you may need to provide at least 2FA login authorization (that can be with IBKR Key on a mobile device).
´³¨¹°ù²µ±ð²Ô


On Tue, Nov 21, 2023 at 08:11 PM, <makeitrain512@...> wrote:
Hey there Jurgen, thanks a lot for your input, it has really helped me see this problem in a different way.?

What's the best way I could approach a scheduled full disconnect right before TWS restarts and the make a fresh new connection after TWS has restarted ?
I imagine this is what most people do, instead of having to deal with a reconnection because of all the issues that arise from it.

Thanks Jurgen!


Re: Impossible to reconnect after TWS restart, please help!

 

Hey there Jurgen, thanks a lot for your input, it has really helped me see this problem in a different way.?

What's the best way I could approach a scheduled full disconnect right before TWS restarts and the make a fresh new connection after TWS has restarted ?
I imagine this is what most people do, instead of having to deal with a reconnection because of all the issues that arise from it.

Thanks Jurgen!


Re: Impossible to reconnect after TWS restart, please help!

 

Thanks Gordon!

I will take @btw advice as you say.?

Your opinion is exactly why I am in this problem:
?BTW there are no reason your connection broke unless TWS restart which is a different issue.
The fact that I need my program to go through the required TWS restart is what's got me struggling with this issue, from what you and Jurgen told me I think?
the best solution is to have my program disconnect right before TWS restarts and then proceeds to make a fresh new connection after TWS has restarted.?
Any advice on what the best approach on this would be ??


Re: Impossible to reconnect after TWS restart, please help!

 

I have followed this post for a while now. Gordon and btw provided a lot of great and relevant advice already, but what you (makeitrain512) are trying to do is pretty advanced. I am wondering whether there are simpler ways to achieve your goal.

You will find many more corner cases that you have not even through about before your reconnect logic will work flawlessly. What if 502 was caused by the daily TWS/IBGW restart? So there may be quite some time before TWS/IBGW can even accept a new socket connection, especially if you run the "latest" TWS/IBGW version that occasionally updates itself during restarts. Or what if TWS/IBGW do not restart properly so a reconnect will not be possible until you manually intervene?

And when you are done with reconnects working properly, you have to reestablish all data feeds and subscriptions your client had active before the 502 disconnect. Depending on how you have structured your code, that might mean that you even have to use the exact same requestIds the client had used originally so that TWS/IBGW responses through the new connection get handled correctly by your client. So you will need a solid and very layered design such as an API Controller ontop of an API Adapter. The adapter would handle all the low-level stuff such as the network socket, the reader thread, and reconnects while the controller would hide all API details from the client (such as requestIds) know about all active subscriptions, and would transparently reestablish the feeds once the reconnect was successful.

And you might have to inform your client or the trading logic about the fact that a chunk of market data was missing during the time it took to reconnect or that possibly some orders got filled or cancelled while that happened. That can all be done, but there will still be a lot of work ahead of you.

@btw made a great point that you might want to consider. Other than the daily TWS/IBGW restarts (that you can completely control when they happen), TWS/IBGW never really disconnect your client as long as your compute platform is stable and your network connection solid. Maybe an approach like this is much easier and meets you requirements as well:
  • you configure TWS/IBGW such that they restart shortly after the market for the instruments you are trading closes (regular or extended hours). Just make sure that you stay away from the daily IBKR maintenance and reset window.
  • client connects to TWS/IBGW just before the market (or pre-market) opens and stays connected throughout the trading session
  • after the end of the session, client either exits well before TWS/IBGW restart or takes the 502 disconnect caused by the TWS/IBGW restart as a sign that it is time to wrap up
  • if your client experiences an 502 during the trading session (extremely unlikely), send an alert and handle the case manually.

You could even design your client such that it always keeps enough state on permanent storage that it can restart after a 502 disconnect and pickup right where it left off. All of these will probably take a fraction of the effort than getting the transparent reconnect work flawlessly.

Just a thought,

´³¨¹°ù²µ±ð²Ô

On Tue, Nov 21, 2023 at 04:14 PM, Gordon Eldest wrote:

@btw give the best path:
you should start from a working example and increase complexity gradually. Splitting issues to do small studies set, one topic at a time,? then assemble what mastered from each study, minded with the principle "divide an conquer".

Opinion:
- your reconnect() method is either too complex or not enough, so make it simpler or remove the concept of reconnect().
If your connection is broken prematurely you cannot even assume that received messages are consistent, better throw away all of them.? BTW there are no reason your connection broke unless TWS restart which is a different issue.
- what you want to do need that you study the code in and around EReader, and see how to .join() it to be sure you never have more than 1 thread running it at same time.
disconnect() should be enough to exit the EReader thread by exiting the while loop, as long as it's not the case, you probably have a racing issue. and/or need to study isConnected()


Re: Impossible to reconnect after TWS restart, please help!

 

@btw give the best path:
you should start from a working example and increase complexity gradually. Splitting issues to do small studies set, one topic at a time,? then assemble what mastered from each study, minded with the principle "divide an conquer".

Opinion:
- your reconnect() method is either too complex or not enough, so make it simpler or remove the concept of reconnect().
If your connection is broken prematurely you cannot even assume that received messages are consistent, better throw away all of them.? BTW there are no reason your connection broke unless TWS restart which is a different issue.
- what you want to do need that you study the code in and around EReader, and see how to .join() it to be sure you never have more than 1 thread running it at same time.
disconnect() should be enough to exit the EReader thread by exiting the while loop, as long as it's not the case, you probably have a racing issue. and/or need to study isConnected()


Re: Concept of Data Lines

 

Not surprising, hence the recommendation from @Hilmar,

We don't know your testing condition and benchmark. Keep in mind that even a few instruments are traded only once a day. (or even not at all!), and also that the time to assemble and process your order is something to factor in too.
So 4 aggregations/second won't change that much. In my limited experience there generally are only about 1000 US Stocks really can go beyond 4 tick/sec
Try APPL on friday at 15:45, or on Forex pair like USD/EUR 10 seconds after a speech from Powell or publication of CPI that didn't follow predicted values.

reqMktData with 4 aggregations second (stocks) or faster on other classes had most probably be designed thinking that it's enough to take a decent decisions and keep IBKR IO pace under control, and it most probably do both efficiently.
Rogers


Re: Impossible to reconnect after TWS restart, please help!

 

I did a test by running my python program with TWS offline and the results are as follows:?

1 - From line 1 to 89 TWS was offline so it was not able to connect with anything.?
2- Proceed to login into TWS
3 - From line 90 to 98 the program is able to connect to TWS and the Ereader thread is started
4- On line 109 I get an error saying the socket is either closed or broken
5 - at line 113 the Ereader thread is finished

and this process goes on and on forever, so the readers thread is starting and finishing.?

I have not been able to figure out what the number? after setConnState 1810740610832 is, everytime there is a new connection this number is different, I have a theory that if im able to refresh this number after a new connection attempt I will be able to succeed in reconnecting.

2023-11-21 12:25:40.272 - INFO ? ?- MainThread - paper_trading.py:41 [start] - Starting host: 127.0.0.1 port: 7497
2023-11-21 12:25:40.273 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: None -> 0
2023-11-21 12:25:40.273 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:25:42.301 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 1
2023-11-21 12:25:42.301 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:25:42.302 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:25:42.302 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:25:42.302 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:25:43.312 - DEBUG ? - MainThread - connection.py:88 [sendMsg] - exception from sendMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988D0980>)
2023-11-21 12:25:43.312 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:25:43.312 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:25:43.313 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 0
2023-11-21 12:25:43.313 - INFO ? ?- MainThread - client.py:217 [disconnect] - disconnecting
2023-11-21 12:25:43.313 - DEBUG ? - MainThread - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:25:43.313 - DEBUG ? - MainThread - connection.py:64 [disconnect] - disconnected
2023-11-21 12:25:43.314 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: False
2023-11-21 12:25:43.314 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: None -> 0
2023-11-21 12:25:43.315 - INFO ? ?- MainThread - client.py:206 [connect] - could not connect
2023-11-21 12:25:43.315 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 0
2023-11-21 12:25:43.315 - DEBUG ? - Thread-1 (run) - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: None
2023-11-21 12:25:43.317 - INFO ? ?- MainThread - ibstore.py:755 [start] - START data: None broker: None
2023-11-21 12:25:43.317 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: None
2023-11-21 12:25:43.317 - DEBUG ? - Thread-1 (run) - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 0
2023-11-21 12:25:53.318 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:25:55.349 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 1
2023-11-21 12:25:55.349 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:25:55.349 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:25:55.349 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:25:55.349 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:25:56.357 - DEBUG ? - MainThread - connection.py:88 [sendMsg] - exception from sendMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988D3D00>)
2023-11-21 12:25:56.357 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:25:56.357 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:25:56.358 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 0
2023-11-21 12:25:56.358 - INFO ? ?- MainThread - client.py:217 [disconnect] - disconnecting
2023-11-21 12:25:56.358 - DEBUG ? - MainThread - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:25:56.358 - DEBUG ? - MainThread - connection.py:64 [disconnect] - disconnected
2023-11-21 12:25:56.359 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: False
2023-11-21 12:25:56.360 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: None -> 0
2023-11-21 12:25:56.360 - INFO ? ?- MainThread - client.py:206 [connect] - could not connect
2023-11-21 12:25:56.360 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 0
2023-11-21 12:26:06.361 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:26:08.390 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 1
2023-11-21 12:26:08.390 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:26:08.390 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:26:08.390 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:08.390 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:09.394 - DEBUG ? - MainThread - connection.py:88 [sendMsg] - exception from sendMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988D3C40>)
2023-11-21 12:26:09.394 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:09.394 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:09.395 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 0
2023-11-21 12:26:09.395 - INFO ? ?- MainThread - client.py:217 [disconnect] - disconnecting
2023-11-21 12:26:09.395 - DEBUG ? - MainThread - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:26:09.395 - DEBUG ? - MainThread - connection.py:64 [disconnect] - disconnected
2023-11-21 12:26:09.396 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: False
2023-11-21 12:26:09.397 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: None -> 0
2023-11-21 12:26:09.397 - INFO ? ?- MainThread - client.py:206 [connect] - could not connect
2023-11-21 12:26:09.397 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 0
2023-11-21 12:26:19.398 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:26:21.417 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 1
2023-11-21 12:26:21.417 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:26:21.417 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:26:21.417 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:21.418 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:22.420 - DEBUG ? - MainThread - connection.py:88 [sendMsg] - exception from sendMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988D08C0>)
2023-11-21 12:26:22.420 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:22.420 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:22.421 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 0
2023-11-21 12:26:22.421 - INFO ? ?- MainThread - client.py:217 [disconnect] - disconnecting
2023-11-21 12:26:22.421 - DEBUG ? - MainThread - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:26:22.421 - DEBUG ? - MainThread - connection.py:64 [disconnect] - disconnected
2023-11-21 12:26:22.421 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 0, connConnected: False
2023-11-21 12:26:22.422 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: None -> 0
2023-11-21 12:26:22.422 - INFO ? ?- MainThread - client.py:206 [connect] - could not connect
2023-11-21 12:26:22.422 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 0
2023-11-21 12:26:32.423 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 0 -> 1
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:32.424 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 17
2023-11-21 12:26:32.425 - DEBUG ? - MainThread - decoder.py:1370 [interpret] - no fields
2023-11-21 12:26:33.438 - DEBUG ? - MainThread - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0780>)
2023-11-21 12:26:33.438 - DEBUG ? - MainThread - client.py:180 [connect] - ANSWER b''
2023-11-21 12:26:33.438 - DEBUG ? - MainThread - decoder.py:1370 [interpret] - no fields
2023-11-21 12:26:34.447 - DEBUG ? - MainThread - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0580>)
2023-11-21 12:26:34.447 - DEBUG ? - MainThread - client.py:180 [connect] - ANSWER b''
2023-11-21 12:26:34.447 - DEBUG ? - MainThread - decoder.py:1370 [interpret] - no fields
2023-11-21 12:26:34.621 - DEBUG ? - MainThread - connection.py:131 [_recvAllMsg] - len 30 raw:b'\x00\x00\x00\x1a176\x0020231121 12:26:35 MST\x00'|
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - client.py:180 [connect] - ANSWER b'\x00\x00\x00\x1a176\x0020231121 12:26:35 MST\x00'
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - comm.py:67 [read_msg] - read_msg: size: 26
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - client.py:183 [connect] - size:26 msg:b'176\x0020231121 12:26:35 MST\x00' rest:b''|
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - client.py:185 [connect] - fields (b'176', b'20231121 12:26:35 MST')
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - client.py:191 [connect] - ANSWER Version:176 time:b'20231121 12:26:35 MST'
2023-11-21 12:26:34.622 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 2
2023-11-21 12:26:34.623 - DEBUG ? - Thread-2 - reader.py:33 [run] - EReader thread started
2023-11-21 12:26:34.623 - INFO ? ?- MainThread - client.py:200 [connect] - sent startApi
2023-11-21 12:26:34.623 - INFO ? ?- MainThread - client.py:94 [logRequest] - REQUEST startApi {}
2023-11-21 12:26:34.623 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 2, connConnected: True
2023-11-21 12:26:34.623 - INFO ? ?- MainThread - client.py:83 [sendMsg] - SENDING startApi b'\x00\x00\x00\t71\x002\x0051\x00\x00'
2023-11-21 12:26:34.624 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:34.624 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:34.624 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:34.624 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:34.624 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 13
2023-11-21 12:26:35.150 - DEBUG ? - Thread-2 - connection.py:131 [_recvAllMsg] - len 0 raw:b''|
2023-11-21 12:26:35.150 - DEBUG ? - Thread-2 - connection.py:108 [recvMsg] - socket either closed or broken, disconnecting
2023-11-21 12:26:35.150 - DEBUG ? - Thread-2 - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:26:35.150 - DEBUG ? - Thread-2 - connection.py:64 [disconnect] - disconnected
2023-11-21 12:26:35.151 - DEBUG ? - Thread-2 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:35.151 - DEBUG ? - Thread-2 - reader.py:55 [run] - EReader thread finished
2023-11-21 12:26:44.625 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:26:44.626 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 2 -> 1
2023-11-21 12:26:44.626 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:44.627 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 17
2023-11-21 12:26:44.628 - DEBUG ? - MainThread - decoder.py:1370 [interpret] - no fields
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - connection.py:131 [_recvAllMsg] - len 30 raw:b'\x00\x00\x00\x1a176\x0020231121 12:26:45 MST\x00'|
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - client.py:180 [connect] - ANSWER b'\x00\x00\x00\x1a176\x0020231121 12:26:45 MST\x00'
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - comm.py:67 [read_msg] - read_msg: size: 26
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - client.py:183 [connect] - size:26 msg:b'176\x0020231121 12:26:45 MST\x00' rest:b''|
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - client.py:185 [connect] - fields (b'176', b'20231121 12:26:45 MST')
2023-11-21 12:26:44.629 - DEBUG ? - MainThread - client.py:191 [connect] - ANSWER Version:176 time:b'20231121 12:26:45 MST'
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 2
2023-11-21 12:26:44.630 - DEBUG ? - Thread-3 - reader.py:33 [run] - EReader thread started
2023-11-21 12:26:44.630 - INFO ? ?- MainThread - client.py:200 [connect] - sent startApi
2023-11-21 12:26:44.630 - INFO ? ?- MainThread - client.py:94 [logRequest] - REQUEST startApi {}
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 2, connConnected: True
2023-11-21 12:26:44.630 - INFO ? ?- MainThread - client.py:83 [sendMsg] - SENDING startApi b'\x00\x00\x00\t71\x002\x0051\x00\x00'
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:44.630 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 13
2023-11-21 12:26:44.634 - DEBUG ? - Thread-3 - connection.py:131 [_recvAllMsg] - len 19 raw:b'\x00\x00\x00\x0f15\x001\x00DU7637496\x00'|
2023-11-21 12:26:44.634 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 19
2023-11-21 12:26:44.634 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 15
2023-11-21 12:26:44.634 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:15 msg.size:15 msg:|b''| buf:||
2023-11-21 12:26:44.635 - DEBUG ? - Thread-3 - connection.py:131 [_recvAllMsg] - len 11 raw:b'\x00\x00\x00\x079\x001\x0022\x00'|
2023-11-21 12:26:44.635 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 11
2023-11-21 12:26:44.635 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 7
2023-11-21 12:26:44.635 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:7 msg.size:7 msg:|b''| buf:||
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - connection.py:131 [_recvAllMsg] - len 61 raw:b'\x00\x00\x0094\x002\x00-1\x002104\x00Market data farm connection is OK:usfarm.nj\x00\x00'|
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 61
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 57
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:57 msg.size:57 msg:|b''| buf:||
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - connection.py:131 [_recvAllMsg] - len 293 raw:b'\x00\x00\x0084\x002\x00-1\x002104\x00Market data farm connection is OK:cashfarm\x00\x00\x00\x00\x0064\x002\x00-1\x002104\x00Market data farm connection is OK:usfarm\x00\x00\x00\x00\x0064\x002\x00-1\x002106\x00HMDS data farm connection is OK:cashhmds\x00\x00\x00\x00\x0044\x002\x00-1\x002106\x00HMDS data farm connection is OK:ushmds\x00\x00\x00\x00\x0094\x002\x00-1\x002158\x00Sec-def data farm connection is OK:secdefil\x00\x00'|
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 293
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 56
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:56 msg.size:56 msg:|b'\x00\x00\x0064\x002\x00-1\x002104\x00Market data farm connection is OK:usfarm\x00\x00\x00\x00\x0064\x002\x00-1\x002106\x00HMDS data farm connection is OK:cashhmds\x00\x00\x00\x00\x0044\x002\x00-1\x002106\x00HMDS data farm connection is OK:ushmds\x00\x00\x00\x00\x0094\x002\x00-1\x002158\x00Sec-def data farm connection is OK:secdefil\x00\x00'| buf:||
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 54
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:54 msg.size:54 msg:|b'\x00\x00\x0064\x002\x00-1\x002106\x00HMDS data farm connection is OK:cashhmds\x00\x00\x00\x00\x0044\x002\x00-1\x002106\x00HMDS data farm connection is OK:ushmds\x00\x00\x00\x00\x0094\x002\x00-1\x002158\x00Sec-def data farm connection is OK:secdefil\x00\x00'| buf:||
2023-11-21 12:26:44.640 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 54
2023-11-21 12:26:44.641 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:54 msg.size:54 msg:|b'\x00\x00\x0044\x002\x00-1\x002106\x00HMDS data farm connection is OK:ushmds\x00\x00\x00\x00\x0094\x002\x00-1\x002158\x00Sec-def data farm connection is OK:secdefil\x00\x00'| buf:||
2023-11-21 12:26:44.641 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 52
2023-11-21 12:26:44.641 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:52 msg.size:52 msg:|b'\x00\x00\x0094\x002\x00-1\x002158\x00Sec-def data farm connection is OK:secdefil\x00\x00'| buf:||
2023-11-21 12:26:44.641 - DEBUG ? - Thread-3 - comm.py:67 [read_msg] - read_msg: size: 57
2023-11-21 12:26:44.641 - DEBUG ? - Thread-3 - reader.py:46 [run] - size:57 msg.size:57 msg:|b''| buf:||
2023-11-21 12:26:45.645 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E08C0>)
2023-11-21 12:26:45.645 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:46.650 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:26:46.650 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:47.651 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0040>)
2023-11-21 12:26:47.651 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:48.654 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E08C0>)
2023-11-21 12:26:48.654 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:49.659 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:26:49.659 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:50.661 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0040>)
2023-11-21 12:26:50.661 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:51.673 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E08C0>)
2023-11-21 12:26:51.673 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:52.678 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:26:52.678 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:53.689 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0040>)
2023-11-21 12:26:53.689 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:54.631 - DEBUG ? - MainThread - client.py:145 [connect] - Connecting to 127.0.0.1:7497 w/ id:51
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 2 -> 1
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - client.py:162 [connect] - msg b'\x00\x00\x00\tv100..176'
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - client.py:164 [connect] - REQUEST b'API\x00\x00\x00\x00\tv100..176'
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:54.632 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:54.633 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 17
2023-11-21 12:26:54.634 - DEBUG ? - MainThread - decoder.py:1370 [interpret] - no fields
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - connection.py:131 [_recvAllMsg] - len 30 raw:b'\x00\x00\x00\x1a176\x0020231121 12:26:55 MST\x00'|
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - client.py:180 [connect] - ANSWER b'\x00\x00\x00\x1a176\x0020231121 12:26:55 MST\x00'
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - comm.py:67 [read_msg] - read_msg: size: 26
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - client.py:183 [connect] - size:26 msg:b'176\x0020231121 12:26:55 MST\x00' rest:b''|
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - client.py:185 [connect] - fields (b'176', b'20231121 12:26:55 MST')
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - client.py:191 [connect] - ANSWER Version:176 time:b'20231121 12:26:55 MST'
2023-11-21 12:26:54.635 - DEBUG ? - MainThread - client.py:78 [setConnState] - 1810740610832 connState: 1 -> 2
2023-11-21 12:26:54.635 - DEBUG ? - Thread-4 - reader.py:33 [run] - EReader thread started
2023-11-21 12:26:54.636 - INFO ? ?- MainThread - client.py:200 [connect] - sent startApi
2023-11-21 12:26:54.636 - INFO ? ?- MainThread - client.py:94 [logRequest] - REQUEST startApi {}
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - client.py:227 [isConnected] - 1810740610832 isConn: 2, connConnected: True
2023-11-21 12:26:54.636 - INFO ? ?- MainThread - client.py:83 [sendMsg] - SENDING startApi b'\x00\x00\x00\t71\x002\x0051\x00\x00'
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - connection.py:78 [sendMsg] - acquiring lock
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - connection.py:80 [sendMsg] - acquired lock
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - connection.py:91 [sendMsg] - releasing lock
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - connection.py:93 [sendMsg] - release lock
2023-11-21 12:26:54.636 - DEBUG ? - MainThread - connection.py:95 [sendMsg] - sendMsg: sent: 13
2023-11-21 12:26:54.690 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E08C0>)
2023-11-21 12:26:54.690 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:55.136 - DEBUG ? - Thread-4 - connection.py:131 [_recvAllMsg] - len 0 raw:b''|
2023-11-21 12:26:55.136 - DEBUG ? - Thread-4 - connection.py:108 [recvMsg] - socket either closed or broken, disconnecting
2023-11-21 12:26:55.136 - DEBUG ? - Thread-4 - connection.py:61 [disconnect] - disconnecting
2023-11-21 12:26:55.136 - DEBUG ? - Thread-4 - connection.py:64 [disconnect] - disconnected
2023-11-21 12:26:55.137 - DEBUG ? - Thread-4 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:55.137 - DEBUG ? - Thread-4 - reader.py:55 [run] - EReader thread finished
2023-11-21 12:26:55.695 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0600>)
2023-11-21 12:26:55.695 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:56.696 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:26:56.696 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:57.704 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E02C0>)
2023-11-21 12:26:57.704 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:58.717 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0600>)
2023-11-21 12:26:58.717 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:26:59.724 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:26:59.724 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:27:00.727 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E02C0>)
2023-11-21 12:27:00.727 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:27:01.737 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E0600>)
2023-11-21 12:27:01.737 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:27:02.742 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E19C0>)
2023-11-21 12:27:02.742 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0
2023-11-21 12:27:03.752 - DEBUG ? - Thread-3 - connection.py:111 [recvMsg] - socket timeout from recvMsg (<class 'TimeoutError'>, TimeoutError('timed out'), <traceback object at 0x000001A5988E02C0>)
2023-11-21 12:27:03.752 - DEBUG ? - Thread-3 - reader.py:39 [run] - reader loop, recvd size 0


Re: Retrieving status of a specific orderID through orderStatus or openOrder

 

Thanks Gordon and bespalex.?

The value of profit_order_ID was assigned outside of the wrapper but after following bespalex's suggestion to print its value within orderStatus, I found?that the assignment was not accessible from within the wrapper, probably because of some Pythonic error I am making.? So I ended up creating a workaround with openOrders instead and I'm able to get the order info I need...?

Chris??


Re: Impossible to reconnect after TWS restart, please help!

 

I would blend your code with the working code.? Add yours block by block until something doesn't work.
Or do nothing.? I can't remember a problem in 20+ years unless there's been a power failure.
Better to host at AWS or something if you need extreme connection/power reliability.? Also, use logic in your code that is robust to interruptions in data or order/position/portfolio callbacks.


Re: Correlate orders and fills from the API to those in Flex Report

 

You are right Juergen. great find (for me at least)!

I had been receiving daily flex reports since ancient times with OrderRefs filled without any additional settings until they stopped filling it a few months ago or so, so I was unaware that this would now need additional configuration and thought it went the way of the respective field not getting filled for any period exceeding the last trading date. This new configuration certainly sounds quite redundant to me since my explicit ordering of OrderRefs in the report column settings signals I want it filled, but well, I guess IB tried to further minimize the chance that this potentially dense data field inadvertently tax their system.

--
Best,
DS


Re: E-MINI reqTickByTick data parameters

 

¿ªÔÆÌåÓý

Oops, sorry I didn¡¯t notice also that you have

?

contract.lastTradeDateOrContractMonth = "202315";

?

This should be ¡°202312¡±, or ¡°20231215¡±.

?


Re: E-MINI reqTickByTick data parameters

fran
 

Thank you Richard as well.


Re: E-MINI reqTickByTick data parameters

fran
 

Thank you ´³¨¹°ù²µ±ð²Ô and Robby for your quick response. I followed your instructions and it worked.?


Re: Retrieving status of a specific orderID through orderStatus or openOrder

 

Why don't you print profit_order_ID right before 'if' to find out? Also they might be of different type, I'd check that too.


Re: Concept of Data Lines

 

Thank you for clarifying this, strangely I do not see much more incoming data messages when using TickByTick, so I am not sure how it saves the bandwidth for them, but lesson's learned.


Re: E-MINI reqTickByTick data parameters

 

Fran,

Try my way removing localSymbol. It works for me though I am using C#.


Re: E-MINI reqTickByTick data parameters

 

When you specify localSymbol you don't have to provide lastTradeDateOrContractMonth as well. But if you do, they have to match. You set lastTradeDateOrContractMonth to "202315", which is not even a real date in the first place.

I suggest you leave that field alone (that's what I do) or you'd have to provide the correct date of "20231215"

´³¨¹°ù²µ±ð²Ô


On Mon, Nov 20, 2023 at 08:48 PM, fran wrote:

Hi Richard, thank you for your answer. I tried your suggestion but I keep getting "Error. Id: 20004, Code: 200, Msg: No security definition has been found for the request".