Data Sources

Trades

Live trade selectors, returned fields, and exchange-specific contract context.

Exchange / providerLiveBacktestSelector
Hyperliquid directYesNobtc@trades@hyperliquidf
BULK directYesNobtc@trades@bulkf
NestYesNoUBTC/USDC@trades@nest
AscendYesNo<token-address>@trades@ascend
MontraYesNo<token-address>@trades@montra

Use a complete selector, not history.source("trade"). No timeframe is needed for direct trades. Raw trades are live-only; candle history does not reconstruct tick ordering.

Returned record

For an ordinary exchange trade:

Example returned record
{
  "price": 80500,
  "size": 0.002
}
FieldTypeMeaning
pricenumberExecution price in quote units per base asset.
sizenumberNormalized base quantity, not the dollar notional. For BTC, `0.002` means 0.002 BTC.
onchaindictionary, optionalMotive contract context. Absent on ordinary exchange trades and the current Oxley indexed adapter.

The selector identifies exchange, provider, and market. Ordinary trade dictionaries do not expose aggressor side or a per-record timestamp. ctx.timestamp_ms is the triggering event's time. Do not treat it as the timestamp of every record retained in history.

Read the latest trade

script = {"name": "watch-trades", "version": "2", "lookback": 20}
SOURCE = "btc@trades@hyperliquidf"


def on_data(ctx, history):
    latest = history.source(SOURCE, 0)
    if latest is None:
        return
    print(latest["price"], latest["size"])
    return {"metrics": {"price": latest["price"], "size": latest["size"]}}

on_data runs for accepted source updates. With no index, history.source(SOURCE) returns retained trades oldest to newest, or []. Index 0 returns the newest, index 1 the previous, and an unavailable index returns None. lookback bounds session history; it does not download older ticks at startup.

Nest pools

Use the pool source from the market picker. The runtime accepts a unique pair, a pair qualified by pool type, or an exact pool address. price is in the pool's quote asset and size is in base tokens. See Nest Scripts for selector examples.

Elysium markets

Use the launched token's address on Elysium mainnet. history.trades("ascend", TOKEN, 0) and history.trades("montra", TOKEN, 0) read the latest indexed trade on the corresponding venue. price is in pool quote units and size is in base tokens.

Next: Data Sources · History · Monitoring.

On this page