Proxy Configuration
HTTP API
The following code demonstrates setting up an HTTPS proxy and actively turning off certificate verification (because the proxy's certificate in the example is self-signed).
- Python
- Java
Support setting HTTP/HTTPS proxy through environment variables
- Set the environment variable HTTP_PROXY
- Set the environment variable HTTPS_PROXY
import os
from webullsdkcore.client import ApiClient
proxy_host = "127.0.0.1"
proxy_port = 8888
# Set the proxy for HTTPS to 127.0.0.1:8888
os.environ['HTTPS_PROXY'] = proxy_host + ":" + str(proxy_port)
# Set verify to False, which means that the certificate provided by the proxy will not be verified
client = ApiClient(app_key="<your_app_key>", app_secret="<your_app_secret>", region_id="<region_id>", verify=False)
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.regionId(Region.us.name())
// Set the proxy for HTTPS to 127.0.0.1:8888; Set ignoreSSL to true, which means that the certificate provided by the proxy will not be verified
.runtimeOptions(new RuntimeOptions().proxy(ProxyType.HTTPS, "https://127.0.0.1:8888").ignoreSSL(true))
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
Quotes Subscription
- Python
- Java
Support setting proxy by calling proxy_set
method. The following code demonstrates setting Socks5 proxy.
import socks
from webullsdkmdata.quotes.subscribe.default_client import DefaultQuotesClient
proxy_host = "127.0.0.1"
proxy_port = 9080
quotes_client = DefaultQuotesClient("<your_app_key>", "<your_app_secret>", region_id="<region_id>")
# Set socks5 proxy to 127.0.0.1:9080
quotes_client.proxy_set(proxy_type=socks.SOCKS5, proxy_addr=proxy_host, proxy_port=proxy_port)
Support setting proxy by calling proxy
method. The following code demonstrates setting Socks5 proxy.
QuotesSubsClient client = QuotesSubsClient.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.regionId(Region.us.name())
// Set socks5 proxy to 127.0.0.1:9080
.proxy(ProxyConfig.builder().protocol(ProxyType.SOCKS5).host("127.0.0.1").port(9080).build())
.build()
Trade Events Subscription / Quotes API
- Python
- Java
Similar to the HTTP API, and it supports setting the proxy through environment variables.
- Set the environment variable grpc_proxy
- Set the environment variable https_proxy
- Set the environment to connect http_proxy
Priority from 1 to 3
Start the JVM with -Dhttps.proxyHost=<host> -Dhttps.proxyPort=<port>
to configure the proxy.