exchange.IO("currency", ...)
Switches the current trading pair of the exchange object at runtime.
exchange.IO(k, symbol)Examples
Switch trading pair at runtime.
javascript
function main() {
// For example, when the live bot starts, the exchange object's current trading pair is BTC_USDT; print the ticker of the current trading pair
Log(exchange.GetTicker())
// Switch the trading pair to LTC_BTC
exchange.IO("currency", "LTC_BTC")
Log(exchange.GetTicker())
}
python
def main():
Log(exchange.GetTicker())
exchange.IO("currency", "LTC_BTC")
Log(exchange.GetTicker())
rust
fn main() {
// For example, when the live bot starts, the exchange object's current trading pair is BTC_USDT; print the ticker of the current trading pair
Log!(exchange.GetTicker(None));
// Switch the trading pair to LTC_BTC
let _ = exchange.IO(("currency", "LTC_BTC"));
Log!(exchange.GetTicker(None));
}Returns
| Type | Description |
bool / null value | Returns |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Selects the |
symbol | string | Yes | Trading pair, upper case and underscore-separated, e.g. |
See Also
Remarks
Switching Trading Pairs at Runtime (currency mode)
javascript
exchange.IO("currency", "ETH_USDT")
Used to dynamically switch trading pairs at runtime. The trading pair format is uppercase letters separated by an underscore. This instruction is equivalent to exchange.SetCurrency.
In backtesting mode, only spot is supported, and you can only switch to a trading pair with the same quote currency. For futures, the contract code is kept after switching the trading pair; call
exchange.SetContractType()when you need a different contract.