¿ªÔÆÌåÓý

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

How to get all VALID options


 

I've also run into this problem: not all strike/expiration combinations are valid.

What I do is whenever I get an error from the API that an option is invalid (e.g. from reqMktData), I store in a key/value store/database that symbol/expiration/strike combination as invalid, and never use it again in the code.

Note that you don't need to store the right. If a PUT is valid for a strike/expiration, so will the CALL, and vice-versa.

Also, agree that the reqSecDefOptParams API is inefficient, and hurts IB as well, because API clients need to check whether options are valid or not. IB should really return only valid options to begin with.


 

That's what I do also, but sometimes, in case of sudden strong demand or price change on a underlying, the market makers decide to add new strikes/expirations. If you don't browse the chain option regularly (that means daily before market open), you could miss these new options.
Trading options in such conditions, with poor quality on such basic info is definitely not what is expected from IB..
Josh, heeeeelp!?? ;-)? I'm sure this forum already asked you, but can you please tell the developers to put a 'decent option chain method' on their priority #1 to-do list, before they work on some 'quant' or 'never-used' functions.
With all VALID combinations of strikes/expiry, and the ConId of each?
A simple dataset of 6 fields would do it: Exchange - TradingClass - strike - expiry - right (put/call) - ConId
OR (to limit data flow)
Exchange - Trading Class - expiry - array of (strike - right (Put/Call) - ConId)



If we need more that that, we could search deeper with the ConId.


 

reqContractDetails?is fast with versions of TWS <= 963.?

My IB sales rep has submitted a sales enhancement request in September 2017.
If you would like to impress upon IB that getting entire option chains fast is also important to you, you can refer to the sales enhancement request mentioned in ticket?T773298.
As far as I know nothing has been done by IB development on this.



On Thu, Apr 18, 2019 at 4:28 AM Francois G via Groups.Io <namasteparis=[email protected]> wrote:
That's what I do also, but sometimes, in case of sudden strong demand or price change on a underlying, the market makers decide to add new strikes/expirations. If you don't browse the chain option regularly (that means daily before market open), you could miss these new options.
Trading options in such conditions, with poor quality on such basic info is definitely not what is expected from IB..
Josh, heeeeelp!?? ;-)? I'm sure this forum already asked you, but can you please tell the developers to put a 'decent option chain method' on their priority #1 to-do list, before they work on some 'quant' or 'never-used' functions.
With all VALID combinations of strikes/expiry, and the ConId of each?
A simple dataset of 6 fields would do it: Exchange - TradingClass - strike - expiry - right (put/call) - ConId
OR (to limit data flow)
Exchange - Trading Class - expiry - array of (strike - right (Put/Call) - ConId)



If we need more that that, we could search deeper with the ConId.


 

I'm using the last 974 version of TWS. I'm afraid to disagree that reqContractDetails?is 'fast' when it comes to search for valid option chains. The fastest is achieved by searching by expity month (AAAAMM), and this is throttled by IB servers. It takes at least 5 seconds per expiry month per symbol.That's not fast at all.
Anyway, thank you for the ticket info. I'll refer to them.


 

As a long time options trader on the TWS platform I am perplexed by this thread.
I have not noticed, or been hampered by, the cited shortcomings, so I guess I'm missing something.

So let me probe a bit to try to get on board. There seem to be two main points:?
1) chain delivery performance and 2) notification of new strikes.

For 1), what would be 'good' timing? Can someone cite a competitive service
as an example? (IB would then at least have a 'target'.)

If I understand 2), what is sought is effectively a new-strike subscription service?
Regardless of liquidity I guess? Whole chain or just new strikes? What filters?
(FWIW, I use notable changes in underlyings to trigger probes of chains.)

It is likely the details of the strategy context could clarify the dependencies
on these topics.

But as you see, I'm a bit confused.

Pete


-----Original Message-----
From: Francois G via Groups.Io <namasteparis@...>
To: twsapi <[email protected]>
Sent: Fri, Apr 19, 2019 3:09 am
Subject: Re: [TWS API] How to get all VALID options

I'm using the last 974 version of TWS. I'm afraid to disagree that reqContractDetails?is 'fast' when it comes to search for valid option chains. The fastest is achieved by searching by expity month (AAAAMM), and this is throttled by IB servers. It takes at least 5 seconds per expiry month per symbol.That's not fast at all.
Anyway, thank you for the ticket info. I'll refer to them.


 

By? TWS <= 963, I meant versions of TWS 963 or older. 974 is not older than 963.


On Fri, Apr 19, 2019 at 3:09 AM Francois G via Groups.Io <namasteparis=[email protected]> wrote:
I'm using the last 974 version of TWS. I'm afraid to disagree that reqContractDetails?is 'fast' when it comes to search for valid option chains. The fastest is achieved by searching by expity month (AAAAMM), and this is throttled by IB servers. It takes at least 5 seconds per expiry month per symbol.That's not fast at all.
Anyway, thank you for the ticket info. I'll refer to them.


 

I'd say getting the entire SPY option chain in 12 seconds or so is fast.


