Symbols
Functions of exchange objects specify an instrument with the string parameter symbol. The notation is defined by the platform and does not depend on the exchange's own API notation, so this part of the code does not change when you switch exchanges.
Omitting symbol
Single-instrument functions (GetTicker, GetDepth, GetTrades, GetRecords, GetHistoryOrders, etc.) act on the **current instrument** when symbol is omitted: the current trading pair is set by exchange.SetCurrency (initially the pair configured for the live trading or backtest), and for futures the contract code is set by exchange.SetContractType. Multi-instrument queries use a range when symbol is omitted; see "Query ranges" below.
Trading pairs
A spot instrument is written as "BASE_QUOTE" in upper case, separated by an underscore _: BTC_USDT is BTC quoted in USDT, ETH_BTC is ETH quoted in BTC.
Contracts
On a futures exchange object an instrument is written as "pair.contractCode", separated by .:
| Notation | Meaning |
|---|---|
BTC_USDT.swap | BTC USDT-margined perpetual |
BTC_USD.swap | BTC coin-margined perpetual |
BTC_USDT.quarter | BTC USDT-margined quarterly contract |
BTC_USD.this_week | BTC coin-margined weekly contract |
The quote currency tells the margin type: stablecoins such as USDT and USDC mean USDT-margined (linear), USD means coin-margined (inverse). The common contract codes are swap (perpetual), this_week, next_week, quarter and next_quarter; which ones an exchange supports is described in exchange.SetContractType.
The default contract of a cryptocurrency futures exchange object is the perpetual swap: until exchange.SetContractType() is called, market and trading functions called without symbol act on the perpetual contract of the current trading pair.
Options
An option is written as "pair.optionCode", where the option code is the exchange's own notation. For example, the Futures_Binance (Binance Futures) option BTC-240108-40000-C is written BTC_USDT.BTC-240108-40000-C.
Native codes
Commodity futures and stock exchanges (Futures_CTP (CTP commodity futures), Futures_Futu (Futu), Futures_IB (Interactive Brokers)) have no "pair.contractCode" split: the instrument is the exchange's native contract code, for example rb2501 on CTP. Futu and Interactive Brokers codes may themselves contain . (for example 00700.HK); the whole string is one instrument and is not split.
Query ranges
GetOrders, GetPositions, GetConditionOrders and GetFundings can query many instruments at once. symbol may be a specific instrument or a range written as "quote.contractType":
| symbol | Range |
|---|---|
USDT.swap | USDT-margined perpetuals |
USDT.futures | USDT-margined delivery contracts |
USD.swap | Coin-margined perpetuals |
USD.futures | Coin-margined delivery contracts |
USDT.option | USDT-margined options |
USD.option | Coin-margined options |
USD.futures_combo | Spread combos (Futures_Deribit inverse combos) |
USD.futures_ff | Linear delivery contracts (Futures_Kraken, contract codes ending in _ff) |
USD.swap_pf | Linear perpetuals (Futures_Kraken, contract code swap_pf) |
Use the quote currency the exchange actually uses (for example USDC.swap). A range the exchange API does not support is reported as an error and returns a null value.
Default range when symbol is omitted or an empty string ""
- Spot exchange objects: all instruments.
- Cryptocurrency futures exchange objects: "current quote currency + contract type of the current contract". The type is
futures_combofor a combo contract (a contract code containing a comma, such asquarter,swap, or a native Deribit combo code, such asBTC-FS-26DEC25_PERP),optionfor an option contract,swap_pfforswap_pf,futures_fffor codes ending in_ff,swapfor other codes containingswap, andfuturesotherwise; with no contract set it isswap. For example, with the current instrumentBTC_USDT.swapthis equals passingUSDT.swap; withBTC_USD.quarterit equalsUSD.futures; withBTC_USD.quarter,swapit equalsUSD.futures_combo. - Futures exchange objects without a "quote + contract type" split (
Futures_CTP,Futures_Futu,Futures_IB,Futures_Polymarket): all instruments. - A few exchanges require an instrument in their query API; on these exchanges
GetOrdersandGetConditionOrderswithoutsymbolquery only the current trading pair.
A successful query with no data in the range returns an empty array []; a failed call returns a null value, see Failures and null values. GetHistoryOrders and GetHistoryConditionOrders do not take ranges; without symbol they query the current instrument.