开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: "438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ?

 

I just checked the Java TWS API documentation and it looks like the "438 : The application is now locked." error has been deprecated which is very unfortunate.

--


Re: "438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ?

 

Hi 闯ü谤驳别苍. Please apologize for the missing information. It is Java on Windows.

--


Re: "438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ?

 

Which API language and operating system has your client used for your tests?
?
?
On Thu, Feb 20, 2025 at 07:04 AM, Orionn wrote:

Can anyone confirm that the errors in the subject have been discontinued in recent API versions ?

I have performed the following tests:

1) TWS locked:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked"
- using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

2) client Id already in use:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id."
- using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

So it is clear that the issue is in the API, not in TWS.

The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use.

Can anyone confirm these findings ?

--


TWS 10.33 and 10.34 crashing on Windows and Mac OS

 

I am seeing crashes with TWS versions 10.33 and 10.34 on Windows and Mac OS.

TWS versions 10.33 and 10.34 are crashing on Windows 7 when exiting TWS. Windows displays a pop-up with "Trader Workstation stopped working" error.

TWS version 10.34 crashes on Mac OS X 10.14.6 right when it is starting. Identifier: com.install4j.5556-0173-2810-3400.22; Crashed Thread: 4 Java: JTS-Main; Exception Type: EXC_BAD_ACCESS (SIGABRT); Exception Codes: EXC_I386_GPFLT; Exception Note: EXC_CORPSE_NOTIFY

Is anyone else experiencing crashes and/or instability with TWS versions 10.33 and up on Windows and Mac OS ?

--


"438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ?

 

Can anyone confirm that the errors in the subject have been discontinued in recent API versions ?

I have performed the following tests:

1) TWS locked:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked"
- using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

2) client Id already in use:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id."
- using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

So it is clear that the issue is in the API, not in TWS.

The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use.

Can anyone confirm these findings ?

--


Re: Auto Restart & Auto Login w/ IB Gateway and Linux

 

Hi Brendan. See this:?
I think it's done by some members of this forum. Thank them ;)

On Mon, Feb 17, 2025 at 9:17?PM Brendan Lydon via <blydon12=[email protected]> wrote:
Hi,
?
I would like to reopen a thread on auto login, and auto restart for IB Gateway on Linux. I have been using TWS for my entire algorithmic trading journey only building strategies within the confines of the stock market's cash open (9:30am to 4pm) to keep systems running all day without needing many restart solutions and auto login credentials. But, now I want to run strategies all night long and for long periods of time. That is how I came across the benefits of using IB Gateway. I have built watchdogs for my applications to handle crashes from disconnecting from TWS, but TWS itself never crashed, only my application. But now I want to build algorithms to trade all through the night without much supervision with IB Gateway. I plan to continue using bash scripting within a linux machine for process monitoring & watchdogs. So to start, how can I enable auto login on IB gateway? What are the limitations you guys have come across? I already have set up a 5:15pm auto restart, as I have a futures trading algorithm backtested and ready to go throughout the night and non cash market hours, but I do not see a place for auto login, etc?
?
Thanks,
Brendan



--
Daniel


Re: Issue with order.orderId Returning 0 in reqCompletedOrders(true)

 

