Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: build problem with cppclient
Yes, that's right. I'm guessing you didn't change what you thought you changed. Here's a step by step if you want to try again:
Or, as someone else suggested in the other thread, you can build the Intel sources directly (I won't outline that process). That should get you started. Are you using Windows System for Linux or something? Not sure what to say then... I don't use it. Maybe someone else can help you troubleshoot if that's the case. Good luck. |
Re: build problem with cppclient
Thank you all for your help and information.
I tried the mods to compilation, packages, makefiles mentioned without any change in the outcome. In fact it looks like the library is not a shared object at all ??? :: file !$ ??? file lib/libbid.so ??? lib/libbid.so: PE32+ executable (DLL) (console) x86-64, for MS Windows, 18 sections :: ldd lib/libbid.so ?? ?not a dynamic executable Looking at the elf file header shows there is no header ??? :: elfedit --input-mach x86_64 --output-mach x86_64 --input-type dyn --output-type dyn lib/libbid.so ??? elfedit: Error: lib/libbid.so: Failed to read ELF header I'm now at best confused because lib/libbid.so seems to be a windows dll according to the file command. Certainly it is not a linkable shared object. So, if anyone has successfully compiled and run the cppclient would you please examine your lib/libbid.so and see if you see the same data? |
Re: Having trouble submitting ZT (2 yr treas) futures orders thru API.
On Fri, 16 Jun 2023 16:04:22 +0000 Lou Dudka loududka@... wrote:
BTW, I also just tried w/ 981 and the bracket went through. Which makes me think that you might try updating the API version you're using (not just TWS/IBGW). I'm sure you're aware that the API itself gets fixed and changes as time goes by. Good luck. |
Re: No response from scanner
Thanks, ´³¨¹°ù²µ±ð²Ô.
The API and gateway logs don't show any data or errors (although we had some gateway logs from the day it worked). We're raising a ticket with IBKR. My best hypothesis at the moment is that we might have hit a limit on scanners even though the original ones were cancelled and the clients killed[^0] -- does that chime with anyone else's experience/expectations? If so, is there an easy fix? [^0]: While I often felt like doing this in my freelancing days, I should stress that no humans were harmed in the production of this bug. |
Re: Error - 2157
¿ªÔÆÌåÓýmy bet is that it's something internal to IB.? How about just setting up a reset loop with a count. So if you hit an error like this one log it, and retry the connection n times. If you blow the n times then shut down the connection gracefully and search for your towel.
??? On 6/15/23 01:43, A.R.SYD wrote:
|
Error - 2157
Hello everyone, Upon launching my trading app right before the market opened, the connection was established without any issues. However, after a few hours (during active market hours), while our app was functioning smoothly, an unexpected occurrence took place. I encountered the following errors in my app log: Any ideas about the type of this error? And, how to deal with it?
|
Re: Tws Connection status monitoring
On Wed, Jun 14, 2023 at 11:39 PM, David Walker wrote:
I couldn't get your new version to work until I moved the But yeah... I'm glad the problem is resolved. On Wed, Jun 14, 2023 at 11:00 PM, ´³¨¹°ù²µ±ð²Ô Reinold wrote:
Me too... that was fun. |
Re: Tws Connection status monitoring
¿ªÔÆÌåÓýOf course. Thanks ´³¨¹°ù²µ±ð²Ô and buddy.? ? I had been trying to establish the reader thread after connecting (not shown in the previous code I posted) rather than prior ¨C an approach which worked in my previous architecture, but obviously not when waiting for a callback. Silly mistake!? ? Here¡¯s the full updated code which works fine: ? import threading ? ? From: [email protected] <[email protected]> On Behalf Of ´³¨¹°ù²µ±ð²Ô Reinold via groups.io
Sent: Thursday, June 15, 2023 9:01 AM To: [email protected] Subject: Re: [TWS API] Tws Connection status monitoring ? There we have it, Dave. Let me see whether I can put the pieces together for you:
Your approach would work just fine in a three-thread approach where EWrapper and EClient run in two separate threads (plus a third thread for EReader). That is the typical TWS API Java setup and has the advantage that callback processing continues, even if the application thread is very busy or preoccupied with a long blocking operation (say spends time reading or writing a file, or god-forbid, does a sleep()). Depending on your design preference you'd take one of two routes:
I simply added this to your code and it worked right away: ??? def processTwsCallbacks(self): |
Re: Tws Connection status monitoring
There we have it, Dave. Let me see whether I can put the pieces together for you:
Your approach would work just fine in a three-thread approach where EWrapper and EClient run in two separate threads (plus a third thread for EReader). That is the typical TWS API Java setup and has the advantage that callback processing continues, even if the application thread is very busy or preoccupied with a long blocking operation (say spends time reading or writing a file, or god-forbid, does a sleep()). Depending on your design preference you'd take one of two routes:
I simply added this to your code and it worked right away: ??? def processTwsCallbacks(self):??????? self.run() ??? def open_connection(self): ??????? self.connection_error = False ??????? self.event_nextValidId_callback.clear() ??????? self.connect("127.0.0.1", self.port, self.client_id) ??????? callbackThread = threading.Thread( target=self.processTwsCallbacks, daemon=True ) ??????? callbackThread.start() This is only a rough outline. Keep in mind that I am not a Python practitioner and that there may be more to the three-thread solution than just starting self.run() in a separate thread. But It will be the more performant solution and callbacks will be performed much more timely. Hope this helps. I learned something new. ´³¨¹°ù²µ±ð²Ô |
Re: Tws Connection status monitoring
On Wed, Jun 14, 2023 at 07:24 PM, buddy wrote:
Sorry, this should be between the client and reader. But, the set and wait are called from the same thread of Dave's example and so all that's accomplished is deadlock. |
Re: Tws Connection status monitoring
On Wed, Jun 14, 2023 at 06:12 PM, ´³¨¹°ù²µ±ð²Ô Reinold wrote:
If you mean between the client and wrapper then I'd say yes. |
Re: Tws Connection status monitoring
On Wed, Jun 14, 2023 at 06:12 PM, ´³¨¹°ù²µ±ð²Ô Reinold wrote:
Hard to say since I think it depends on the overall context and mostly on what the program is meant to accomplish. For example, is it meant to be long lived or just do some processing and exit? What are the real-time requirements? I could also envision simply setting a member to Not sure there are simple answers in this respect. |
Re: Tws Connection status monitoring
Would Event objects provided bz the asyncio package work better here (IBKR suggests asyncio and ib_insync is built upon it) ? The goal, as I understand it, is to fully comply with the IBKR TWS API (as described in the section) and to block the main thread from making any API requests until:
So the connect() call needs to create some kind of event object that can be used to block the main thread until the NextValidID can release the wait block. As a matter of practice, our (Java) based connect logic waits for the nextValidId() and managedAccounts() callbacks, since our clients cannot do any meaningful work until both have arrived. ´³¨¹°ù²µ±ð²Ô
|
Re: Tws Connection status monitoring
On Wed, Jun 14, 2023 at 04:42 PM, ´³¨¹°ù²µ±ð²Ô Reinold wrote:
That's already happening via the base classes. Unfortunately, by calling the main thread itself (which should receive the callback is blocked) and then immediately throws a ConnectionError as soon as possible. Dave, it's not clear what you're trying to accomplish by using the threading event. Threading events are a mechanism for IPC (inter-process communication) and meant to communicate between threads, but you don't start any more threads of your own. Why not try getting rid of that stuff and just call |
Re: Tws Connection status monitoring
Unfortunately I am not Python literate enough to give you concrete help, Dave. But on the surface, your approach looks fine. I am wondering, though, whether there is some adverse interaction between the call to? self.event_nextValidId_callback.wait() and the ability of your client to process incoming TWS API messages. You say "Market data connection callbacks (2104, 2106, 2158) are shown in the IBG API log (but not received by the client)" which makes me wonder whether messages from TWS/IBGW get processed. Not sure whether that happens behind the scene, but wouldn't you have to start the message reader in a separate thread as it is described in the chapter? ´³¨¹°ù²µ±ð²Ô Hi ´³¨¹°ù²µ±ð²Ô (and others), |
Re: No response from scanner
Along your questions, I'd make sure that TWS/IBGW does indeed receive the requests and check what, if anything, is returned. So enable API logging in TWS/IBGW, run your program, decrypt the the API log in TWS/IBGW and check what the request looks like from the TWS/IBGW side. The log entry for a successful request/response looks like this: 15:15:16:088 <- 22-10000001-20-STK-STK.US.MAJOR-MOST_ACTIVE_AVG_USD--------------0------15:15:16:568 -> --..20-3-10000001-20-0-756733-SPY-STK--0--SMART-USD-SPY-SPY-SPY----- ... truncated ... Assuming you see the incoming request but no response, I'd look at the TWS/IBGW log. It is verbose, cryptic, and complex, but you might see an internal error message in case you are triggering some kind of issue in TWS/IBGW. In any case, this would probably be a case for a trouble ticket with IBKR. In case there is some kind of response, you'd obviously need to check in your own program. One area to check is error reporting. You seem to be getting the "regular" error callbacks, but EWrapper actually has three different versions of the error() callback method. ´³¨¹°ù²µ±ð²Ô On Wed, Jun 14, 2023 at 08:43 AM, <unclekensson@...> wrote:
I couldn't get the java client working (which is my problem, obviously), but I did manage to get a python client using ibsync up and running. |
Re: Tws Connection status monitoring
Hi ´³¨¹°ù²µ±ð²Ô (and others),
Thanks for your comments on this, as helpful as always.? I'm experiencing a similar absence of the??callback, and have not been able to successfully troubleshoot it. On calling connect(),
I would really appreciate any help on this and hope I'm not missing something really obvious!.? Unil recently I have used other connection verification procedures which have largely worked fine; it is only since updating to using nextValidId that I have encountered this. Dave import threading ? ? ? ??if not self.event_nextValidId_callback.wait(120) or self.connection_error: [apologies if the code doesn't come through properly formatted] |
Re: No response from scanner
I couldn't get the java client working (which is my problem, obviously), but I did manage to get a python client using ibsync up and running.
As far as I can see, it behaves in exactly the same way: * it's definitely connected, other queries go through fine; * the request is definitely reaching IB, because if I send a scan code like "NONSENSE", it returns an error; cancelling the scanner also works; * no scan data is returned for a correct request My question is really, how do I even go about trouble-shooting this? As you say, ´³¨¹°ù²µ±ð²Ô, it's a pretty simple scanner and (if I've read your message correctly) there's nothing wrong with the message reaching IB -- which fits with it having worked for a while last week. Has anyone come across situations where a request is apparently mothballed rather than processed? Could there be some sort of problem with the account that causes a silent fail rather than an error? What would you try? |
Re: build problem with cppclient
Btw, searching around revealed where the same failed binutils assertion yielded a dangerous relocation and linker core dump. It certainly seems the problem is due to linking intermediate object files created with different binutils. I agree with the github comment that says:
Fwiw, IDK why the IB SDK is distributing a pre-built library (either .a or .so). The only reason I can fathom is that they've modified the reference implementation but this strikes me as unlikely. Anyway... This is not best practice as far as I know, C/C++ is not "write once run anywhere". IMHO they should include the source (but this would complicate the makefile a bit). Or they should instruct the user to use either... their own system packages or build the stuff from Intel. Maybe they'll do this in the future but beware for now. |