Option Open Interest
Streams open-interest updates for one option contract. OPRA reports open interest each morning around 06:30 ET, reflecting the prior session; each report delivers an OpenInterest event.
The snippets below assume a connected client with streaming started — see Getting Started for the connect-and-stream ladder.
use thetadatadx::fpss::protocol::Contract;
use thetadatadx::fpss::{FpssData, FpssEvent};
tdx.start_streaming(|event: &FpssEvent| {
if let FpssEvent::Data(FpssData::OpenInterest { contract, open_interest, .. }) = event {
println!("{} oi={open_interest}", contract.symbol);
}
})?;
let sub = Contract::option("SPY", OptionLeg { expiration: "20260618", strike: "570", right: "C" })?.open_interest();
tdx.subscribe(sub.clone())?;
// Remove this stream; the session stays open for other subscriptions.
tdx.unsubscribe(sub)?;from thetadatadx import Contract
def on_event(event):
if event.kind == "open_interest":
print(event.contract.symbol, event.open_interest)
tdx.start_streaming(on_event)
sub = Contract.option("SPY", expiration="20260618", strike="570", right="C").open_interest()
tdx.subscribe(sub)
# Remove this stream; the session stays open for other subscriptions.
tdx.unsubscribe(sub)import { Contract } from 'thetadatadx';
tdx.startStreaming((event) => {
if (event.kind === 'open_interest') {
const e = event.openInterest!;
console.log(e.contract.symbol, e.openInterest);
}
});
const sub = Contract.option('SPY', { expiration: '20260618', strike: '570', right: 'C' }).openInterest();
tdx.subscribe(sub);
// Remove this stream; the session stays open for other subscriptions.
tdx.unsubscribe(sub);client.set_callback([](const tdx::FpssEvent& event) {
if (event.kind == TDX_FPSS_OPEN_INTEREST) {
auto& e = event.open_interest;
std::cout << e.contract.symbol << " oi=" << e.open_interest << "\n";
}
});
auto sub = tdx::Contract::option("SPY", {.expiration = "20260618", .strike = "570", .right = "C"}).open_interest();
client.subscribe(sub);
// Remove this stream; the session stays open for other subscriptions.
client.unsubscribe(sub);GET ws://127.0.0.1:25520/v1/eventsWebSocket streaming from the bundled server binary. Send one JSON envelope per command; set "add": false to unsubscribe.
Example
websocat ws://127.0.0.1:25520/v1/events
{"msg_type": "STREAM", "sec_type": "OPTION", "req_type": "OPEN_INTEREST", "id": 1, "add": true, "contract": {"symbol": "SPY", "expiration": 20260618, "strike": 570000, "right": "C"}}The WebSocket envelope takes the strike in thousandths of a dollar (570000 = $570.00); the SDKs take dollars.
Event fields
Each update arrives as a OpenInterest event with these fields:
| Field | Type | Description |
|---|---|---|
contract | contract | Resolved contract identity (symbol, security type, and option fields). |
ms_of_day | i32 | Milliseconds since midnight Eastern Time. |
open_interest | i32 | Total outstanding contracts. |
date | i32 | Trading date as a YYYYMMDD integer. |
received_at_ns | u64 | Local receive timestamp, nanoseconds since the Unix epoch. |
The contract field carries symbol, the security type, and — for options — expiration, right, and the strike. See Handling Events for the full event catalogue and per-language field shapes.