exchange.SetProxy
The exchange.SetProxy() function is used to set the proxy configuration for the exchange exchange object.
exchange.SetProxy(proxy)Examples
-
Configure
socks5proxy forexchangeexchange object:javascriptfunction main() { exchange.SetProxy("socks5://192.168.1.10:8080") // 如果访问不到交易所行情接口,设置一个可用的ss5代理,就可以访问到行情接口了 Log(exchange.GetTicker()) }pythondef main(): exchange.SetProxy("socks5://192.168.1.10:8080") Log(exchange.GetTicker())c++void main() { exchange.SetProxy("socks5://192.168.1.10:8080"); Log(exchange.GetTicker()); } -
In addition to **globally specifying** the IP address for requests sent by the
exchangeexchange object, it also supports specifying IP addresses based onexchange:javascriptfunction main(){ exchange.SetProxy("ip://10.0.3.15") // 发出的请求IP地址为10.0.3.15 exchange.GetTicker() }pythondef main(): exchange.SetProxy("ip://10.0.3.15") exchange.GetTicker()c++void main() { exchange.SetProxy("ip://10.0.3.15"); exchange.GetTicker(); }
Arguments
| Name | Type | Required | Description |
proxy | string | Yes | The |
See Also
Remarks
If the proxy setting fails, calling the exchange.SetProxy() function will return null.
The proxy setting functionality of the exchange.SetProxy() function only supports the rest protocol. Each exchange exchange object can set one proxy. After setting the proxy, all access to the exchange interface bound to the exchange exchange object will be accessed through the proxy.
Supports setting socks5 proxy, taking the first added exchange object exchange (i.e., exchanges[0]) as an example:
-
Set proxy (no username, no password):
exchange.SetProxy("socks5://127.0.0.1:8889"). -
Set proxy (with username and password):
exchange.SetProxy("socks5://username:[email protected]:8889"). Whereusernameis the username andpasswordis the password. -
Switch to normal mode (without proxy):
exchange.SetProxy("").
Supports setting the IP address for requests sent by the exchange exchange object, global specification.