Skip to content

WebSockets · Futures

Futures bars stream

Futures one-minute bars.
WS/v1/ws/futures/barswsFuturesBars
On this page

The forming and closed one-minute bar of a product or dated contract, built from trades. A forming bar is sent at most 60 times a second; the closed bar (closed: true) is sent once, when the minute ends.

Connect and subscribe

Open wss://api.ordermap.si/v1/ws/futures/bars?symbols=ES with your key in the Authorization header, then send a subscribe message. Up to 25 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/futures/bars?symbols=ES", {
  headers: { Authorization: `Bearer ${process.env.ORDERMAP_API_KEY}` },
});

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

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":"futures.bars","seq":N,"data":{...}}.

data of futures.bars

  • buy_volumeintegerrequiredContracts traded at the ask.
  • closenumberrequiredLatest trade price.
  • closedbooleanrequiredTrue on the final event of the minute.
  • contractstringrequiredDated contract.
  • end_timeintegerunix-msrequiredEnd of the minute (exclusive). Unix epoch milliseconds (UTC).
  • highnumberrequiredHighest trade price.
  • intervalstringrequiredBar size: 1m.
  • lownumberrequiredLowest trade price.
  • opennumberrequiredFirst trade price.
  • partialbooleanrequiredTrue when trades of the minute may be missing: the stream started, or lost continuity (a gap was reported), during it. Bars of full minutes that follow are complete.
  • sell_volumeintegerrequiredContracts traded at the bid.
  • start_timeintegerunix-msrequiredStart of the minute (inclusive). Unix epoch milliseconds (UTC).
  • symbolstringrequiredThe symbol subscribed to.
  • timestampintegerunix-msrequiredTime of the latest trade in the bar. Unix epoch milliseconds (UTC).
  • trade_countintegerrequiredNumber of trades.
  • unknown_volumeintegerrequiredContracts whose aggressor is unknown.
  • volumeintegerrequiredContracts traded.
  • vwapnumberrequiredVolume-weighted average price.

Example event

{
  "type": "event",
  "event_type": "futures.bars",
  "seq": 1,
  "data": {
    "buy_volume": 640,
    "close": 5801.25,
    "closed": false,
    "contract": "ESZ6",
    "end_time": 1792161060000,
    "high": 5801.5,
    "interval": "1m",
    "low": 5800.25,
    "open": 5800.5,
    "partial": false,
    "sell_volume": 520,
    "start_time": 1792161000000,
    "symbol": "ES",
    "timestamp": 1792161042210,
    "trade_count": 412,
    "unknown_volume": 20,
    "volume": 1180,
    "vwap": 5800.91
  }
}

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.