Type/to search
Built-in Functions
Global
Log
Market
exchange.GetTicker
exchange.GetTickers
exchange.GetDepth
exchange.GetTrades
exchange.GetRecords
exchange.GetMarkets
exchange.GetRawJSON
exchange.SetData
exchange.GetData
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Gets the Ticker structure (market data) of a spot instrument or contract; without symbol it uses the currently set trading pair and contract code. GetTicker() is a member function of the exchange object exchange and acts only on the account bound to that exchange object (with several accounts, use exchanges[i].GetTicker() to pick one).

exchange.GetTicker()
exchange.GetTicker(symbol)

Examples

  • For a cryptocurrency futures exchange object (i.e., exchange or exchanges[0]), the default contract is the perpetual contract (swap): if exchange.SetContractType() has not been called, the market data functions return perpetual contract data. To use another contract, first set the contract code with the exchange.SetContractType() function. See Symbols.

    javascript
    function main(){ // Futures objects default to the perpetual contract; set another one first if needed: // exchange.SetContractType("quarter") var ticker = exchange.GetTicker() if (!ticker) return // null on failure (e.g. the exchange API is unreachable) Log("Symbol:", ticker.Symbol, "High:", ticker.High, "Low:", ticker.Low, "Sell:", ticker.Sell, "Buy:", ticker.Buy, "Last:", ticker.Last, "Open:", ticker.Open, "Volume:", ticker.Volume) }
    python
    def main(): ticker = exchange.GetTicker() if not ticker: return Log("Symbol:", ticker["Symbol"], "High:", ticker["High"], "Low:", ticker["Low"], "Sell:", ticker["Sell"], "Buy:", ticker["Buy"], "Last:", ticker["Last"], "Open:", ticker["Open"], "Volume:", ticker["Volume"])
    rust
    fn main() { // Futures objects default to the perpetual contract; set another one first if needed: // exchange.SetContractType("quarter").unwrap(); let Ok(ticker) = exchange.GetTicker(None) else { return }; Log!("Symbol:", ticker.Symbol, "High:", ticker.High, "Low:", ticker.Low, "Sell:", ticker.Sell, "Buy:", ticker.Buy, "Last:", ticker.Last, "Open:", ticker.Open, "Volume:", ticker.Volume); }
  • Use the symbol parameter to request market data of a specific instrument (spot instrument).

    javascript
    function main() { var ticker = exchange.GetTicker("BTC_USDT") Log(ticker) }
    python
    def main(): ticker = exchange.GetTicker("BTC_USDT") Log(ticker)
    rust
    fn main() { let ticker = exchange.GetTicker("BTC_USDT").unwrap(); Log!(ticker); }

Returns

TypeDescription

Ticker / null value

Ticker structure on success; null value on failure.

Arguments

NameTypeRequiredDescription

symbol

string

No

Instrument code, for example BTC_USDT on a spot exchange object or BTC_USDT.swap on a futures exchange object; the notation (including options) is described in Symbols. If omitted, the market data of the current trading pair and contract code is requested.

See Also

Remarks

In the backtesting system, in the Ticker data returned by the exchange.GetTicker() function, High and Low are simulated values, taken from the best ask price and best bid price of the order book at that time.

In live trading, in the Ticker data returned by the exchange.GetTicker() function, the values of High and Low are determined based on the data returned by the wrapped exchange's Tick interface. This data contains the highest price and lowest price within a certain period (usually a 24-hour period).

On-chain swap exchanges (such as Uniswap and Jupiter) have no order book and no 24h statistics: Buy and Sell are executable quotes for a certain size (about $1000) and Last is their midpoint; the values of High, Low, Volume and the other fields are given on the exchange pages, for example Uniswap and Jupiter.

Exchanges that do not support this function: Web3. The call fails with an error and returns null; for all exchanges see Capability Matrix.