A live stream of your own fills, orders, trades and accounts
https://app.skylit.ai/api/nexus/v1/trading/streamOpen one stream and Nexus pushes your own changes the moment they happen, so your bot stops asking "did it fill yet?". It's Server-Sent Events (text/event-stream): one long response with an event per change. Run it from your bot: a browser's EventSource can't send your key in a header, and your key shouldn't be in a browser anyway.
- Same key, same checks as every route. Opening it counts as one read. Events and heartbeats don't.
- Only yours. Nobody else's trades ever show up. Your agent account's events come only to you. Test orders never show up: they aren't trades. Futures events only come if your account has futures.
- No market data. Quotes aren't in it.
| Event | When | data |
|---|---|---|
connected | Once, first (no id) | account, resumed, futures, heartbeatSeconds |
resync | First thing on a new connection, and any time the server lost track | {reason}. Re-read your state with the REST routes |
trade | An options or stock trade was opened, added to, trimmed, closed or expired | change, book, at, fill (quantity, price; id only when known, left out today), trade (as GET /api/nexus/v1/trades/{id} returns it) |
order | A resting order changed | change, assetClass, book, order (as the order read returns it) |
wallet | Your options and stocks cash or buying power moved | book, wallet (as the wallet read returns it) |
account | A futures account changed | book, account (as the account read returns it) |
heartbeat | Every 15 seconds (no id) | {at} |
closed | We ended the stream. Fix the reason before you reconnect | {reason}: invalid_api_key, account_suspended, nexus_access_denied or trades_api_disabled |
reconnect | The server is restarting | {reason: "server_restart"}. Reconnect right away |
An order's change is working, held (a futures stop or target waiting for its entry), modified, triggered (a stop went off), partial_fill, filled, cancelled, rejected or expired. A trade's change is opened, added, trimmed, closed or expired. Orders you placed in Nexus show up too.
Dropped connections. Every data event has an id. Reconnect with the last one as Last-Event-ID. If the server you land on still has what you missed (your last 128 events, for 2 minutes after you drop), you get them and connected says "resumed": true. If not, the first event after connected is resync. So on resync, read your open trades, working orders, wallet and futures accounts again, then keep going.
Limits. 3 streams per key and 6 per account at once, past that 429 stream_limit_reached with Retry-After. A heartbeat comes every 15 seconds: hear nothing for 45 and the connection's dead, so reconnect. A revoked key's stream ends within about 2 minutes. capabilities has a stream block with these numbers.
Authorization
Authorization: Bearer <your API key>Required. A missing header returns 401; an invalid, revoked or expired key returns 403.
Query parameters
accountstringmainfor your own trades and accounts,agentfor your bot's. Leave it out (or sendall) for both. Every event says whichbookit's on.mainagentalllastEventIdstringThe same as
Last-Event-ID, for clients that can't set the header. The header wins if both are sent.
Headers
Last-Event-IDstringThe
idof the last event you got, to pick up where you left off after a drop.
Responses
- 200
The stream. It stays open until you close it or the server sends
closedorreconnect. - 400
The request was refused before anything was traded. Codes:
bad_request,bad_contract,invalid_quantity,invalid_price,unsupported_asset_class,unsupported_order_type,only_market_orders,limit_price_required(a limit with nolimitPrice),invalid_limit_price(not in cents, or outside 0.01 to 99,999.99 for options or 999,999.99 for stocks),stop_price_required(a stop with nostopPrice),invalid_stop_price(not in cents, or outside 0.01 to 999,999.99),invalid_take_profit,test_orders_unavailable,test_modify_unavailable. - 401
No key, or a key that isn't valid. Codes:
missing_api_key,invalid_api_key. - 403
The key works but the account can't do this. Codes:
account_suspended,nexus_access_denied,futures_access_denied. - 429
Over a rate limit. Wait
Retry-Afterseconds, then retry. Codes:rate_limited, andstream_limit_reached(too many live streams open: 3 per key, 6 per account). - 500
Something went wrong on our side. If you sent a
clientOrderId, retry with the same one. Code:internal_error. - 503
Try again in a moment (honour
Retry-Afterwhen it's sent). Codes:stale_quote(the quote, or a stock's last trade, is more than 15 seconds old, so nothing filled),no_live_price,rules_pending,unavailable,auth_unavailable,access_check_unavailable,api_keys_unavailable,trades_api_disabled,stream_unavailable(the live stream isn't on, or the server is restarting: try again shortly, or poll the reads).
Response fields
Returns string.
Last updated