exchange.GetTicker
Get the Ticker structure corresponding to the currently set trading pair or contract code, i.e., market data. The GetTicker() function is a member function of the exchange object exchange. The member functions (methods) of the exchange object are only related to exchange, which will not be repeated in subsequent documentation.
exchange.GetTicker()
exchange.GetTicker(symbol)Examples
-
For futures exchange objects (i.e.,
exchangeorexchanges[0]), you need to use theexchange.SetContractType()function to set the contract code before calling market data functions. This will not be repeated in subsequent documentation.javascriptfunction main(){ // If it's a futures exchange object, first set the contract code, for example, set it to perpetual contract // exchange.SetContractType("swap") var ticker = exchange.GetTicker() /* Due to network reasons, the exchange API may not be accessible (even if the device where the bot is hosted can open the exchange website, the API interface may still be inaccessible) In this case, ticker will be null, and accessing ticker.High will cause an error, so when testing this code, ensure that the exchange API is accessible */ 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() 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"])c++void main() { auto ticker = exchange.GetTicker(); 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 for a specific symbol (spot symbol).javascriptfunction main() { var ticker = exchange.GetTicker("BTC_USDT") Log(ticker) }pythondef main(): ticker = exchange.GetTicker("BTC_USDT") Log(ticker)c++void main() { auto ticker = exchange.GetTicker("BTC_USDT"); Log(ticker); }
Returns
| Type | Description |
| The |
Arguments
| Name | Type | Required | Description |
symbol | string | No | The When calling the When calling the When calling the |
See Also
exchange.GetDepth exchange.GetTrades exchange.GetRecords exchange.GetTickers exchange.IO (API rate limit control)
Remarks
In the backtesting system, the Ticker data returned by the exchange.GetTicker() function has simulated values for High and Low, taken from the best ask and best bid at that time.
In live trading, the Ticker data returned by the exchange.GetTicker() function has High and Low values determined by the data returned from the exchange's encapsulated Tick interface, which includes the highest and lowest prices within a certain period (usually a 24-hour period).
Exchanges that do not support the exchange.GetTicker() function:
| Function Name | Unsupported Spot Exchanges | Unsupported Futures Exchanges |
|---|---|---|
| GetTicker | -- | Futures_Aevo |