Option Market Value
Streams the calculated market value for one option contract, delivered as a MarketValue event. Each update carries the calculated market_bid, market_ask, and market_price.
The snippets below assume a connected client with streaming started — see Getting Started for the connect-and-stream ladder.
use thetadatadx::streaming::{Contract, OptionLeg};
use thetadatadx::streaming::{StreamData, StreamEvent};
client.stream().start_streaming(|event: &StreamEvent| {
if let StreamEvent::Data(StreamData::MarketValue { contract, market_price, .. }) = event {
println!("{} market_price={market_price}", contract.symbol);
}
})?;
let sub = Contract::option("SPY", OptionLeg { expiration: "20260618", strike: "570", right: "C" })?.market_value();
client.stream().subscribe(sub.clone())?;
// Remove this stream; the session stays open for other subscriptions.
client.stream().unsubscribe(sub)?;from thetadatadx import Contract
def on_event(event):
if event.kind == "market_value":
print(event.contract.symbol, event.market_price)
client.stream.start_streaming(on_event)
sub = Contract.option("SPY", expiration="20260618", strike="570", right="C").market_value()
client.stream.subscribe(sub)
# Remove this stream; the session stays open for other subscriptions.
client.stream.unsubscribe(sub)import { Contract } from 'thetadatadx-ts';
await client.stream.startStreaming((event) => {
if (event.kind === 'market_value') {
const e = event.marketValue!;
console.log(e.contract.symbol, e.marketPrice);
}
});
const sub = Contract.option('SPY', { expiration: '20260618', strike: '570', right: 'C' }).marketValue();
client.stream.subscribe(sub);
// Remove this stream; the session stays open for other subscriptions.
client.stream.unsubscribe(sub);client.stream().set_callback([](const thetadatadx::StreamEvent& event) {
if (event.kind == THETADATADX_STREAM_MARKET_VALUE) {
auto& e = event.market_value;
std::cout << e.contract.symbol << " market_price=" << e.market_price << "\n";
}
});
auto sub = thetadatadx::Contract::option("SPY", {.expiration = "20260618", .strike = "570", .right = "C"}).market_value();
client.stream().subscribe(sub);
// Remove this stream; the session stays open for other subscriptions.
client.stream().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": "MARKET_VALUE", "id": 1, "add": true, "contract": {"symbol": "SPY", "expiration": 20260618, "strike": 570000, "right": "C"}}The WebSocket envelope takes the strike as the terminal's 1/10-cent integer (570000 = $570.00) by default, matching the terminal wire; pass the server's --strike-format dollars flag to use a dollar value instead. The native SDK builders take dollars.
MarketValue event fields
Each update arrives as a MarketValue 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. |
market_bid | f64 | Calculated market-value bid (stocks and options only). |
market_ask | f64 | Calculated market-value ask (stocks and options only). |
market_price | f64 | Calculated market value; the only populated value for an index. |
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.
WebSocket frame
The native SDK callbacks (Rust/Python/TypeScript/C++) receive every field above. Each raw WebSocket frame (the Server tab) is { "header": {…}, "contract": {…}, "market_value": {…} }: header and contract are always present, while the market_value payload object carries only the terminal-compatible subset: ms_of_day, market_bid, market_ask, market_price, date. The remaining event fields are delivered to the SDK callbacks, not the market_value payload object.