exchange.SetCurrency
The exchange.SetCurrency() function is used to switch the current trading pair of the exchange object exchange.
exchange.SetCurrency(currency)Examples
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());
}
c++
void main() {
auto 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());
}Arguments
| Name | Type | Required | Description |
currency | string | Yes | The |
See Also
Remarks
-
Compatible with the
exchange.IO("currency", "BTC_USDT")switching method, seeexcahnge.IOfor 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_USDTcan be switched toLTC_USDT, but cannot be switched toLTC_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 3BTCand 10000USDT. If you immediately switch toLTC_USDTat this point, the amount of the base currency after switching is 0, i.e., the amount ofLTCin the account is 0; the amount ofUSDTis shared after switching, i.e., the amount remains 10000.