The resource loading... loading...

exchange.GetTicker

Get the {@struct/Ticker Ticker} structure of the spot or contract corresponding to the currently set trading pair, contract code, i.e. the ticker data. GetTicker () function is a member function of the exchange object {@var/EXCHANGE exchange}, the use of exchange object member functions (methods) only related to exchange, and it will not be repeated in the document.

The exchange.GetTicker() function returns the {@struct/Ticker Ticker} structure when the request for data succeeds, and returns null value when the request for data fails. {@struct/Ticker Ticker}, null value

exchange.GetTicker() exchange.GetTicker(symbol)

The parameter symbol is used to specify the specific trading pair and contract code corresponding to the requested {@struct/Ticker Ticker} data. If this parameter is not passed, the market data of the currently set trading pair and contract code will be requested by default. When calling the exchange.GetTicker(symbol) function, exchange is the spot exchange object. If you need to request market data with the denominated currency as USDT and the trading currency as BTC, the parameter symbol is: "BTC_USDT", and the format is the trading pair format defined by the FMZ platform. When calling the exchange.GetTicker(symbol) function, exchange is the futures exchange object. If you need to request the market data of BTC’s U-standard perpetual contract, the parameter symbol is: "BTC_USDT.swap", and the format is a combination of the trading pair and contract code defined by the FMZ platform, separated by the character “.”. When calling the exchange.GetTicker(symbol) function, exchange is the futures exchange object. If you need to request the market data of BTC’s U-standard option contract, the parameter symbol is: "BTC_USDT.BTC-240108-40000-C" (taking Binance Option BTC-240108-40000-C as an example), the format is the combination of the trading pair defined by the FMZ platform and the specific option contract code defined by the exchange, separated by the character “.”.

symbol false string

function main(){
    // If it is a futures exchange object, set the contract code first, e.g. set it as a perpetual contract
    // exchange.SetContractType("swap")

    var ticker = exchange.GetTicker()
    /*
        The exchange interface may not be accessible due to network reasons (even if the docker program's device can open the exchange website, the API interface may not be accessible).
        At this point, the ticker is null, and it will cause an error when accessing ticker.High, so when testing this code, make sure that the exchange interface can be accessed.
    */
    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)
}
def 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"])
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);
}

For futures exchange objects (i.e., exchange or exchanges[0]), you need to set the contract code using the exchange.SetContractType() function before calling the ticker function, which will not be repeated.

function main() {
    var ticker = exchange.GetTicker("BTC_USDT")
    Log(ticker)
}
def main():
    ticker = exchange.GetTicker("BTC_USDT")
    Log(ticker)
void main() {
    auto ticker = exchange.GetTicker("BTC_USDT");
    Log(ticker);
}

Use the symbol parameter to request market data for a specific symbol (spot symbol).

The Ticker data returned by the exchange.GetTicker() function in the backtesting system. Where High and Low are simulated values, taken from the sell one and buy one of the market at that time. The Ticker data returned by the exchange.GetTicker() function in the real market. Where the High and Low values are based on the data returned by the encapsulated exchange 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

{@fun/Market/exchange.GetDepth exchange.GetDepth}, {@fun/Market/exchange.GetTrades exchange.GetTrades}, {@fun/Market/exchange.GetRecords exchange.GetRecords}, {@fun/Market/exchange.GetTickers exchange.GetTickers}

Log exchange.GetDepth