Subscribe
Before you can receive or send messages on a channel, you must subscribe to it. Only one channel can be named per SUBSCRIBE message. Each channel section documents its exact subscribe message and confirmation.
Subscribing is additive: a further SUBSCRIBE to a channel you already have adds its instruments to the ones you receive, and never removes any. MARK_PRICE is the exception, where a new SUBSCRIBE replaces the selection. To drop instruments, UNSUBSCRIBE from the channel and subscribe again.
Connection-level messages on the shared socket: authentication, generic subscribe and unsubscribe, heartbeats and errors.
const payload = { "type": "SUBSCRIBE", "channels": [ { "name": "TRADING" } ]};const socket = new WebSocket("wss://streams.fast.onetrading.com/");socket.addEventListener("open", () => { socket.send(JSON.stringify(payload));});You can only subscribe to one channel in a single SUBSCRIBE message. ORDER_BOOK, PRICE_TICKS and BOOK_TICKER require an instrument_codes property alongside the channel name; MARK_PRICE takes it optionally. A further SUBSCRIBE to the same channel adds instruments rather than replacing them, except on MARK_PRICE. See each channel for its exact subscribe message.
- payload
type*stringchannels*array<>1 <= items <= 1Subscribe to the TRADING channel
{ "type": "SUBSCRIBE", "channels": [ { "name": "TRADING" } ]}Reply
Sent back on the same channel.