The resource loading... loading...

exchange.SetCurrency

The exchange.SetCurrency() function is used to switch the current trading pair of the exchange object {@var/EXCHANGE exchange}.

exchange.SetCurrency(currency)

The currency parameter is used to set the trading pair to be switched. The trading pair format is uppercase uniformly, using an underscore to separate baseCurrency from quoteCurrency, such as BTC_USDT. currency true string

function main() {
    var ticker = exchange.GetTicker() 
    Log(ticker)
    Log(exchange.GetAccount())    
    // Switching trading pairs, pay attention to the changes of ticker data and account information after switching
    exchange.SetCurrency("LTC_USDT")
    Log("Switch to LTC_USDT")
    ticker = exchange.GetTicker()
    Log(ticker)
    Log(exchange.GetAccount())
}
def main():
    ticker = exchange.GetTicker()
    Log(ticker)
    Log(exchange.GetAccount())
    exchange.SetCurrency("LTC_USDT")
    Log("Switch to LTC_USDT")
    ticker = exchange.GetTicker()
    Log(ticker)
    Log(exchange.GetAccount())
void main() {
    auto ticker = exchange.GetTicker();
    Log(ticker);
    Log(exchange.GetAccount());
    exchange.SetCurrency("LTC_USDT");
    Log("Switch to LTC_USDT");
    ticker = exchange.GetTicker();
    Log(ticker);
    Log(exchange.GetAccount());
}
  1. Compatible with exchange.IO("currency", "BTC_USDT") switching method, please refer to {@fun excahnge.IO}.
  2. Support switching trading pairs in the backtesting system, the name of the denominated currency cannot be changed when switching trading pairs in the backtesting system. For example: BTC_USDT can be switched to LTC_USDT, not to LTC_BTC.
  3. The number of trading currencies is 0 after switching to the trading pair initially set on the non-backtest page. For example, when backtesting the initial trading pair set on the backtest page is BTC_USDT, the number of BTC is 3, the number of USDT is 10000. At this time, switch to LTC_USDT immediately, the number of trading currencies is 0 after switching, i.e. the number of LTC_USDT in the account is 0. That is, the number of LTC in the account is 0, and the switched trading pair shares the number of USDT, which is 10000.

{@fun/Account/exchange.GetCurrency exchange.GetCurrency}

exchange.GetCurrency exchange.GetQuoteCurrency