markets reference
Facts about exchanges and symbols.
Look up exchange categories, listed symbols, base and quote assets, tick and step sizes, and build combined exchange selections.
Functions
markets.agg
markets.agg(exchanges: string...) -> stringBuilds 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.
| Parameter | Type |
|---|---|
exchanges | string |
Returns string
markets.exchangeCategory
markets.exchangeCategory(exchange: string) -> stringReturns 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.
| Parameter | Type |
|---|---|
exchange | string |
Returns string
Available in Handlers and functions called from handlers.
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.
| Parameter | Type |
|---|---|
category | string? |
Returns string[]
Available in Handlers and functions called from handlers.
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.
| Parameter | Type |
|---|---|
symbol | string |
Returns string[]
Available in Handlers and functions called from handlers.
markets.hasExchange
markets.hasExchange(exchange: string) -> boolReports 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.
| Parameter | Type |
|---|---|
exchange | string |
Returns bool
Available in Handlers and functions called from handlers.
markets.hasSymbol
markets.hasSymbol(exchange: string, symbol: string) -> boolReports 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.
| Parameter | Type |
|---|---|
exchange | string |
symbol | string |
Returns bool
Available in Handlers and functions called from handlers.
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.
| Parameter | Type |
|---|---|
exchange | string |
symbol | string |
Returns float?
Available in Handlers and functions called from handlers.
markets.symbolBase
markets.symbolBase(exchange: string, symbol: string) -> stringReturns 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.
| Parameter | Type |
|---|---|
exchange | string |
symbol | string |
Returns string
Available in Handlers and functions called from handlers.
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.
| Parameter | Type |
|---|---|
exchange | string |
Returns string[]
Available in Handlers and functions called from handlers.
markets.symbolQuote
markets.symbolQuote(exchange: string, symbol: string) -> stringReturns 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.
| Parameter | Type |
|---|---|
exchange | string |
symbol | string |
Returns string
Available in Handlers and functions called from handlers.
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.
| Parameter | Type |
|---|---|
exchange | string |
symbol | string |
Returns float?
Available in Handlers and functions called from handlers.