Skip to content

[bot] Add binary option fields to OptionsContract - #1062

Merged
justinpolygon merged 1 commit into
masterfrom
jw/options-contract-binary-fields
Dec 4, 2026
Merged

justinpolygon merged 1 commit into
masterfrom
jw/options-contract-binary-fields

Conversation

@justinpolygon

Copy link
Copy Markdown
Collaborator

Adds the binary option fields from the OpenAPI spec to OptionsContract, which get_options_contract and list_options_contracts return. Before this change the client dropped them.

Fields added (from the production spec, same on both endpoints):

  • type: Optional[str]: standard or binary. Can be missing, for example on older contracts.
  • underlying_type: Optional[str]: kpi, equity or index
  • KPI binaries only:
    • company_ticker: Optional[str]
    • metric: Optional[str]
    • reporting_period: Optional[str]
    • report_time: Optional[str] (AM or PM)
    • scale: Optional[int]

The new fields are appended after the existing ones, so positional construction of OptionsContract is unchanged.

Existing mismatches fixed:

  • correction was annotated Optional[str], but the spec says integer. Changed to Optional[int]. This only changes the type hint: the value is passed through unchanged.
  • from_dict passed size=, which isn't a model field or a spec property. @modelclass silently drops unknown kwargs, so it was dead code. Removed it, along with the matching size=None in the tests.

No server-side type filter: the spec has no type or underlying_type query parameter on /v3/reference/options/contracts, and the live API ignores type=binary (it returns the same contracts as an unfiltered request). So this PR adds no filter kwargs. To get only binaries, filter on the client:

binaries = [c for c in client.list_options_contracts(underlying_ticker="KAAPL") if c.type == "binary"]

Testing:

  • New fixtures, taken from real responses with no key in them:
    • a KPI binary, O:KAAPL270205C00001200
    • an equity binary, O:B1VDA261120C00160000 (with as_of=2026-11-19)
  • New tests check that the fields parse on both binaries and stay None on a standard contract. All 3 fail against the previous model.
  • make lint and make test pass (56 REST, 14 WebSocket).
  • Live check:
    • O:KAAPL270205C00001200: every new field is populated (binary, kpi, AAPL, Earnings Per Share ($/share), 2027Q1, PM, 1).
    • O:B1VDA261120C00160000 with as_of=2026-11-19: type=binary and underlying_type=equity, with the KPI-only fields None.
    • O:SPY261218C00600000: the API doesn't send type, so it's None.
    • list_options_contracts(underlying_ticker="KAAPL"): returns the fields.

@justinpolygon justinpolygon changed the title [TBD] Add binary option fields to OptionsContract [bot] Add binary option fields to OptionsContract Dec 4, 2026
@justinpolygon
justinpolygon merged commit 4355e58 into master Dec 4, 2026
7 checks passed
@justinpolygon
justinpolygon deleted the jw/options-contract-binary-fields branch December 4, 2026 19:52
justinpolygon added a commit that referenced this pull request Dec 4, 2026
Adds response fields that the REST and WebSocket specs define but the
models dropped. A full audit of the library against both specs found
them.

**REST**
- `Agg.fractional_volume` (from `dv`, string), used for the snapshot
`day` and `prevDay` bars. The API sends this field, for example on
`get_snapshot_all("stocks", ...)`. The name matches
`MinuteSnapshot.fractional_volume`.
- `FuturesContract`: `provider_id`, `provider_product_id`
- `FuturesProduct`: `clearing_symbol`, `clearing_venue`, `provider_id`,
`strategy_type`
- `OptionContractSnapshot.fmv_last_updated` and
`UniversalSnapshot.fmv_last_updated` (int, ns)
- `Trade.received_timestamp` (int, ns; crypto trades)

**WebSocket**
- `EquityTrade.participant_timestamp` and
`EquityQuote.participant_timestamp` (from `pt`)

Additive only: new fields go at the end of each model, and method
signatures are unchanged. The options contract binary fields are in
#1062.

**Testing**
- `make lint` and `make test` pass.
- Rerunning the spec audits (REST endpoints and all 38 WebSocket
channels) shows no dropped fields left outside #1062.
- A live A/B against `master` on 42 core workflows: every existing value
is identical, and the only differences are the new fields. `dv` comes
through live as `day.fractional_volume`.
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.

2 participants