Skip to content

WebSockets · Stocks

Stocks trades stream

Stock trades.
WS/v1/ws/stocks/tradeswsStocksTrades
On this page

Every consolidated trade of a stock. Cancels and corrections do not appear on the stream.

Connect and subscribe

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

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

Subscription parameters

3 parameters, 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 100 itemseach at most 128 characterspattern ^[A-Za-z][A-Za-z0-9.]{0,9}$Symbols to subscribe to (up to 100).
min_sizequeryoptionalnumbermin 0max 1000000000000Minimum size in shares.
min_notionalqueryoptionalnumbermin 0max 1000000000000000Minimum notional value in dollars.

Event

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

data of stocks.trades

  • conditionsarray<integer>requiredTrade condition codes.
  • exchangeinteger | nullrequiredNumeric id of the executing exchange; 4 is an off-exchange trade.
  • notionalnumberrequiredPrice × size in dollars.
  • off_exchangebooleanrequiredTrue for a trade reported by a trade reporting facility.
  • participant_timestampinteger | nullunix-msrequiredTime the exchange stamped the trade. Unix epoch milliseconds (UTC).
  • pricenumberrequiredTrade price.
  • sequence_numberinteger | nullrequiredConsolidated sequence number.
  • sizenumberrequiredTrade size in shares.
  • symbolstringrequiredTicker.
  • tapeinteger | nullrequiredConsolidated tape (1 = NYSE, 2 = NYSE American, 3 = Nasdaq).
  • timestampintegerunix-msrequiredTime the consolidated feed stamped the trade. Unix epoch milliseconds (UTC).
  • trade_idstring | nullrequiredTrade id; null when the feed supplies none.
  • trf_idinteger | nullrequiredTrade reporting facility id of an off-exchange trade.
  • trf_timestampinteger | nullunix-msrequiredTime the facility received an off-exchange trade. Unix epoch milliseconds (UTC).

Example event

{
  "type": "event",
  "event_type": "stocks.trades",
  "seq": 1,
  "data": {
    "conditions": [
      12,
      37
    ],
    "exchange": 4,
    "notional": 23142,
    "off_exchange": true,
    "participant_timestamp": 1792161000120,
    "price": 231.42,
    "sequence_number": 1563,
    "size": 100,
    "symbol": "AAPL",
    "tape": 3,
    "timestamp": 1792161000123,
    "trade_id": "52983525029461",
    "trf_id": 202,
    "trf_timestamp": 1792161000122
  }
}

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.