¿ªÔÆÌåÓý

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

Re: Request for options contracts per expirtation date

juxeiier
 

Hi Francois,

thx for the links.
All of this leaves me really speachless about the quality of the IB API.
I am a professional software developer since >30years, but a function like reqSecDefOptParams?plays in the primary league of "worst design never".
Not only does it return invalid data, but the concept inherently leads to massive server requests.

So sad, and since this topic is years old, IB obviously does not care.
Do they even have a valid email adress to their developers?


Re: How to get all VALID options

juxeiier
 

This is really unbelievable.
The quality of this API is really low, which is especially evident in this problem.
I have now implemented something with Yahoo finance, which gives me the valid option chains.
Then I create all needed contracts and serialize them to a file(because it takes an enormous amount of time to get them).
That way, the cached contracts can be reloaded and only new expiration chains well need to be added.
But still, why do we need to do this?
We deserve better from IB, since all this data is available in the option trader window.

I now struggle in reveiving the greeks for the options. Are they even there when markets are closed?


Re: Getting last Expired Option Price

 

Hi Mattias & Alexandre,
To get the underlying closing price, do you use reqHistoricalData for the expiration date?
Using Regular Trading Hours (RTH) = 1 or 0 ?
The closing price of the underlying for option calculation is normally based on the price AFTER market close, so RTH=0
Please confirm.


Re: Request for options contracts per expirtation date

 

Hi! well, again and again the same pain in the... Api about reqSecDefOptParams
/g/twsapi/message/46566
/g/twsapi/message/42241
Welcome to the party!


Re: Anyone upgraded Java version for TWS on Linux?

 

Hi,
I believe TWS comes with its own Java built into the installer.? I'm pretty sure I use that one.? TWS has never been the best written app but if you stick with stable its OK.?

I believe there are some weird security things built into IB's JVM they distribute which is why you can't make a stock JVM work.? I think if you dig into the IB JVM, you will probably find some security configs in the jre/lib directory (or inside of one of its sub-directories) that allow TWS to work.? Perhaps jre/lib/security/java.policy has been altered to only run IB signed jars or that TWS needs a custom Java security policy.? If you really want to hammer away at this that's where I would look.? As for the performance issues with TWS, perhaps the screen config you have is too busy or perhaps its using up all the pacing capacity and that's causing issues with refreshing the screen.? I have a hard time believing that upgrading the JVM would help.? The Java 8 JVM is really mature and the changes to it are mostly about very minor things that probably wouldn't impact the performance of a GUI app.

Hunter

On Monday, March 15, 2021, 11:32:32 AM PDT, John <jpelly@...> wrote:


No such luck for me - I let that error dialog sit and nothing happens; just sits there forever (rest of TWS will not start up).

I'd like to run TWS on my local Linux laptop, so hopefully someone else comments on this thread with some additional suggestions.

Correction to original message: I'm running Linux Mint 20.

Thanks all
John


On Mon, Mar 15, 2021 at 1:04 PM Ray Racine <ray.racine@...> wrote:
On latest Fedora Linux and I'm getting the exact same error as of today as well.? TWS ultimately starts up fine however.? I assume just not on the latest update :).

With regard to performance,? I've never had to do anything beyond adjusting the Max Heap. ? Performance is retalive, but I have some pretty big watch lists, charts with studies, plus API clients and performance has been fine for me.

I do get quite a few UI issues with menus and mouse pointing (not calculating the X-Y position correctly mostly) when I run under Sway / Wayland.??? The occasional annoying UI issues with XMonad / XOrg.? And no real UI issues to speak of with Gnome - Xorg or Wayland.

On Mon, Mar 15, 2021 at 11:52 AM John <jpelly@...> wrote:
I'm experiencing pretty bad performance of TWS GUI on Linux (Mint 19). I've tried to upgrade Java version that TWS uses, thinking that will help.

However I'm unable to change versions. Reading through the tws shell script, it looks like it pins the JRE version at 1.8.0_152. If I remove the check in the shell script and try to upgrade to openjdk version 1.8.0_282 (upgraded patch level), TWS won't start - says "we are unable to update the platform due to a networking error" (see attached screenshot)

Has anyone successfully been able to do this? It looks like you can upgrade Java versions on Windows so I was hoping to do it on Linux.

jws networking error.png


Re: Anyone upgraded Java version for TWS on Linux?

 

No such luck for me - I let that error dialog sit and nothing happens; just sits there forever (rest of TWS will not start up).

