Socketrade

Guide · Streaming

Prices. One socket, ticks only.

The WebSocket pushes bid/ask ticks for the symbols you ask for. It does not push positions, orders or history. Subscribe, read the tick, and keep your position logic on REST.

01Open the socket on the gateway host

One connection per account. Send the key on the handshake; a browser cannot set a header, so it may use ?api_key= instead, at the cost of the key appearing in the URL.

wss://win-vi96ovqi4i6.taile61f2a.ts.net/v2/acc_.../ws
X-API-Key: $SOCKETRADE_KEY

02Subscribe to symbols

Up to 64 symbols per connection. The server acknowledges with the list it accepted. Subscribing adds to the set; it does not replace it.

{ "action": "subscribe", "symbols": ["EURUSD", "XAUUSD"] }

{"type":"subscribed","topic":"prices","symbols":["EURUSD","XAUUSD"]}

03Read the tick

bid and ask are the current quote, timeMsc is the broker's tick time in milliseconds, and seq is the account's stream counter. A gap in seq means you missed messages, not that the market jumped.

{
  "type": "tick", "topic": "prices", "symbol": "EURUSD",
  "bid": 1.08451, "ask": 1.08455, "last": 0, "volume": 0,
  "timeMsc": 1764450000123, "seq": 918273, "ts": 1764450000456
}

04Treat silence as silence

A subscribed symbol with no ticks has no market right now, usually forex at the weekend. Do not carry a stale price forward and call it live. Check timeMsc against your own clock before you act on a quote.

05Reconnect and resubscribe

There is no replay. On close, reconnect, send subscribe again, and read positions over REST to catch up on anything that changed while you were away.

{ "action": "unsubscribe", "symbols": ["EURUSD"] }
{ "action": "subscriptions" }   // what this socket is subscribed to

When it fails

401The key was missing or rejected at the handshake.
too many symbolsMore than 64 on one connection. Split across connections or narrow the list.
symbols must be a non-empty listThe subscribe body had no symbols, or was not a list.
No ticksThe symbol is not subscribed, or its market is closed. It is not a broken socket.
WS closedReconnect and resubscribe; no tick replay is available.

Related