Skip to content

WebSockets · Indices

Indices basis stream

Index versus futures-implied value.
WS/v1/ws/indices/basiswsIndicesBasis
On this page

The relation between a cash index and its futures: fair value, the futures-implied index price, basis, premium and a state (index_above_implied, index_below_implied, at_fair). An update is sent on every change, at most 60 per second per index; whenever the state changes an extra event with kind crossing follows. Only available while the cash index is live.

Connect and subscribe

Open wss://api.ordermap.si/v1/ws/indices/basis?symbols=SPX with your key in the Authorization header, then send a subscribe message. Up to 10 symbols per connection. One connection per account per stream; streams need API Pro. The protocol, limits and close codes are in WebSockets.

Node.js

import WebSocket from "ws";

const ws = new WebSocket("wss://api.ordermap.si/v1/ws/indices/basis?symbols=SPX", {
  headers: { Authorization: `Bearer ${process.env.ORDERMAP_API_KEY}` },
});

ws.on("open", () => ws.send(JSON.stringify({ action: "subscribe", symbols: ["SPX"] })));
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":["SPX"]}

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 10 itemseach at most 128 characterspattern ^[A-Za-z][A-Za-z0-9.]{0,9}$Symbols to subscribe to (up to 10).

Event

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

data of indices.basis

  • basisnumberrequiredFutures price minus index, in index points.
  • contractstringrequiredDated futures contract used.
  • dividend_yieldnumberrequiredDividend yield used, continuously compounded.
  • fair_basisnumberrequiredFair value minus index, in index points.
  • fair_valuenumberrequiredFair futures price: index × e^((rate − dividend yield) × years).
  • futures_pricenumberrequiredFutures price used: the quote midpoint, else the last trade.
  • futures_price_basisstringrequiredWhich futures price was used.midlast
  • futures_timestampintegerunix-msrequiredTime of the futures price. Unix epoch milliseconds (UTC).
  • implied_index_pricenumberrequiredIndex level implied by the futures price: futures × e^(−(rate − dividend yield) × years).
  • index_minus_impliednumberrequiredCash index minus the futures-implied index price, in index points.
  • index_timestampintegerunix-msrequiredTime of the index value. Unix epoch milliseconds (UTC).
  • index_valuenumberrequiredCash index value.
  • kindstringrequiredupdate on every change; crossing when the state changed (an update follows with the same state).updatecrossing
  • premiumnumberrequiredFutures price minus fair value, in index points.
  • premium_bpsnumberrequiredPremium as basis points of the index.
  • previous_statestring | nullrequiredState before a crossing; null on updates.index_above_impliedindex_below_impliedat_fairnull
  • ratenumberrequiredFinancing rate used, continuously compounded.
  • settlement_timeintegerunix-msrequiredFinal settlement of the contract. Unix epoch milliseconds (UTC).
  • statestringrequiredWhether the cash index sits above, below or at the futures-implied price (within the epsilon, 0.25 points by default).index_above_impliedindex_below_impliedat_fair
  • symbolstringrequiredIndex symbol.
  • timestampintegerunix-msrequiredTime of the newest input. Unix epoch milliseconds (UTC).
  • years_to_settlementnumberrequiredYears from now to the contract's final settlement (ACT/365).

Example event

{
  "type": "event",
  "event_type": "indices.basis",
  "seq": 1,
  "data": {
    "basis": 40,
    "contract": "ESZ6",
    "dividend_yield": 0.013,
    "fair_basis": 32.1,
    "fair_value": 5832.1,
    "futures_price": 5840,
    "futures_price_basis": "mid",
    "futures_timestamp": 1792161000100,
    "implied_index_price": 5807.8,
    "index_minus_implied": -7.8,
    "index_timestamp": 1792161000000,
    "index_value": 5800,
    "kind": "crossing",
    "premium": 7.9,
    "premium_bps": 13.6,
    "previous_state": "index_above_implied",
    "rate": 0.045,
    "settlement_time": 1797604200000,
    "state": "index_below_implied",
    "symbol": "SPX",
    "timestamp": 1792161000100,
    "years_to_settlement": 0.1726
  }
}

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.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: one live connection per account per event type.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.