I'd like to run TWS on my local Linux laptop, so hopefully someone else comments on this thread with some additional suggestions.

Correction to original message: I'm running Linux Mint 20.

Thanks all
John


On Mon, Mar 15, 2021 at 1:04 PM Ray Racine <ray.racine@...> wrote:
On latest Fedora Linux and I'm getting the exact same error as of today as well.? TWS ultimately starts up fine however.? I assume just not on the latest update :).

With regard to performance,? I've never had to do anything beyond adjusting the Max Heap. ? Performance is retalive, but I have some pretty big watch lists, charts with studies, plus API clients and performance has been fine for me.

I do get quite a few UI issues with menus and mouse pointing (not calculating the X-Y position correctly mostly) when I run under Sway / Wayland.??? The occasional annoying UI issues with XMonad / XOrg.? And no real UI issues to speak of with Gnome - Xorg or Wayland.

On Mon, Mar 15, 2021 at 11:52 AM John <jpelly@...> wrote:
I'm experiencing pretty bad performance of TWS GUI on Linux (Mint 19). I've tried to upgrade Java version that TWS uses, thinking that will help.

However I'm unable to change versions. Reading through the tws shell script, it looks like it pins the JRE version at 1.8.0_152. If I remove the check in the shell script and try to upgrade to openjdk version 1.8.0_282 (upgraded patch level), TWS won't start - says "we are unable to update the platform due to a networking error" (see attached screenshot)

Has anyone successfully been able to do this? It looks like you can upgrade Java versions on Windows so I was hoping to do it on Linux.

jws networking error.png


Re: Anyone upgraded Java version for TWS on Linux?

 

On latest Fedora Linux and I'm getting the exact same error as of today as well.? TWS ultimately starts up fine however.? I assume just not on the latest update :).

With regard to performance,? I've never had to do anything beyond adjusting the Max Heap. ? Performance is retalive, but I have some pretty big watch lists, charts with studies, plus API clients and performance has been fine for me.

I do get quite a few UI issues with menus and mouse pointing (not calculating the X-Y position correctly mostly) when I run under Sway / Wayland.??? The occasional annoying UI issues with XMonad / XOrg.? And no real UI issues to speak of with Gnome - Xorg or Wayland.


On Mon, Mar 15, 2021 at 11:52 AM John <jpelly@...> wrote:
I'm experiencing pretty bad performance of TWS GUI on Linux (Mint 19). I've tried to upgrade Java version that TWS uses, thinking that will help.

However I'm unable to change versions. Reading through the tws shell script, it looks like it pins the JRE version at 1.8.0_152. If I remove the check in the shell script and try to upgrade to openjdk version 1.8.0_282 (upgraded patch level), TWS won't start - says "we are unable to update the platform due to a networking error" (see attached screenshot)

Has anyone successfully been able to do this? It looks like you can upgrade Java versions on Windows so I was hoping to do it on Linux.

jws networking error.png


Request for options contracts per expirtation date

 

Hi all,

I would like to request a feature and I don't know to whom to address this.
The feature is about requesting all option contracts for specific expiration dates, or all contracts up to some date in the future.
So, in pseudocode, I would like to have something like

contractsList = ib.reqOptionContractsUntil(symbolId, 60days from today)

The contractsList would then be filled with objects that hold all calls and puts contracts for a specific date(like the tabs in the options trader) up to 60days in the future.
The current solution with reqSecDefOptParams is really hard to work with to achieve the same result.
You first get the data and then you have to request if a specific combination of expiration/strike is even valid.
If you have many symbols, for which you want these contracts, you would have thousands of slow requests towards the server for all possible combinations.
This takes a very long time and is bad for the network.

It would be so much simpler, if the IB server would directly give us back all valid contracts.
What do you think?
Is there an email address where I can forward this proposal to the developers?

Thanks you very much for help,
Juergen


Re: Anyone upgraded Java version for TWS on Linux?

Stuart Cracraft
 

I run it fine on Ubuntu on AWS

Version 20 of Ubuntu.

Works fine.

My only nit is the need to restart it weekly.

That is truly sophomoric.

A daemon is supposed to run 7x24x365 and not require re-authentication or at most automatic re-authentication.

Very strange.

Plus having to run the GUI itself.

The IB Gateway also is sophomoric.

My two cents.

Level up Interactivebrokers.com!!!!

On Mar 15, 2021, at 7:56 AM, John <jpelly@...> wrote:

I'm experiencing pretty bad performance of TWS GUI on Linux (Mint 19). I've tried to upgrade Java version that TWS uses, thinking that will help.

