¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 ¿ªÔÆÌåÓý
Date

Re: Which Java version to use?

 

What kind of issues do you experience, JG?

TWS and IBGW bring their own customized Oracle Java 8 VM with JavaFX and my strong suggestion is that you don't change that and let TWS/IBGW use their embedded JVM.

The appropriate Java VM for your own software and the TWS API jar depends on what requirements the frameworks and libraries have that your software depends. It would make sense to standardize on one Java version for your entire workflow from IDE, through testing, and deployment.

For us that is currently Java 9 (though we are evaluating a migration to Java 11 or 17) and we have rock stable results running identical jars on OpenJDK 9 for Windows and Linux. Running our Java 9 jars on OpenJDK 11 works fine without any problems, too.

For better version control, compatibility, and debugging we build our own TWS API jar from the Java source code provided by IBKR. The IBKR jar that comes with API distributions is compiled with Java 8 and has version 52 class files.

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


Which Java version to use?

 

A few days ago I upgraded my desktop computer from Ubuntu 20.04 to 22.04. Since then am I experiencing issues with my trading software. Investigating this I get the impression that it is caused by using old and/or outdated versions of Java and the Netbeans IDE I'm using. I have been carrying it over for many years, but fear that by now it is considered obsolete.
What are the recommendations from other users related to Java? For example: does it matter whether I use OpenJDK or Oracle's Java? I seem to recall that a couple of years ago there were some issues with OpenJDK and IB's software, but don't know the current situation. What version should I upgrade to? Are there other considerations?
Of course am I looking for the "path of least resistance": my software is running for more than five years and I would like to change as little as possible. And do the bare minimum required to get it to work to the current versions of the Java language and IDE on the current (and future) Ubuntu LTS versions.


Reuters / Refinitiv and Dow Jones Press Release subscriptions using the API

 

If I subscribe to?Reuters / Refinitiv and Dow Jones Press Release - will I also get the data using the API?
And how can I subscribe to Reuters / Refinitiv data with API? I can't see it on the "Research Subscriptions" page on my user settings.


Re: ScannerSubscription

 

Must be a bug in TWS since it's Avrg Vlm ($) equals the Avrg Vlm (expressed in # shares) for all of these symbols.

Either the TWS developers mapped the wrong data field to the column, or they forgot to multiply the Avrg Vlm (expressed in # shares) with the average share price.

Max


ScannerSubscription

 

I'm trying to build some scripting for a market scanner based on average dollar volume, however this figure doesn't seem to make sense.

In the case of tesla for example:
1) the daily dollar volume= 26.6M x ~$900 = $24 billion. This looks right
2) the 90 day average dollar volume = 30.8M x ~$800 = $24 billion. (assuming average price was $800 for the last 90 days).?

However the Average Volume ($) is only showing $30.8M which is about 1000 times less. Any ideas?


Get company analyst forecasts

 

Is there a way using the TWS API get?analyst forecasts for all upcoming quarters and years?
I try?reqFundamentalData but I only get forecast for the current quarter, next quarter and current year.
I need data for few following quarters and years to come, which exist on TWS fundamentals explorer.



Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)

 

Thanks a lot

On Fri, 12 Aug 2022 at 21:29 Joel Gross <joelrgross@...> wrote:
The empty string appears to work normally.

On Fri, Aug 12, 2022, 11:26 AM Edward <ed.gonen@...> wrote:
Joel

If you can, please update on your results. I didn't have a chance to check this yet as after my failure with cancellation I had reverted to the "old" API.?

Thanks in advance
Ed

On Fri, 12 Aug 2022 at 20:46 Joel Gross <joelrgross@...> wrote:
I tried passing in a datetime string and it ended up not cancelling my orders properly. I will try the empty string.

--
Ed Gonen

--
Ed Gonen


Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)

Joel Gross
 

The empty string appears to work normally.


On Fri, Aug 12, 2022, 11:26 AM Edward <ed.gonen@...> wrote:
Joel

If you can, please update on your results. I didn't have a chance to check this yet as after my failure with cancellation I had reverted to the "old" API.?

Thanks in advance
Ed

On Fri, 12 Aug 2022 at 20:46 Joel Gross <joelrgross@...> wrote:
I tried passing in a datetime string and it ended up not cancelling my orders properly. I will try the empty string.

--
Ed Gonen


Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)

 

Joel

If you can, please update on your results. I didn't have a chance to check this yet as after my failure with cancellation I had reverted to the "old" API.?

Thanks in advance
Ed

On Fri, 12 Aug 2022 at 20:46 Joel Gross <joelrgross@...> wrote:
I tried passing in a datetime string and it ended up not cancelling my orders properly. I will try the empty string.

--
Ed Gonen


Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)

Joel Gross
 

I tried passing in a datetime string and it ended up not cancelling my orders properly. I will try the empty string.


