Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
exchange.GetName
exchange.GetLabel
exchange.GetCurrency
exchange.SetCurrency
exchange.GetQuoteCurrency
exchange.GetPeriod
exchange.SetMaxBarLen
exchange.SetPrecision
exchange.GetRate
exchange.SetRate
exchange.SetBase
exchange.GetBase
exchange.SetProxy
exchange.SetTimeout
exchange.Encode
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Sets the proxy configuration of the exchange object.

exchange.SetProxy(proxy)

Examples

Configure a socks5 proxy for the exchange object.

javascript
function main() { exchange.SetProxy("socks5://192.168.1.10:8080") // If the exchange market data API is unreachable, set a working socks5 proxy to reach it Log(exchange.GetTicker()) }
python
def main(): exchange.SetProxy("socks5://192.168.1.10:8080") Log(exchange.GetTicker())
rust
fn main() { exchange.SetProxy("socks5://192.168.1.10:8080"); // If the exchange market data API is unreachable, set a working socks5 proxy to reach it Log!(exchange.GetTicker(None)); }

Returns

TypeDescription

bool / null value

Returns true on success; if the proxy format is invalid (unsupported scheme or missing host and port), returns a null value, the error message can be obtained with GetLastError, and the previous proxy setting stays unchanged.

Arguments

NameTypeRequiredDescription

proxy

string

Yes

Proxy configuration in the form scheme://[username:password@]host:port; pass an empty string to remove the proxy.

See Also

Remarks

Each exchange object can have one proxy. Once set, the exchange object's network requests to the exchange (REST requests and the WebSocket connections opened by the exchange connector) go through the proxy.

Supported proxy schemes: http://, https://, socks5://, socks5h:// (domain names resolved by the proxy server) and ssocks5:// (socks5 over TLS), all of which can carry a username and password. Taking the first added exchange object exchange, i.e. exchanges[0], as an example:

  • Set a proxy without username or password: exchange.SetProxy("socks5://127.0.0.1:8889").
  • Set a proxy with username and password: exchange.SetProxy("socks5://username:[email protected]:8889"), where username is the username and password is the password.
  • Switch back to normal mode without a proxy: exchange.SetProxy("").

Specifying the source IP address of requests per exchange object (the legacy ip:// form) is not supported. To specify the outgoing IP, set it globally with the -I command-line option when starting the docker.