Skip to content

WebSockets · Options

Options levels stream

Changes of the key option levels.
WS/v1/ws/options/levelswsOptionsLevels
On this page

One event for each key level that changed since the last event: call_wall_moved, put_wall_moved (strike from and to), zero_gamma_crossed (the spot moved from above to below the zero-gamma level, or the reverse), regime_changed (gamma regime label from and to) and max_pain_moved. The first message after subscribing, and the first one for a socket that joins a running subscription, has kind snapshot and carries the full current state with from and to null; every event carries the full current levels. The levels are OrderMap's own model. The state is checked at most once every 5 seconds per root, and each change found is one event, so a single check can send several events. Subscribe by option root or family. At most 25 distinct option roots are served at once across all connections (an operator setting); a subscription to one more is answered with a status event, state unavailable and reason capacity, until a slot frees.

Connect and subscribe

Open wss://api.ordermap.si/v1/ws/options/levels?symbols=SPXW with your key in the Authorization header and your saved installation ID in X-OrderMap-Device-ID, then send a subscribe message. Up to 25 symbols per connection. Streams need API Pro. All keys and projects share one active device per account and one connection per event type. Reuse the same installation ID for every stream and reconnect. Browser subprotocols, limits and close codes are in WebSockets.

Node.js

import WebSocket from "ws";

// Create a UUID once per installation, save it, and reuse it for every stream.
const deviceId = process.env.ORDERMAP_DEVICE_ID;
if (!deviceId) throw new Error("Set ORDERMAP_DEVICE_ID to this installation's saved UUID.");

const ws = new WebSocket("wss://api.ordermap.si/v1/ws/options/levels?symbols=SPXW", {
  headers: {
    Authorization: `Bearer ${process.env.ORDERMAP_API_KEY}`,
    "X-OrderMap-Device-ID": deviceId,
  },
});

ws.on("open", () => ws.send(JSON.stringify({ action: "subscribe", symbols: ["SPXW"] })));
ws.on("message", (raw) => {
  const message = JSON.parse(raw.toString());
  if (message.type === "event") console.log(message.seq, message.data);
  if (message.type === "gap") console.warn("continuity lost: refetch the range over REST", message);
});
ws.on("close", (code, reason) => console.log("closed", code, reason.toString()));

Subscribe message

{"action":"subscribe","symbols":["SPXW"]}

Upgrade headers

A persistent installation ID is required. Supply the header below, or offer it as an ordermap.device.<id> browser subprotocol with ordermap.v1. Reuse the same saved ID for every event type, key, project and reconnect. Headers are not subscription filters.

ParameterType and limitsDescription
X-OrderMap-Device-IDheaderoptionalstringat least 16 charactersat most 128 characterspattern ^[A-Za-z0-9_-]{16,128}$Required unless supplied as an ordermap.device.<id> subprotocol together with ordermap.v1. Generate one random identifier per client installation and persist it across event types, keys, projects and reconnects. Never send it in the URL.

Subscription parameters

1 parameter, none required. Send them in the query string of the upgrade request, or as the filters of a subscribe message.

ParameterType and limitsDescription
symbolsqueryoptionalarray<string>comma-separated in one parameter1 to 25 itemseach at most 128 characterspattern ^[A-Za-z][A-Za-z0-9.]{0,9}$Symbols to subscribe to (up to 25).

Event

Each event is one message: {"type":"event","event_type":"options.levels","seq":N,"data":{...}}.

data of options.levels

  • fromnumber | string | nullrequiredThe previous strike (wall and max pain moves), side of the spot (above or below the zero-gamma level) or regime label; null in a snapshot.
  • kindstringrequiredWhat changed; snapshot is the full current state.snapshotcall_wall_movedput_wall_movedzero_gamma_crossedregime_changedmax_pain_moved
  • levelsobjectrequiredThe full current levels.5 fields inside
    • call_wallnumber | nullrequiredStrike of the largest positive call gamma exposure.
    • max_painnumber | nullrequiredMax pain strike of the nearest expiration.
    • put_wallnumber | nullrequiredStrike of the largest negative put gamma exposure.
    • regimestring | nullrequiredGamma regime of the model.positivenegativeneutralnull
    • zero_gammanumber | nullrequiredUnderlying price at which the modeled net gamma changes sign.
  • spotnumber | nullrequiredUnderlying price of the valuation.
  • symbolstringrequiredThe root or family subscribed to.
  • timestampintegerunix-msrequiredTime of the valuation. Unix epoch milliseconds (UTC).
  • tonumber | string | nullrequiredThe new strike, side of the spot or regime label; null in a snapshot.

Example event

{
  "type": "event",
  "event_type": "options.levels",
  "seq": 1,
  "data": {
    "from": 6050,
    "kind": "call_wall_moved",
    "levels": {
      "call_wall": 6075,
      "max_pain": 6000,
      "put_wall": 5950,
      "regime": "positive",
      "zero_gamma": 5890
    },
    "spot": 6021.4,
    "symbol": "SPX",
    "timestamp": 1792161060000,
    "to": 6075
  }
}

Before the upgrade

Errors before the upgrade are ordinary JSON errors; after it, problems arrive as messages and close codes (see WebSockets).

StatusMeaningBody
101Switching protocols: WebSocket protocol ordermap.v1.Switching protocols
400Invalid handshake parameters or missing, malformed or conflicting persistent device identifier.Error object
401Missing or invalid API key (Authorization, X-API-Key or, from a browser, the ordermap.key. subprotocol).Error object
403The plan has no streaming (streaming_not_in_plan), the dataset is not released, or the account is suspended.Error object
409stream_connection_limit: the account is already connected on another device, or already has this event type open on the active device. The existing connection is preserved.Retry-AfterError object
426The request is not a WebSocket upgrade.Error object
429Rate limit or WebSocket cooldown.Retry-AfterError object
503stream_unavailable: the stream is not enabled or its source is down; retry after Retry-After seconds.Retry-AfterError object

Authenticated responses carry the X-RateLimit-* headers (see rate limits); 429 and 503 add Retry-After.