Locked Re: No documentation for new manualCancelOrderTime in cancelOrder?

 

We had a thread about this very recently. Please see "What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)". That topic should answer your question. If not, let's continue on the original topic.

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


Locked No documentation for new manualCancelOrderTime in cancelOrder?

Joel Gross
 

I saw this has been added, but did not see documentation for it (in client.py):
def cancelOrder(self, orderId:OrderId, manualCancelOrderTime:str):
? ? ? ? """Call this function to cancel an order.

? ? ? ? orderId:OrderId - The order ID that was specified previously in the call
? ? ? ? ? ? to placeOrder()"""

? ? ? ? self.logRequest(current_fn_name(), vars())

? ? ? ? if not self.isConnected():
? ? ? ? ? ? self.wrapper.error(NO_VALID_ID, NOT_CONNECTED.code(), NOT_CONNECTED.msg())
? ? ? ? ? ? return

? ? ? ? if self.serverVersion() < MIN_SERVER_VER_MANUAL_ORDER_TIME and manualCancelOrderTime:
? ? ? ? ? ? self.wrapper.error(orderId, UPDATE_TWS.code(), UPDATE_TWS.msg() + " ?It does not support manual order cancel time attribute")
? ? ? ? ? ? return

? ? ? ? VERSION = 1

? ? ? ? flds = []
? ? ? ? flds += [make_field(OUT.CANCEL_ORDER)]
? ? ? ? flds += [make_field(VERSION)]
? ? ? ? flds += [make_field(orderId)]

? ? ? ? if self.serverVersion() >= MIN_SERVER_VER_MANUAL_ORDER_TIME:
? ? ? ? ? ? flds += [make_field(manualCancelOrderTime)]

? ? ? ? msg = "".join(flds)

? ? ? ? self.sendMsg(msg)


Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given

 

Well, if your code was written against a version 9 API, you might want to stay with the stable API? 9.81 track for now. You can still run your code against all (even the latest and beta) TWS and IBGW versions. It's a good practice to lock the API version in and to avoid automatic and uncontrolled version changes.

But by its nature, the stable track is a couple years old and is lacking the latest features version 10 provides. So you might want to start the development, unit, system, and regression testing cycles so that you can eventually move to the version 10 API.

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

On Thu, Aug 11, 2022 at 08:44 PM, Joel Gross wrote:

Wow, thanks guys! Tons of major changes it looks like.?

I have not been developing much... is it worth it to upgrade or should I switch from Latest to Stable?


Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given

Joel Gross
 

Wow, thanks guys! Tons of major changes it looks like.?

I have not been developing much... is it worth it to upgrade or should I switch from Latest to Stable?


Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given

 

Nope. The advancedOrderRejectJson field was introduced in API version 10.14.01 in January 2022 and went through beta and is, obviously, in the current "latest" version 10.17.01.

Version 10 has many and large changes compared with the current stable version 9.81 and is still rapidly getting new features.

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

On Thu, Aug 11, 2022 at 06:20 PM, @sbank wrote:

I came across this the other day.? I believe that IB has been making major changes to the API (in minor patch releases).
?
?


Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given

 

On Thu, Aug 11, 2022 at 06:28 PM, Joel Gross wrote:
My guess is you are using a new api version where error takes an extra param (advancedOrderRejectJson)
Either change back to an older api version or change the app.error method in your code to accept an extra string.


Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given

 

I came across this the other day.? I believe that IB has been making major changes to the API (in minor patch releases).

Look for your definition of error().? It now takes 5 arguments and not 4.

So something like this:

??? def error(self,
????????????? reqId: TickerId,
????????????? errorCode: int,
????????????? errorString: str):?

Needs to be changed to:

??? def error(self,
????????????? reqId: TickerId,
????????????? errorCode: int,
????????????? errorString: str,
????????????? advancedOrderRejectJson=""):

Take a look at the API Docs.? They have some boilerplate code around using that new advancedOrderRejectionJson parameter.

-s

On Thu, Aug 11, 2022, at 6:27 PM, Joel Gross wrote:
I have been running TWS API with Python for years without many issues. Suddenly my code that worked yesterday is no longer working. Any file I run, I get an error like this:


Traceback (most recent call last):
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 296, in <module>
? ? main()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 287, in main
? ? app.run()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 409, in run
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1377, in interpret
? ? self.interpretWithSignature(fields, handleInfo)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1358, in interpretWithSignature
? ? method(*args)
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 515, in nextValidId
? ? self.start()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 137, in start
? ? self.runWithoutSchedule()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 466, in runWithoutSchedule
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1379, in interpret
? ? handleInfo.processMeth(self, iter(fields))
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1273, in processErrorMsg
? ? self.wrapper.error(reqId, errorCode, errorString, advancedOrderRejectJson)
TypeError: TestApp.error() takes 4 positional arguments but 5 were given