On Fri, Apr 19, 2019 at 2:09 PM Peter Gum via Groups.Io <peter.gum=[email protected]> wrote:
As a long time options trader on the TWS platform I am perplexed by this thread.
I have not noticed, or been hampered by, the cited shortcomings, so I guess I'm missing something.

So let me probe a bit to try to get on board. There seem to be two main points:?
1) chain delivery performance and 2) notification of new strikes.

For 1), what would be 'good' timing? Can someone cite a competitive service
as an example? (IB would then at least have a 'target'.)

If I understand 2), what is sought is effectively a new-strike subscription service?
Regardless of liquidity I guess? Whole chain or just new strikes? What filters?
(FWIW, I use notable changes in underlyings to trigger probes of chains.)

It is likely the details of the strategy context could clarify the dependencies
on these topics.

But as you see, I'm a bit confused.

Pete


-----Original Message-----
From: Francois G via Groups.Io <namasteparis=[email protected]>
To: twsapi <[email protected]>
Sent: Fri, Apr 19, 2019 3:09 am
Subject: Re: [TWS API] How to get all VALID options

I'm using the last 974 version of TWS. I'm afraid to disagree that reqContractDetails?is 'fast' when it comes to search for valid option chains. The fastest is achieved by searching by expity month (AAAAMM), and this is throttled by IB servers. It takes at least 5 seconds per expiry month per symbol.That's not fast at all.
Anyway, thank you for the ticket info. I'll refer to them.


 

@Jimmy
Oh sorry I didn't realize about the <= 963. Actually this is true: older versions of API are faster when using reqContractDetails with a month expiry (AAAAMM). This is IB oddity... However, I commercialize a software and I can't ask my customers to use old TWS or API versions.
And 12 seconds per symbol is way too much if you only intent to display an expiry/strike table, such as in TWS's Option Trader.

@Pete
1/ All data feeders would provide a clean option chain, with all valid strike/expiry combination, quotes, greeks and so on. But you would have to pay of course. Il you want a sample of what can be had for FREE, then try this:

and you'll have the complete option chain of SPX? JUN 21, 2019, immediately, with all quotes in a clean JSON format that can be parsed, without any limitations or throttling. You get tons of info about the underlying (SPX), and for each option, you even get OI, bid/ask, IV and more:

contractSymbol "SPX190621C02860000"
strike 2860
currency "USD"
lastPrice 86.86
change -3.790001
percentChange -4.1809163
volume 200
openInterest 12350
bid 85.3
ask 87
contractSize "REGULAR"
expiration 1561075200
lastTradeDate 1555075804
impliedVolatility 0.1295100477600098
inTheMoney true
?
You can send requests for many months simultaneously (parallel tasks) without being rejected, and get the whole SPX option chains with quotes and more in less than a second.

12 seconds for the same option chain, without any data when using IB API? We deserve better than that.

2/ If IB provides us with such a clean and reliable option chain method, that would be enough. Upload the option chain when you need it, maybe store it for the day to avoid unnecessary subsequent uploads, and there you go. Yes we could store the option chain, and update it only when IB notifies us that there had been some changes, but let's stop dreaming...


 

@Francois
1/The Yahoo API you illustrate is certainly an interesting example. Thank you for sharing that.
While the delayed data is a drawback, the mechanics of the interface are attractive.

I'm still uncertain about what constitutes a 'clean', i.e., 'valid' chain (or just a strike?). Illiquid I understand and
sometimes IB can't 'value' a contract (rare). But what else would you filter for?

Pete


-----Original Message-----
From: Francois G via Groups.Io <namasteparis@...>
To: twsapi <[email protected]>
Sent: Sat, Apr 20, 2019 4:21 am
Subject: Re: [TWS API] How to get all VALID options

@Jimmy
Oh sorry I didn't realize about the <= 963. Actually this is true: older versions of API are faster when using reqContractDetails with a month expiry (AAAAMM). This is IB oddity... However, I commercialize a software and I can't ask my customers to use old TWS or API versions.
And 12 seconds per symbol is way too much if you only intent to display an expiry/strike table, such as in TWS's Option Trader.

@Pete
1/ All data feeders would provide a clean option chain, with all valid strike/expiry combination, quotes, greeks and so on. But you would have to pay of course. Il you want a sample of what can be had for FREE, then try this:

and you'll have the complete option chain of SPX? JUN 21, 2019, immediately, with all quotes in a clean JSON format that can be parsed, without any limitations or throttling. You get tons of info about the underlying (SPX), and for each option, you even get OI, bid/ask, IV and more:

contractSymbol"SPX190621C02860000"
strike2860
currency"USD"
lastPrice86.86
change-3.790001
percentChange-4.1809163
volume200
openInterest12350
bid85.3
ask87
contractSize"REGULAR"
expiration1561075200
lastTradeDate1555075804
impliedVolatility0.1295100477600098
inTheMoneytrue
?
You can send requests for many months simultaneously (parallel tasks) without being rejected, and get the whole SPX option chains with quotes and more in less than a second.

12 seconds for the same option chain, without any data when using IB API? We deserve better than that.

