资源加载中... loading...

exchange.SetCurrency


exchange.SetCurrency(currency)

```currency```参数用于设置切换的交易对,交易对格式统一为大写,使用下划线分隔```baseCurrency```与```quoteCurrency```,例如:```BTC_USDT```。
currency
true
string

```javascript
function main() {
    var ticker = exchange.GetTicker() 
    Log(ticker)
    Log(exchange.GetAccount())    
    // 切换交易对,注意切换后行情数据,账户信息的变化
    exchange.SetCurrency("LTC_USDT")
    Log("切换为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("切换为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("切换为LTC_USDT");
    ticker = exchange.GetTicker();
    Log(ticker);
    Log(exchange.GetAccount());
}

1、兼容exchange.IO("currency", "BTC_USDT")切换方式,参考{@fun excahnge.IO}。 2、支持回测系统中切换交易对,回测系统中切换交易对时计价币名称不能改变。例如:BTC_USDT可以切换为LTC_USDT,不能切换为LTC_BTC。 3、切换为非回测页面初始设置的交易对后交易币的数量为0。例如:回测时回测页面上初始设置的交易对为BTC_USDTBTC数量为3个,USDT数量为10000。此时立即切换为LTC_USDT,切换后交易币数量为0,即账户中LTC数量为0,切换的交易对共享USDT数量,数量为10000。

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

exchange.GetCurrency exchange.GetQuoteCurrency