Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
exchange.IO
exchange.IO("api", ...)
exchange.IO("currency", ...)
exchange.IO("base", ...)
exchange.IO(mode, value)
exchange.IO("rate", ...)
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

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

TypeDescription

bool / null value

Returns true on success; returns a null value if the trading pair format is invalid, and the current trading pair stays unchanged.

Arguments

NameTypeRequiredDescription

k

string

Yes

Selects the exchange.IO() feature; currency switches the trading pair.

symbol

string

Yes

Trading pair, upper case and underscore-separated, e.g. ETH_USDT.

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.