However I'm unable to change versions. Reading through the tws shell script, it looks like it pins the JRE version at 1.8.0_152. If I remove the check in the shell script and try to upgrade to openjdk version 1.8.0_282 (upgraded patch level), TWS won't start - says "we are unable to update the platform due to a networking error" (see attached screenshot)

Has anyone successfully been able to do this? It looks like you can upgrade Java versions on Windows so I was hoping to do it on Linux.

<jws networking error.png>


Anyone upgraded Java version for TWS on Linux?

 

I'm experiencing pretty bad performance of TWS GUI on Linux (Mint 19). I've tried to upgrade Java version that TWS uses, thinking that will help.

However I'm unable to change versions. Reading through the tws shell script, it looks like it pins the JRE version at 1.8.0_152. If I remove the check in the shell script and try to upgrade to openjdk version 1.8.0_282 (upgraded patch level), TWS won't start - says "we are unable to update the platform due to a networking error" (see attached screenshot)

Has anyone successfully been able to do this? It looks like you can upgrade Java versions on Windows so I was hoping to do it on Linux.

jws networking error.png


TWS API usage.

 

I'm no technology expert so would appreciate any help.
I've downloaded the latest version of TWS API and ticked the "Enable ActiveX and Sockets Clients" box under API Settings in TWS.

However, when attempting to run the sample Excel sheet TwsRtdServer sheet or building simple RTD functions to bring in stock prices I get #N/A error codes.

Any idea what might be the reason for error?

I've tried to repair Excel but the problem still remains.

After looking through Microsoft help pages I read: "RTD servers should be digitally signed. If an RTD server is not digitally signed, the server may not load, and a #N/A will be displayed in the cell(s) referencing the RTD server."

Does anyone know how to confirm that the RTD server is digitally signed?

Also, are there any specific excel COM Add-ins that have to be running for TWS RTD to work?

I¡¯m running Excel on Microsoft 365.


historical open interest

 

Hi all,
?? I was wondering if anyone knew a way to get historical open interest data on equities from IB.? Is it buried in reqFundamentalData somewhere these days?? I know I can find it in TWS itself but I can't seem to determine which API calls return this specific data.

thanx,
Hunter


Re: How to create a performance efficient trading app so each sub process runs smoothly in Python?

 

I don't know how your overall design is structured, but indeed there are performance issues due to GIL of python. So you do need to use multiprocessing.? But I do believe you can get lot of performance just using python + multiprocessing. Lot of the core building blocks in numpy/pandas is highly optimized - so it is less likely your performance would be impacted due to these (unless ofcourse you are extremely latency sensitive). I use IB for orders, but use a different 3rd party data provider. What I have is?
#1) First I have a process that would start IB as a background thread. This process will create the IB thread with all the connections established. Then it enters a wait loop forever, waking up periodically.
#2) I have a separate process that handle data feeds, does model predictions etc and send messages to the waiting process. I use multiprocessing shared memory () to exchange signal output between data feed process and IB process. Waiting IB process picks up from queue periodically and post orders to IB. Just use locks as appropriate (If you need IB for feed, you can still do it by making the waiting process query data and receive data in an async fashion. Locks and shared memory are your best friend here).?

