Python ScriptingData Sources

Market info

Read live indexed statistics for perps and launchpad tokens.

The info source requires Market Lab 0.1.134 or later.

Use a literal selector such as btc@info@bulkf or btc@info@hyperliquidf to start a feed when the job launches. For Ascend and Montra, use the market from a launch event with ctx.subscribe. An existing token can also use a literal selector such as <token-address>@info@ascend.

SOURCE = "btc@info@bulkf"
script = {"name": "btc-info", "version": "2"}


def on_data(ctx, history):
    info = history.source(SOURCE, 0)
    if info is not None:
        return {"metrics": {
            "mark": info["mark_price"],
            "funding": info["funding_rate"],
        }}

The first update contains the latest indexed record when one is available. Each subsequent update enters history and calls on_data. An empty feed returns None from history.source(feed, 0). Check updated_at before relying on a retained record. Info feeds are live only.

Perpetuals

FieldsMeaning
kind, exchange, marketkind is "perp".
base_symbol, quote_symbolUnits used by price, volume and open interest.
updated_at, last_price_atStats and last-price observation times in Unix milliseconds.
last_price, index_price, mark_priceDistinct price observations in quote units per base unit.
open_interest_base, open_interest_quoteBase size and its value at the mark.
funding_rate, funding_interval_secDecimal rate for the stated period.
volume_24h_base, volume_24h_quoteRolling 24-hour volumes in the stated units.

Launchpad tokens

FieldsMeaning
kind, exchange, market, symbolkind is "token". Use market as the identifier.
quote, quote_symbolQuote asset address and symbol.
created_at, updated_atLaunch and stats times in Unix milliseconds.
pricePool price in quote units per token. Use the trades feed for executed prices.
market_cap_quote, market_cap_usdSupply valuation in quote or USD units.
liquidity_quoteIndexed pool value in quote units.
volume_24h_quote, volume_24h_usdRolling 24-hour volume in quote or USD units.
holdersIndexed holder count.
dev_bought, dev_sold, dev_holdingsLaunch buy, observed creator sale, and creator balance in base-token units.

Unavailable statistics are None. Ascend can report creator sales and holdings when its launch tracking covers them. Montra supplies holders and launch-buy data through its catalog where available. Creator sales and holdings may remain unknown. Prices and quote-denominated fields can be in HYPE, WHYPE, or another quote asset. Check quote_symbol before comparing markets.

Subscribe during a run

ctx.subscribe returns a feed handle immediately. Pass it to history.source to read retained records. The same handle identifies future on_data updates.

LAUNCHES = "launches@montra"
script = {"name": "watch-launch-info", "version": "2"}
feed = None


def on_data(ctx, history):
    global feed
    if ctx.source == LAUNCHES:
        launch = history.source(LAUNCHES, 0)
        if launch is None:
            return
        if feed is not None:
            ctx.unsubscribe(feed)
        feed = ctx.subscribe({
            "exchange": launch["exchange"],
            "market": launch["market"],
            "stream": "info",
        })
        return

    if ctx.source == feed:
        info = history.source(feed, 0)
        if info is not None:
            return {"metrics": {
                "event": "market_info",
                "exchange": info["exchange"],
                "market": info["market"],
                "symbol": info["symbol"],
                "quote": info["quote_symbol"],
                "holders": info["holders"],
                "dev_bought": info["dev_bought"],
                "dev_sold": info["dev_sold"],
                "market_cap_quote": info["market_cap_quote"],
                "market_cap_usd": info["market_cap_usd"],
                "liquidity_quote": info["liquidity_quote"],
            }}

The script logs these metrics for ser, using the same market from its launch. In this output, quote is the display symbol copied from the info record's quote_symbol. Each unavailable value is None in Python and null in JSON. See the original launch record.

{
  "event": "market_info",
  "exchange": "montra",
  "symbol": "ser",
  "market": "99901:0xa3c935b0fdc1ff9453a2a0814e7d9fa7d05d1348",
  "quote": "HYPE",
  "holders": null,
  "dev_bought": null,
  "dev_sold": null,
  "market_cap_quote": null,
  "market_cap_usd": null,
  "liquidity_quote": null
}

Use stream: "trades" for new executions or stream: "candles" with a timeframe in seconds. Dynamic trades and candles support indexed BULK and Hyperliquid perps, Ascend and Montra token addresses, and Nest pool addresses. Dynamic candles aggregate new trades from when the feed connects. Keep a literal source for the job's first event. Each job can open up to 16 dynamic feeds. An identical subscription returns the same handle. Unsubscribe when finished to release the slot and discard that feed's history. Startup feeds stay active. Dynamic subscriptions grant read access only.

On this page