Skip to main content
This endpoint is in closed beta. It is available only to accounts enrolled in the beta, and only on staging (https://api.tradearies.dev). Request and response shapes may change before general availability.
Booked values only. The stream carries what fills have booked: quantity, cost, average price, and realized P&L. It has no mark price and no unrealized P&L, so it sends an update when a fill changes a position and not on every price tick. Compute unrealized P&L on the client from the live price stream; see Unrealized P&L.

Request

Authenticate the same way as Stream Prediction Orders. The stream carries only the authenticated user’s own positions: an account you have no positions on streams an empty snapshot and nothing after it. The first line of the response is retry: 2000, which tells an EventSource to wait two seconds before it reconnects.

Events

A : ping comment is sent every 15 seconds to keep idle connections open.

snapshot

positions holds only open positions, those with a non-zero qty. A position that is flat is not in the snapshot.

position

Each position is the whole row as it stands after the change, not a delta. Replace the row you hold for that symbol when the event’s version is higher than the one you have. When qty is "0" the position has closed: remove the row.

resync

The stream ends right after a resync. Reconnect, and the new snapshot brings your view up to date. slow_client means you stopped reading events fast enough to keep up; shutdown means the server is restarting.

Position fields

Decimals are strings: "0.54", not 0.54. ForecastEx takes buy orders only, so a position holds one outcome at a time. Buying the other outcome of a contract you hold does not open a second position: it nets against the one you have.

Unrealized P&L

Positions carry no mark price and no unrealized P&L. Take the last price for the held outcome from the live price stream, where each contract’s snapshot has a yes.last and a no.last, and compute:
Use yes.last when outcome is YES and no.last when it is NO. Do the arithmetic with a decimal type. If that outcome has not traded, last is null: show no unrealized P&L rather than zero.

Ordering

  • Every position carries a version that rises with each change. Keep the highest version you have seen for each symbol, and ignore a position at or below it. The stream already drops older versions, but applying this rule makes your client correct across reconnects too.
  • Never order by time. createdAt and updatedAt are for display. Only version says which row is newer.
  • snapshot comes first. Every position after it is newer than the snapshot’s copy of that position.
  • Changes to one position arrive in the order they happened. Changes to different positions may interleave.

Reconnecting

Events have no IDs and are not replayed, and there is no Last-Event-ID resume. Every connection starts with a fresh snapshot, so after a disconnect or a resync, reconnect and replace all your positions with the new snapshot. A change that happened while you were disconnected is reflected in it, and a position that closed while you were away is no longer in it. EventSource reconnects on its own after the retry: 2000 delay. A client that reads the stream with fetch has to reconnect itself, as the example below does.

Examples

cURL
A browser’s EventSource cannot send an Authorization header, so read the stream with fetch:
JavaScript
To show unrealized P&L, keep each contract’s latest yes.last and no.last from the live price stream and combine them with the held row:
JavaScript
Number keeps the example short. In production, use a decimal library for money.

Working with the stream

  • Prices, quantities, and P&L are decimal strings. Parse them with a decimal type.
  • Do not put the stream behind a buffering proxy. Events must reach you as they are sent.

Errors

Errors are returned before the stream opens, in the usual error envelope: