MMTMMT Docs
Built-in catalog

markets reference

Eval-only host-provided exchange and instrument metadata helpers. Values are stable metadata, not bar or snapshot market state.

Eval-only host-provided exchange and instrument metadata helpers. Values are stable metadata, not bar or snapshot market state.

markets.exchangeNames

markets.exchangeNames(category: string? = null) -> string[]

Lists exchange names, optionally filtered by category.

category filters the list, for example to "spot" or "futures". Omit it or use null for all exchanges. Names are sorted alphabetically. An unknown category returns an empty list.

The returned list is read-only. Call this inside a handler.

Example

script "Exchange Names"
input exchange = input.exchange("binancef", title: "Exchange")
data chart = subscribe(data.ohlcv, exchange: exchange)
plot last = plot.line(title: "Last")

on chart.update {
  let available = markets.exchangeNames("futures")
  if available.includes(exchange) {
    last.plot(chart.close)
  }
}

markets.symbolNames

markets.symbolNames(exchange: string) -> string[]

Lists the symbols available on an exchange.

exchange selects the exchange. Names are sorted alphabetically. An unknown exchange returns an empty list.

The list is read-only and does not depend on the current bar or snapshot.

Example

script "Symbol Names"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  let symbols = markets.symbolNames("binancef")
  last.plot(chart.close)
}

markets.exchangesForSymbol

markets.exchangesForSymbol(symbol: string) -> string[]

Lists the exchanges that offer a symbol.

symbol selects the symbol. Exchange names are sorted alphabetically. An unknown symbol returns an empty list.

The returned list is read-only. Call this inside a handler.

Example

script "Symbol Venues"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  let venues = markets.exchangesForSymbol("BTCUSDT")
  last.plot(chart.close)
}

markets.hasExchange

markets.hasExchange(exchange: string) -> bool

Reports whether an exchange name is known.

exchange must be one exchange name. A combined selection such as "binancef:bybitf" returns false. The result is never null and does not depend on live market updates.

Example

script "Has Exchange"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  if markets.hasExchange("binancef") {
    last.plot(chart.close)
  }
}

markets.hasSymbol

markets.hasSymbol(exchange: string, symbol: string) -> bool

Reports whether a symbol is listed on an exchange.

Checks whether exchange lists symbol. For a combined exchange selection, returns true if any member lists the symbol. If any member exchange is unknown, returns false.

The result is never null and does not depend on the current bar or snapshot.

Example

script "Has Symbol"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  if markets.hasSymbol("binancef", "BTCUSDT") {
    last.plot(chart.close)
  }
}

markets.exchangeCategory

markets.exchangeCategory(exchange: string) -> string

Returns an exchange's category, such as spot or futures.

exchange selects the exchange. An unknown name returns an empty string. Use markets.hasExchange to check a name before reading its category.

Example

script "Exchange Category"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  let category = markets.exchangeCategory("binancef")
  if category == "futures" {
    last.plot(chart.close)
  }
}

markets.symbolBase

markets.symbolBase(exchange: string, symbol: string) -> string

Returns the base asset of a symbol.

exchange and symbol select the listing. An unknown exchange or symbol returns an empty string. The result does not depend on the current bar.

For a combined exchange selection from markets.agg, reads the first exchange in alphabetical order that lists the symbol. If any exchange is unknown, or none lists the symbol, returns an empty string.

Example

script "Symbol Base"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  let base = markets.symbolBase("binancef", "BTCUSDT")
  if base == "BTC" {
    last.plot(chart.close)
  }
}

markets.symbolQuote

markets.symbolQuote(exchange: string, symbol: string) -> string

Returns the quote asset of a symbol.

exchange and symbol select the listing. An unknown exchange or symbol returns an empty string. The result does not depend on the current bar.

For a combined exchange selection from markets.agg, reads the first exchange in alphabetical order that lists the symbol. If any exchange is unknown, or none lists the symbol, returns an empty string.

Example

script "Symbol Quote"
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")

on chart.update {
  let quote = markets.symbolQuote("binancef", "BTCUSDT")
  if quote == "USDT" {
    last.plot(chart.close)
  }
}

markets.tickSize

markets.tickSize(exchange: string, symbol: string) -> float?

Returns the smallest price increment for a symbol.

exchange and symbol select the listing. An unknown listing or unavailable increment returns null.

For a combined exchange selection from markets.agg, returns the smallest available increment among exchanges that list the symbol. Exchanges without the symbol are skipped. If any exchange is unknown, none lists the symbol, or no increment is available, returns null.

Example

script "Tick Size"
data chart = subscribe(data.ohlcv)
plot ticks = plot.line(title: "Ticks")

on chart.update {
  let tick = markets.tickSize("binancef", "BTCUSDT") ?? 0.01
  ticks.plot((chart.close ?? 0.0) / tick)
}

markets.stepSize

markets.stepSize(exchange: string, symbol: string) -> float?

Returns the smallest quantity increment for a symbol.

exchange and symbol select the listing. An unknown listing or unavailable increment returns null.

For a combined exchange selection from markets.agg, returns the smallest available increment among exchanges that list the symbol. Exchanges without the symbol are skipped. If any exchange is unknown, none lists the symbol, or no increment is available, returns null.

Example

script "Step Size"
data chart = subscribe(data.ohlcv)
plot lots = plot.line(title: "Lots")

on chart.update {
  let step = markets.stepSize("binancef", "BTCUSDT") ?? 0.001
  lots.plot((chart.volume ?? 0.0) / step)
}

markets.agg

markets.agg(exchanges: string...) -> string

Builds the combined exchange selection.

Combines exchange names into a value you can pass to subscribe(exchange:). Names are sorted alphabetically and joined with ":": markets.agg("bybit", "binance") returns "binance:bybit". Exchange names are checked when you subscribe.

You can call this during setup. Changing an input used to choose the exchanges restarts the script with the new selection. Pass each exchange name as a separate argument.

Example

script "conf"

setup spec = markets.agg("binance", "bybit", "okx")

data chart = subscribe(data.ohlcv, exchange: spec)

plot out = plot.line(title: "out")

on chart.update {
  out.plot(chart.close)
}

On this page