Yes indeed, the issue that Juergen touched here would make OrderId's pretty much useless?even if IB kept them because reqCompletedOrders returns indiscriminately, and inescapably, all today's completed orders in TWS, at least for all API clients and if asked properly, all manual orders too. So there would be no way to guarantee unique identification for completed orders using OrderIds anyway. (If there were an intention to maintain some symmetry between different order managing request branches, this call should perhaps have been called reqAllCompletedOrders or reqGlobalCompletedOrders in accord with reqAllOpenOrders or reqGlobalCancel, but apparently there's none such, so we have the most simple name here irrespective of the function it serves, simply because there are no other request methods for completed orders to differentiate).

Depending on your needs, there are a few methods to uniquely identify IBKR orders which are discussed in this group from time to time, so you might check out the search function to get a?grasp of prior art.





пн, 17 февр. 2025?г. в 20:26, 闯ü谤驳别苍 Reinold via <TwsApiOnGroupsIo=[email protected]>:

As @ds-avatar indicated, orderIDs have a limited shelf life. They are only meaningful as long as the order is active and only for the client (as in clientID) that created the order. Keep in mind that each clientID has its own (permanent) sequence of orderIDs, that orderIDs must strictly increase for each new order placed, and that orderIDs might have to be adjusted ("bound") when one client gets in contact with an active order of a different client.
?
That is why each order also has a permID. IBKR assigns it when the order is accepted and returns properly adjusted Order objects with the openOrder() callbacks. That is where you'd get the permID from )or anz other aspect of the order that was changed by IBKR or the exchange)
?
The permID is also used to relate execution and commission reports to an order.
?
闯ü谤驳别苍
?
?
On Mon, Feb 17, 2025 at 12:29 AM, <joshi.tarun3107@...> wrote:
Hello Folks,

I am encountering an issue where order.orderId is consistently returning 0 when making the following request:
reqCompletedOrders(true);


I'm currently using Paper Trading account.

This occurs specifically in the completedOrder(const Contract& contract, const Order& order, const OrderState& orderState) callback response.

Has anyone else experienced a similar issue or found a solution for this behavior?

Looking forward to your insights.




--
Best,
DS


Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor

 

any guide to run tws on arm tablet / smartphone??


Auto Restart & Auto Login w/ IB Gateway and Linux

 

Hi,
?
I would like to reopen a thread on auto login, and auto restart for IB Gateway on Linux. I have been using TWS for my entire algorithmic trading journey only building strategies within the confines of the stock market's cash open (9:30am to 4pm) to keep systems running all day without needing many restart solutions and auto login credentials. But, now I want to run strategies all night long and for long periods of time. That is how I came across the benefits of using IB Gateway. I have built watchdogs for my applications to handle crashes from disconnecting from TWS, but TWS itself never crashed, only my application. But now I want to build algorithms to trade all through the night without much supervision with IB Gateway. I plan to continue using bash scripting within a linux machine for process monitoring & watchdogs. So to start, how can I enable auto login on IB gateway? What are the limitations you guys have come across? I already have set up a 5:15pm auto restart, as I have a futures trading algorithm backtested and ready to go throughout the night and non cash market hours, but I do not see a place for auto login, etc?
?
Thanks,
Brendan


Re: Issue with order.orderId Returning 0 in reqCompletedOrders(true)

 

As @ds-avatar indicated, orderIDs have a limited shelf life. They are only meaningful as long as the order is active and only for the client (as in clientID) that created the order. Keep in mind that each clientID has its own (permanent) sequence of orderIDs, that orderIDs must strictly increase for each new order placed, and that orderIDs might have to be adjusted ("bound") when one client gets in contact with an active order of a different client.
?
That is why each order also has a permID. IBKR assigns it when the order is accepted and returns properly adjusted Order objects with the openOrder() callbacks. That is where you'd get the permID from )or anz other aspect of the order that was changed by IBKR or the exchange)
?
The permID is also used to relate execution and commission reports to an order.
?
闯ü谤驳别苍
?
?
On Mon, Feb 17, 2025 at 12:29 AM, <joshi.tarun3107@...> wrote:

Hello Folks,

I am encountering an issue where order.orderId is consistently returning 0 when making the following request:
reqCompletedOrders(true);


I'm currently using Paper Trading account.

This occurs specifically in the completedOrder(const Contract& contract, const Order& order, const OrderState& orderState) callback response.

Has anyone else experienced a similar issue or found a solution for this behavior?

Looking forward to your insights.




Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor

 

开云体育

Can I just add a minor clarification to 闯ü谤驳别苍’s post. [Actually, having written this I’m not sure it really clarifies anything, but I’ll send it anyway.]

?

TWS and Gateway 1034 still work perfectly well with the Oracle Java 8 runtime that has shipped with the installers for many prior versions. So I don’t think IBKR have made any changes at this stage to take advantage of post-Java 8 language developments. What they do is take account of the modular nature of Java 9 onwards. This requires additional qualifiers (--add-opens and –补诲诲-别虫辫辞谤迟蝉) in the Java command for each runtime module need by TWS/Gateway. And of course the runtime itself will have been greatly improved and optimised ‘under the hood’ between Java 8 and Java 17, so I expect performance to be somewhat better.

?

Having taken this initial step, my expectation is that IBKR will first extend Java 17 support to the Windows and macOS installers, and then start making use of the new language features that have accrued in Java 9 onwards where appropriate. I don’t expect a great deal of change in this regard: the old adage “if it ain’t broke don’t fix it” is good advice. But I’m not IBKR, so we’ll see…

?

Richard

?


Re: Issue with order.orderId Returning 0 in reqCompletedOrders(true)

 

I don't think IB keeps OrderId's for completed orders.

пн, 17 февр. 2025?г., 10:29 joshi.tarun3107 via <joshi.tarun3107=[email protected]>:

Hello Folks,

I am encountering an issue where order.orderId is consistently returning 0 when making the following request:
reqCompletedOrders(true);


I'm currently using Paper Trading account.

This occurs specifically in the completedOrder(const Contract& contract, const Order& order, const OrderState& orderState) callback response.

Has anyone else experienced a similar issue or found a solution for this behavior?

Looking forward to your insights.




--
Best,
DS


Issue with order.orderId Returning 0 in reqCompletedOrders(true)

 

Hello Folks,

I am encountering an issue where order.orderId is consistently returning 0 when making the following request:
reqCompletedOrders(true);


I'm currently using Paper Trading account.

This occurs specifically in the completedOrder(const Contract& contract, const Order& order, const OrderState& orderState) callback response.

Has anyone else experienced a similar issue or found a solution for this behavior?

Looking forward to your insights.




Re: ISSUES WITH SMOOTH FAILOVER IN TWS APPLICATION - IBKR SERVER CONECTION DROP.

 

I sincerely thank everyone for their valuable guidance on the design patterns I should follow to prevent discrepancies.


Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor

 

Since there was some interest in running TWS/IBGW on ARM (such as Raspberry Pi), here a quick update since the latest TWS/IBGW 1034 make this much more feasible.

Here a copy of my post in the IBC group:

==============================================

As Richard mentioned in this post, the Linux distributions of TWS/IBGW 10.34 now ship with a Java JRE17. That means that IBKR has made the appropriate changes in the source code so that TWS/IBGW now support the Java language changes introduced by Java 11 and Java 17.

That makes it much more feasible for TWS/IBGW on ARM devices, In fact, I was just now able to install and run TWS (not just IBGW) for the first time on my loyal but tired Raspberry Pi 2:
  • 900MHz quad-core ARM Cortex-A7 32bit CPU
  • 1GB RAM
  • Raspbian/Debian 12.9 (bookworm)

Before we go on, one quick disclaimer. TWS/IBGW have not been designed for the ARM architecture and their extensive dependence on Java 8 (until now) and Java FX2 features places significant (undocumented) requirements on the system, the Java JRE, and JavaFX . While running TWS/IBGW on ARM is an interesting exercise, seems to become quite stable, and will be useful in many scenarios, using them to trade in a live account is still a really bad idea.

With that out of the way, here the simple steps that I went through to bring up TWS. No modification of TWS scripts are required:

  • Install the BellSoft Full Java JRE 17.0.14 (in my case in /opt/Java/jre-17.0.14-full). JRE 21 will not work.

  • Install libgtk2.0 since TWS/IBGW need libgdk-x11-2.0.so.0. Most Linux versions now ship with GTK3 or GTK4

  • Download TWS from:

  • Install TWS with:

    app_java_home="/opt/Java/jre-17.0.14-full" sh tws-latest-standalone-linux-x64.sh

  • Run TWS with:
    JAVA_HOME="/opt/Java/jre-17.0.14-full" \
    ? ? INSTALL4J_JAVA_HOME="${JAVA_HOME}" \
    ? ? ? ? app_java_home="${JAVA_HOME}" \
    ? ? ? ? ? ? ? ? sh ~/Jts/1034/tws

That's it. It takes a while to start up (all spent in "Reading layout settings ..") but here it is ...

闯ü谤驳别苍

?

?


Re: ISSUES WITH SMOOTH FAILOVER IN TWS APPLICATION - IBKR SERVER CONECTION DROP.

 

In Software Engineering (and also in Automation) there is a concept called a Controller pattern. The best analogy is the clutch when you drive stick.
A controller has a:
- Resource - the object it controls
- Desired State: what it should be
- Actual State: what it currently is
The controller simply tries to issue actions to bring the actual state closer to the desired state.
?
In this case you need a double clutch as you will be driving a race car :)
?
- Position Controller
Resource: position (indexed by security)
Desired State: total # of contracts in a certain stock/security that you want to have
Actual State: sum(# of executions) + last valid position update (usually from startup/reconnect)
Action: your trading model changes the desired state only - it does not issue any orders; the position controller checks how much total qty is active in the Order Controller and taking the difference (desired vs actual - call it position error) it will issue new requests (to the Order Controller) to bring the number of active quantity in the market equal to the desired state. If it mistakenly overfills by "k" contracts (e.g. due to a bad algo in Order Controller), it will request a -k to the Order Controller. So it's self-healing to a certain degree.
?
- Order Controller
Resource: orders (indexed by security and an internal order request UUID from position controller)
Desired State: # total == # filled; you can go on a splurge with additional "desires": desired time (T), desired risk (max 4 ticks), active/passive, iceberg, VWAP etc..
Actual State: each order has # total quantity, # filled = 0 and # unfilled = # total as received from the initial request (coming from Position Controller) and then updated by subsequent API responses by adding up executions
Action: the Position Controller will ask for more exposure in the market, or will ask to reduce its exposure in the market by issuing specific requests to the Order Controller. In turn, the order controller will then issue new order(s) based on that. It could issue none initially if a desired start time is not there, etc.. Or it could issue less than the requested quantity in case of VWAP etc.. In the simple case it will just issue a single new order with total=request, filled=0, unfilled=request. A slightly more complex scenario it will modify an existing order.
As executions fill up, you update back the filled/unfilled parameters for that order id.
?
Each controller runs in it's own thread (or async routine) in parallel.
?
Now, addressing your use-case:
You request 10 desired state and you have 0 actual state in Position Controller.
Order Controller issues a new order with total qty=10 (still unfilled) associated with an internal id=0xdeadbeef.
You modify your request to 15 desired state and immediately disconnect.
Order Controller won't issue new orders or modify existing orders while disconnected.
You will have 15 in your desired state and a 0 in your actual state in the Position Controller.
You reconnect.
Once you're back up (regardless what happened in the market), you will synchronize positions and orders during startup / reconnect.
Now your Position Controller will suddenly be 15 desired state and 10 actual state.
Your Order Controller gets the list of active orders (some it knows based on internal UUID correspondence, some are maybe new, some are maybe missing).
There is 0 unfilled so initially Order Controller won't do anything. It will just remove the reference to the filled order under it's UUID 0xdeadbeef.
Next, Position Controller will issue a new request for 15-10=5 to Order Controller with an in internal id=0xaaaabbbb.
Order Controller will issue an order in the market with total qty 5.


Re: TWS & IBKR CONNECTION STATUS.

 

To check my internet connection I simply ping google.com. Very crude but does the trick for me.


Re: ISSUES WITH SMOOTH FAILOVER IN TWS APPLICATION - IBKR SERVER CONECTION DROP.

 

It looks like there's no way of deciding whether the order was actually modified without placing a req[All]OpenOrders call. I don't usually modify working orders but if I had to approach this problem I would likely use a circular awaitable future structure that would wait for two events to complete together: an OpenOrderEnd callback and an ExecutionEnd callback, and make a new req[All]OpenOrders call every time these two events have happened. In C# structurally this can be done either with regular events or two TaskCompletionSource objects and an await Task.WhenAll (or similar) call in a cycle. Doing this would ensure optimally timed calls to req[All]OpenOrders that would neither overlap each other nor fire needlessly in the absense of new Executions. Overall while this would inevitably lead to quite many req[All]OpenOrders calls, these will actually not require much processing power or connection hopping since these data are already in TWS so getting and processing it through the socket is going to be cheap even with some redundancy, which seems to be inevitable here
--
Best,
DS


Re: looking for earning data vendor

 

开云体育

yep they are my go to as well.

On 2/14/25 16:03, Despair via groups.io wrote:

Have a look at hedginglab.com.


Re: looking for earning data vendor

 

Have a look at hedginglab.com.