The resource loading... loading...

NetSettings

exchange.SetBase

The exchange.SetBase() function is used to set the base address of the exchange API interface configured in the {@var/EXCHANGE exchange} exchange object.

exchange.SetBase(s)

The s parameter is used to specify the exchange API interface base address. s true string

function main() {
    // Use default base address
    Log(exchange.GetTicker())
    // Switch to https://aws.okx.com
    exchange.SetBase("https://aws.okx.com")
    Log(exchange.GetTicker())
}
def main():
    Log(exchange.GetTicker())
    exchange.SetBase("https://aws.okx.com")
    Log(exchange.GetTicker())
void main() {
    Log(exchange.GetTicker());
    exchange.SetBase("https://aws.okx.com");
    Log(exchange.GetTicker());
}

Switching the exchange API base address is not supported in the backtesting system, because the backtesting system is a sandbox simulation environment and it does not really access the exchange API interface.

{@fun/Trade/exchange.IO exchange.IO}

exchange.GetBase

The exchange.GetBase() function is used to get the current exchange API interface base address.

The current exchange API interface base address. string

exchange.GetBase()

function main() {
    Log(exchange.GetBase())
}
def main():
    Log(exchange.GetBase())
void main() {
    Log(exchange.GetBase());
}

{@fun/NetSettings/exchange.SetBase exchange.SetBase}

exchange.SetProxy

The exchange.SetProxy() function is used to set the proxy configuration of the {@var/EXCHANGE exchange} exchange object.

exchange.SetProxy(proxy)

The proxy parameter is used to specify the proxy configuration. proxy true string

function main() {
    exchange.SetProxy("socks5://192.168.1.10:8080")
    // If you can't access the exchange ticker interface, set up an available ss5 proxy and you can access the ticker interface
    Log(exchange.GetTicker())
}
def main():
    exchange.SetProxy("socks5://192.168.1.10:8080")
    Log(exchange.GetTicker())
void main() {
    exchange.SetProxy("socks5://192.168.1.10:8080");
    Log(exchange.GetTicker());
}

Configure the {@var/EXCHANGE exchange} exchange object socks5 proxy:

function main(){
    exchange.SetProxy("ip://10.0.3.15")
    // The requested IP address is 10.0.3.15
    exchange.GetTicker()
}
def main():
    exchange.SetProxy("ip://10.0.3.15")
    exchange.GetTicker()
void main() {
    exchange.SetProxy("ip://10.0.3.15");
    exchange.GetTicker();
}

In addition to global specification of the IP address of the request from the {@var/EXCHANGE exchange} exchange object, there is also support for specifying an IP address based on {@var/EXCHANGE exchange}:

If the proxy setting fails, the exchange.SetProxy() function will return null when called. The exchange.SetProxy() function sets the proxy for the rest protocol only. One proxy can be set for each {@var/EXCHANGE exchange} exchange object, and access to the exchange interface bound to the {@var/EXCHANGE exchange} exchange object after setting the proxy will be accessed through the proxy. Support for setting socks5 proxy, taking the first exchange object added {@var/EXCHANGE exchange} i.e.: exchanges[0] as an example:

  • Set proxy, no username, no password: exchange.SetProxy("socks5://127.0.0.1:8889").
  • Set proxy, enter username and password: exchange.SetProxy("socks5://username:password@127.0.0.1:8889"). username is the user name and password is the password.
  • Switch to normal mode without proxy: exchange.SetProxy("").

Supports setting the IP address of the request from the {@var/EXCHANGE exchange} exchange object, globally specified.

{@var/EXCHANGE exchange}

exchange.SetTimeout

The exchange.SetTimeout() function is used to set the timeout of the rest request for the {@var/EXCHANGE exchange} exchange object.

exchange.SetTimeout(timeout)

The timeout parameter is used to specify the number of milliseconds for the timeout setting. timeout true number

function main() {
    exchange.SetTimeout(3000)
    Log(exchange.GetTicker())
}
def main():
    exchange.SetTimeout(3000)
    Log(exchange.GetTicker())
void main() {
    exchange.SetTimeout(3000);
    Log(exchange.GetTicker());
}

The parameter timeout is a millisecond value, 1000 milliseconds equals 1 second. Restricted to the rest protocol only, used to set the timeout on rest requests, it takes effect by setting once only. For example, exchange.SetTimeout(3000), sets the rest request timeout for the exchange exchange object to 3 seconds. Calling functions with network requests such as exchange.GetTicker() that do not receive an answer for more than 3 seconds will time out, and function calls that do time out will return null values. SetTimeout() is not a global function, it is a method of the {@var/EXCHANGE exchange} exchange object.

{@var/EXCHANGE exchange}

Futures Threads