This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-predictions/realtime / predictionsTopics

predictionsTopics ​

const predictionsTopics: object

Predictions realtime topics, for realtime.subscribe from @getenginex/sdk/realtime. The three market ones are public (they work without a session); orders() is private: it uses the session's user and requires login. All enums arrive in lowercase, without the protobuf prefix.

Type Declaration ​

market() ​

market(input): Topic<MarketUpdate>

Prices, volume and status of a market (market:<marketId>, market_update). The sequenced-mode snapshot has the same format and is delivered (meta.kind === 'snapshot').

Parameters ​

input ​

MarketTopicInput

marketId: market id.

Returns ​

Topic<MarketUpdate>

Example ​

ts
realtime.subscribe(predictionsTopics.market({ marketId: 'mkt-1' }), (m) => setPrice(m.lastPriceYes))

Throws ​

CONFIGURATION_ERROR, as in orderbook.

orderbook() ​

orderbook(input): Topic<OrderbookUpdate>

Orderbook of a market (predictions:orderbook:<marketId>, orderbook_update messages). In sequenced mode the snapshot is delivered (meta.kind === 'snapshot'). The SDK does not apply deltas: load the base with markets.getOrderbook and reload on onResync.

Parameters ​

input ​

MarketTopicInput

marketId: market id.

Returns ​

Topic<OrderbookUpdate>

Example ​

ts
realtime.subscribe(predictionsTopics.orderbook({ marketId: 'mkt-1' }), (book, meta) => apply(book, meta.kind))

Throws ​

CONFIGURATION_ERROR if marketId is empty or outside ^[a-zA-Z0-9_:.-]+$ (letters, digits, _, :, ., -).

orders() ​

orders(): Topic<OrderStatusUpdate>

Status changes of the user's orders (predictions:orders:<sub>, order_status_update). Private: the id is the session's sub. realtime.subscribe without a session throws UNAUTHENTICATED.

Returns ​

Topic<OrderStatusUpdate>

Example ​

ts
realtime.subscribe(predictionsTopics.orders(), (o) => console.log(o.orderId, o.status))

Throws ​

CONFIGURATION_ERROR if it receives an id (the topic takes no arguments).

trades() ​

trades(input): Topic<TradeUpdate>

Executed trades of a market (predictions:trades:<marketId>, trade_update). The sequenced-mode snapshot (price history, another format) is not delivered: use markets.getPriceHistory for the base.

Parameters ​

input ​

MarketTopicInput

marketId: market id.

Returns ​

Topic<TradeUpdate>

Example ​

ts
realtime.subscribe(predictionsTopics.trades({ marketId: 'mkt-1' }), (t) => tape.push(t))

Throws ​

CONFIGURATION_ERROR, as in orderbook.

Example ​

ts
import { createRealtime } from '@getenginex/sdk/realtime'
import { predictionsTopics } from '@getenginex/sdk-predictions/realtime'

const realtime = createRealtime(enginex)
const off = realtime.subscribe(predictionsTopics.orderbook({ marketId: 'mkt-1' }), (book) => render(book))