I am running Windows 10, TWS Latest, API Latest. About the time this error started, I had to switch from Visual Studio Code to Visual Studio Code Insiders. Python files run regularly under VS Code Insiders just fine.

What could cause this to happen??


TypeError: TestApp.error() takes 4 positional arguments but 5 were given

Joel Gross
 

I have been running TWS API with Python for years without many issues. Suddenly my code that worked yesterday is no longer working. Any file I run, I get an error like this:

Traceback (most recent call last):
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 296, in <module>
? ? main()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 287, in main
? ? app.run()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 409, in run
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1377, in interpret
? ? self.interpretWithSignature(fields, handleInfo)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1358, in interpretWithSignature
? ? method(*args)
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 515, in nextValidId
? ? self.start()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 137, in start
? ? self.runWithoutSchedule()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 466, in runWithoutSchedule
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1379, in interpret
? ? handleInfo.processMeth(self, iter(fields))
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1273, in processErrorMsg
? ? self.wrapper.error(reqId, errorCode, errorString, advancedOrderRejectJson)
TypeError: TestApp.error() takes 4 positional arguments but 5 were given

I am running Windows 10, TWS Latest, API Latest. About the time this error started, I had to switch from Visual Studio Code to Visual Studio Code Insiders. Python files run regularly under VS Code Insiders just fine.

What could cause this to happen??


Re: Tick-by-tick data is coming in bursts

 

Please keep in mind that time stamps in TickByTick callbacks have a resolution of 1 second. Therefore, liquid instruments can have many trades per second, each trade would be reported as a separate callback, and all trades that took place within the same second will have the same time stamp.

The same is true, and for many instruments more visible, for BidAsk updates. The instruments we subscribe to often have 10 BidAsk updates for each trade.

Your log is from pre-market trading but I am sure AAPL is good for seven trades in one second an hour before market open.

Hope that helps,

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

PS. If you tag each callback with your own local higher resolution arrival time stamp you will see that callbacks with identical time stamps do not happen in one block. What I mean is you will see that they take place over approximately one second but not equally spaced nor all together. There is also a separate thread about millisecond resolution of TickByTick data.


Tick-by-tick data is coming in bursts

 

Hi everyone,
I've recently started messing around with the Java API, specifically the?'reqTickByTickData'?method. But I noticed some unexpected behavior and would like to know why this is and if there's something I can do to resolve it.
In my program I request tick by tick data twice. Once with tickType of?'Last'?and once with a tickType of?'BidAsk'.
On their respective callback methods being called I log the time parameter of the callback.
The below lines are the logs, where 'LAST' indicates a log from the 'Last' callback method and 'BIDASK' indicates a log from the 'BidAsk' callback method.
You will notice that some of the data comes in clumps for example, the 4th line to the 10th line all indicate the exact same time. I find this likely to be inaccurate as this was ran premarket when I wouldn't expect a lot of activity occurring at the exact same time. I'm of the thinking that for whatever reason I'm getting slightly delayed data, that is pushed together with other data generated roughly around the same time. Has anyone else ran into this. would upgrading subscription help I wonder?
Thanks for any input you can offer.



BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220588| BidPrice: 170.04| AskPrice: 170.08| AskSize: 300| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220588| BidPrice: 170.04| AskPrice: 170.09| AskSize: 300| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220588| BidPrice: 170.07| AskPrice: 170.09| AskSize: 2600| TickAttributeBidAsk:?
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 161| TickAttributeLast: | Exchange: ARCA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 100| TickAttributeLast: | Exchange: ARCA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 100| TickAttributeLast: | Exchange: ARCA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 100| TickAttributeLast: | Exchange: ARCA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 100| TickAttributeLast: | Exchange: ARCA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 4000| TickAttributeLast: | Exchange: FINRA| SpecialConditions: T
LAST: RequestId: 1| Ticker: AAPL| tickType: 1| Time: 1660220606| Price: 170.09| Size: 139| TickAttributeLast: | Exchange: FINRA| SpecialConditions: T
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220606| BidPrice: 170.07| AskPrice: 170.1| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220606| BidPrice: 170.08| AskPrice: 170.1| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220606| BidPrice: 170.08| AskPrice: 170.09| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220606| BidPrice: 170.07| AskPrice: 170.09| AskSize: 200| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.07| AskPrice: 170.1| AskSize: 300| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.07| AskPrice: 170.09| AskSize: 300| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.05| AskPrice: 170.09| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.07| AskPrice: 170.09| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.06| AskPrice: 170.09| AskSize: 100| TickAttributeBidAsk:?
BIDASK: RequestId: 2| Ticker: AAPL| Time: 1660220608| BidPrice: 170.05| AskPrice: 170.09| AskSize: 100| TickAttributeBidAsk:?