It take a bit to get this going, but I want to stick to python and this design so far works for me (I haven't tested it with lot of symbols, but at that point the bottleneck would be with data + model evaluation, I suspect)


How to create a performance efficient trading app so each sub process runs smoothly in Python?

 

What would be the best way to do on-the-fly computations using Numpy, Pandas for trading using IB TWS API, writing to/from mySQL, and in the meanwhile receive and send data and orders?

From (and ) I conclude that CPU-bound programs, those that spend most of the their time processing data (like on the-fly computations using Pandas which is synchronous single threaded), solutions like threading (pre-emptive multitasking) and asyncio are inferior (and may disrupt the sending/receipt of data or introduce some lag or data drops) since there is only one Python interpreter on a single core/processor (asyncio aligns I/O processes more efficiently) that takes care of both the CPU computations and checking for socket data.

I know there is? a ib_insync library that implements cooperative multitasking (asyncio) in Python, but will the overall program be fast enough if you do computations using large dataframes? I read that on a socket level there might not be any limitations (¡°socket itself is actually thread-safe¡±), as suggested by . I do not assume that Ptyhon has it implemented this way since the Global Interpreter Lock is in place (single thread, synchronous). From :

IB.sleep(0); may be an alternative, but I do not think a Pandas groupby() can be interrupted once called.

Should I use the Multiprocessing library and do every task on its own processor (thus dataframe calculations, mySQL connection read/write, sending and receiving orders and data)?
Or should I combine some things using (I think some next level threading which can be combined with the normal way of interpretation of code by Python) or the (has to do with built-in async for Scikit-Learn, Pandas, etc. functions, if I understand correctly) library? I think this is next level, and may be an overkill.

Or should stick to Java (I do not know if there is a Pandas like alternative which allows easy manipulation of data and performing machine learning for example, but threading may be organized better)?

Any suggestions or tutorials?

(I read something about was well, but that¡¯s a whole different story since it is not directly applicable to IB TWS API, and may be prone to delays resulting from single core processing/interpreting by Python as well, if I understand correctly)


Re: Getting last Expired Option Price

 

Thanks for your answers. That's what I thought at first, but when I ask for the underlying past quotes, I can see a discrepancy between historical data using reqhistoricaldata, and what is displayed on the graph. Using RTH or not, and setting RTH graph parameter, figures differ for all (open, high, low, close)


Re: Getting last Expired Option Price

Matthias Frener
 

I'm also usng the underlying. Expired OTM options are 0$, price of ITM is the different from strike to underlying closing price (they have no more time value at expiry).

Am Sa., 13. M?rz 2021 um 15:07?Uhr schrieb §¡§Ý§Ö§Ü§ã§Ñ§ß§Õ§â §¹§Ö§â§ß§Ú§Ü§à§Ó <me@...>:

It would be easier to figure out official closing price for the underlying and calculate option prices yourself.

On Sat, Mar 13, 2021, 10:36 Francois G via <namasteparis=[email protected]> wrote:
Hi, I try to get the expiration price of an option (let's say SPY) expired 2 months ago.
I tried to get the Close of the last trading day using reqHistoricalData:
IContract.exchange="SMART"
IContract.conId=458962807?????? //SPY 2021-01-22 Call 386
IContract.includeExpired=true
IBClient.ClientSocket.reqHistoricalData(1,IContract,"20210125 02:00:00 CET","1 W","1 day","TRADES",0,1,0,Null)

But I get an error 200 No security definition has been found for the request
Which sounds logical, according to the historical data limitations:
unavailable historical data: Expired options, FOPs, warrants and structured products

So, does anyone knows how to get the last price of an expired option (the expiration price kept for assignment calculations by OCC and IB) via API (and not FLEX queries)?


Re: Getting last Expired Option Price

 

It would be easier to figure out official closing price for the underlying and calculate option prices yourself.


On Sat, Mar 13, 2021, 10:36 Francois G via <namasteparis=[email protected]> wrote:
Hi, I try to get the expiration price of an option (let's say SPY) expired 2 months ago.
I tried to get the Close of the last trading day using reqHistoricalData:
IContract.exchange="SMART"
IContract.conId=458962807?????? //SPY 2021-01-22 Call 386
IContract.includeExpired=true
IBClient.ClientSocket.reqHistoricalData(1,IContract,"20210125 02:00:00 CET","1 W","1 day","TRADES",0,1,0,Null)

But I get an error 200 No security definition has been found for the request
Which sounds logical, according to the historical data limitations:
unavailable historical data: Expired options, FOPs, warrants and structured products

So, does anyone knows how to get the last price of an expired option (the expiration price kept for assignment calculations by OCC and IB) via API (and not FLEX queries)?


Getting last Expired Option Price

 

Hi, I try to get the expiration price of an option (let's say SPY) expired 2 months ago.
I tried to get the Close of the last trading day using reqHistoricalData:
IContract.exchange="SMART"
IContract.conId=458962807?????? //SPY 2021-01-22 Call 386
IContract.includeExpired=true
IBClient.ClientSocket.reqHistoricalData(1,IContract,"20210125 02:00:00 CET","1 W","1 day","TRADES",0,1,0,Null)

But I get an error 200 No security definition has been found for the request
Which sounds logical, according to the historical data limitations:
unavailable historical data: Expired options, FOPs, warrants and structured products

So, does anyone knows how to get the last price of an expired option (the expiration price kept for assignment calculations by OCC and IB) via API (and not FLEX queries)?


Re: Handling Executions for expired options

 

Hi Dan, did you get any solution to handle these Expired/Assigned option orders, initiated by IB?


Re: Order executions when AUTOEXERCISE, ASSIGNED, or EXPIRED

 

Am I the only one here to try to automate ASSIGNED, or EXPIRED option prices retrieval?