2/ If IB provides us with such a clean and reliable option chain method, that would be enough. Upload the option chain when you need it, maybe store it for the day to avoid unnecessary subsequent uploads, and there you go. Yes we could store the option chain, and update it only when IB notifies us that there had been some changes, but let's stop dreaming...


 

Sure Yahoo provides delayed data (15mn I think), but hey this is free, not throttled, reliable and very fast. If you just want to get the option chain for x symbols without the quotes every morning and store it, it's definitely a good deal.With parallel tasking, you could get several hundreds option chains within a second.
?
Clean: well organised response, without redundancy, such as: Exchange - Trading Class - expiry - array of (strike - right (Put/Call) - ConId)

Valid: EXHAUSTIVE listing of VALID combinations (expiry/strike)


 

I appreciate your clarifications. They certainly have helped me understand
your points. Your suggestions would certainly improve efficiency.

But I'm not sure how broad support for these might be. I can see how
specific strategies might significantly benefit, but for my purposes, for
example, whole chains at once would not be a helpful flood.?

Once I turn my attention to a particular stock it is already the case that I also
already have a focus on potential ranges of strikes and expiries, a far smaller
subset of the whole chain. But that is just my approach which is not necessarily?
the case in general. But it also explains why TWS as it stands works just
fine for me.

I gather TWS sometimes delivers invalid combinations. But I don't think I have
ever consciously run into one. Is an error recognized at some point??
Or is a trade rejected? Or does TWS fail to list strikes that are known to be valid?
from other sources?

Pete

-----Original Message-----
From: Francois G via Groups.Io <namasteparis@...>
To: twsapi <[email protected]>
Sent: Sat, Apr 20, 2019 11:57 am
Subject: Re: [TWS API] How to get all VALID options

Sure Yahoo provides delayed data (15mn I think), but hey this is free, not throttled, reliable and very fast. If you just want to get the option chain for x symbols without the quotes every morning and store it, it's definitely a good deal.With parallel tasking, you could get several hundreds option chains within a second.
?
Clean: well organised response, without redundancy, such as: Exchange - Trading Class - expiry - array of (strike - right (Put/Call) - ConId)

Valid: EXHAUSTIVE listing of VALID combinations (expiry/strike)


 

Francois, thanks for sharing, this is so much faster than via the IB API which often takes me several minutes to get through. Is there a way to get a list of valid option expiration dates from Yahoo, or do you need to request every possible monthly and check if they have weeklies?


 

Scott, if you omit the last parameter (date);

you still obtain at the beginning of the response the list of all valid expirations dates, and strikes.
You can then request for each date to get the full option chain.
The source of this info is here:


 

As far as I can see the yahoo URL you show does not include weekly options. Is there a way to get these from Yahoo?


On Sat, Apr 27, 2019 at 3:16 AM Francois G via Groups.Io <namasteparis=[email protected]> wrote:
Scott, if you omit the last parameter (date);

you still obtain at the beginning of the response the list of all valid expirations dates, and strikes.
You can then request for each date to get the full option chain.
The source of this info is here:


 

https://query1.finance.yahoo.com/v7/finance/options/%5ESPX


 

IB Dev finally responded to the sales enhancement request, and they said they were going to keep reqContractDetails the way it is (i.e., unreasonably slow to try to get an option chain), and?reqSecDefOptParams useless (i.e., a jumble of expiry dates and strike prices). Thus, if anyone would needs to be able to build an option chain using IB TWS API, please ask them to either speed up?reqContractDetails back to what it was, or augment?reqSecDefOptParams so that it groups strike prices & expiry dates together, or a 3rd request to provide an option chain; please refer to sales enhancement request associated with ticket?T773298.


 

It seems that the Yahoo option chains are incomplete. For example, IBM's option chain has 884 options with IB; with Yahoo, it has 636 options. Yahoo is missing (for example) Aug 9 $118, $119, $120, etc.
Am I doing something wrong, or have you also noticed that Yahoo's options chains are missing options?


BDS
 

¿ªÔÆÌåÓý

Interesting observation, are you pulling the yahoo data from their API?

BDS

On Aug 6, 2019, at 2:34 PM, Jimmy <jimmydtalbot@...> wrote:

It seems that the Yahoo option chains are incomplete. For example, IBM's option chain has 884 options with IB; with Yahoo, it has 636 options. Yahoo is missing (for example) Aug 9 $118, $119, $120, etc.
Am I doing something wrong, or have you also noticed that Yahoo's options chains are missing options?


 

Yes I noticed that also. It seems that only DOTM strikes with bid/ask=0 and/or with open interest=0 are missing. Which is not a big loss, in a trader's point of view...
You can see that on the yahoo website:


 

You probably already know this but please be careful with Yahoo data, it can be wrong, sometimes very wrong.

Best wishes,

M

On Wed, 7 Aug 2019, 09:38 Francois G via Groups.Io, <namasteparis=[email protected]> wrote:
Yes I noticed that also. It seems that only DOTM strikes with bid/ask=0 and/or with open interest=0 are missing. Which is not a big loss, in a trader's point of view...
You can see that on the yahoo website: