exchange.GetTicker
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.,
exchangeorexchanges[0]), the default contract is the perpetual contract (swap): ifexchange.SetContractType()has not been called, the market data functions return perpetual contract data. To use another contract, first set the contract code with theexchange.SetContractType()function. SeeSymbols.javascriptfunction 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) }pythondef 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"])rustfn 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
symbolparameter to request market data of a specific instrument (spot instrument).javascriptfunction main() { var ticker = exchange.GetTicker("BTC_USDT") Log(ticker) }pythondef main(): ticker = exchange.GetTicker("BTC_USDT") Log(ticker)rustfn main() { let ticker = exchange.GetTicker("BTC_USDT").unwrap(); Log!(ticker); }
Returns
| Type | Description |
|
|
Arguments
| Name | Type | Required | Description |
symbol | string | No | Instrument code, for example |
See Also
exchange.GetDepth exchange.GetTrades exchange.GetRecords exchange.GetTickers exchange.IO API rate limiting
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.