exchange.SetCurrency
Switches the current trading pair of the exchange object exchange.
exchange.SetCurrency(currency)Examples
Switch the trading pair and query the ticker and account before and after.
javascript
function main() {
var ticker = exchange.GetTicker()
Log(ticker)
Log(exchange.GetAccount())
// Switch the trading pair, note the changes in market data and account information after
// switching
exchange.SetCurrency("LTC_USDT")
Log("Switched to LTC_USDT")
ticker = exchange.GetTicker()
Log(ticker)
Log(exchange.GetAccount())
}
python
def main():
ticker = exchange.GetTicker()
Log(ticker)
Log(exchange.GetAccount())
exchange.SetCurrency("LTC_USDT")
Log("Switched to LTC_USDT")
ticker = exchange.GetTicker()
Log(ticker)
Log(exchange.GetAccount())
rust
fn main() {
let ticker = exchange.GetTicker(None).unwrap();
Log!(ticker);
Log!(exchange.GetAccount());
// Switch the trading pair, note the changes in market data and account information after
// switching
exchange.SetCurrency("LTC_USDT");
Log!("Switched to LTC_USDT");
let ticker = exchange.GetTicker(None).unwrap();
Log!(ticker);
Log!(exchange.GetAccount());
}Arguments
| Name | Type | Required | Description |
currency | string | Yes | Trading pair to switch to. The trading pair format is uniformly uppercase, using an underscore to separate |
See Also
Remarks
Compatible with the exchange.IO("currency", "BTC_USDT") switching method, see exchange.IO for details.
Switching trading pairs is supported in the backtesting system, but when switching trading pairs in the backtesting system, the name of the quote currency cannot be changed. For example: BTC_USDT can be switched to LTC_USDT, but cannot be switched to LTC_BTC.
After switching to a trading pair other than the one initially set on the backtesting page, the amount of the base currency is 0. For example: during backtesting, the trading pair initially set on the backtesting page is BTC_USDT, with 3 BTC and 10000 USDT. If you immediately switch to LTC_USDT at this point, the amount of the base currency after switching is 0, i.e., the amount of LTC in the account is 0; the amount of USDT is shared after switching, i.e., the amount remains 10000.