Skip to content

6.0: OptionChain::expirations is Vec<Expiry> - #1253

Open
faysou wants to merge 2 commits into
wboayue:mainfrom
faysou:contracts/option-chain-expiration-dates
Open

faysou wants to merge 2 commits into
wboayue:mainfrom
faysou:contracts/option-chain-expiration-dates

Conversation

@faysou

@faysou faysou commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Why

OptionChain::expirations was Vec<String>. Every caller that wants the nearest expiration, or an expiration to put in an option contract, sorts and parses the text itself; the crate's own options_exercise examples did expirations.sort() and then expiration.parse()?.

What

  • OptionChain::expirations is Vec<Expiry>. TWS sends each entry as a YYYYMMDD date, which decodes to Expiry::Date(ExpirationDate): it orders by date and goes straight into Contract::option.
  • Text in another form is kept as Expiry::Unknown, through the existing lenient Expiry::from_wire, so an unexpected value never fails the request (the enum-typing rule for one-shot fields).
  • The examples and the spreads integration tests use the typed values; the integration tests compare the dates' text as before.
  • Migration guide §39, changelog entry under Changed, wire-facts entry under contracts.

Verified

  • Live, paper TWS server 223: reqSecDefOptParams for AAPL (22 chains), SPX (9 chains) and ES futures options on CME (21 chains, weeklies and dailies included) sent only 8-digit YYYYMMDD expirations.
  • Decoder test covers two dates and an unrecognized entry kept as Expiry::Unknown.
  • Gates: cargo fmt; clippy, rustdoc, examples and cargo test on the default, sync-only and all-features legs; tools/check-rules-graph.sh; clippy on ibapi-integration-sync and ibapi-integration-async.

TWS sends every option chain expiration as a YYYYMMDD date (live on
paper TWS for stock, index and futures option chains). The field was
Vec<String>, so finding the nearest expiration meant parsing text. Each
date now decodes to Expiry::Date(ExpirationDate), which orders by date
and goes straight into Contract::option. Text in another form is kept
as Expiry::Unknown, so an unexpected value never fails the request.
Migration section 39.
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

Successfully merging this pull request may close these issues.

1 participant