Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin option chain builder #40

Open
ilan-pinto opened this issue Jul 1, 2024 · 2 comments
Open

builtin option chain builder #40

ilan-pinto opened this issue Jul 1, 2024 · 2 comments

Comments

@ilan-pinto
Copy link

Many people are building the option chain on their own. It could be nice having a built function that builds the option chain based on multiple params like: symbol,day to expiration, right range of strike/delta and more

@mattsta
Copy link
Contributor

mattsta commented Jul 1, 2024

The primary problem is IBKR is a fairly bad bulk data service. Fetching more than one option chain per minute slows down to blocking for 20 seconds to 90 seconds each time where no other data requests can happen due to IBKR's "data pacing limits" (there is no practical reason for slow data retrieval other than IBKR still acts like it's the 1970s in some of their APIs).

Services with usable data APIs like Tradier or Polygon.io provide better loading of the same data in milliseconds instead of 90 seconds through IBKR.

Also, since option chains don't change during the day (they can only add new strikes overnight between market sessions), fetched chains should be cached for the remainder of the day after their first request.

The real problems with option chain fetching all just on the user:

  • figuring out the expiration dates per instrument
  • deciding when requesting too many strikes at once blocks your client for too much time
  • deciding what to cache and for how long (then how to integrate the cache into your application)

We don't have an additional utility library for extra non-network-API usage like that, but feel free to sponsor additional work.

Practically, ib_async should probably remain a simple dependency-light IBKR-API-only library, but we could make an additional higher level utility library package including things like transparent caching, automatic market date discovery, data pacing awareness, etc.

@westonplatter
Copy link

I've run into similar needs to what @ilan-pinto is describing. See below screenshot of logic to pull down an IB option chain for future options.

Screenshot 2024-09-15 at 12 58 37

There's some nuance to making the final data structure look like the UI shown in the TWS Option Trader UI. For example, to get Option Bid/Ask/Last and Option greeks, one has to qualify the option contract by conId, request the tickers for each of the Option/FutureOption contracts, and then extract the desired ticker fields out and merge onto the option chain (at least, that's how I've gotten it to work on my end - there could be better approaches). Given those operations, I agree with @mattsta's point that this belongs in a higher level library and probably not in ib_insync.

@mattsta would be you open to creating an option chain specific repo under ib-api-reloaded? If so, I'd be curious in developing a package for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants