Skip to content

Updated

Proxy for trading bots:
set it for both REST and WebSocket in ccxt and Freqtrade

  1. In ccxt, set both httpsProxy (REST) and wsProxy (WebSocket) on the exchange object to the same proxy; for SOCKS5 use socksProxy and wsSocksProxy.
  2. Freqtrade's HTTP_PROXY variable does not cover exchange requests, so set httpsProxy and wsProxy under exchange.ccxt_config in the config file.
  3. Use a Proxy302 per-GB static IP generated with “Opens crypto exchanges” ticked, click Lock this line, and add its exit IP to the exchange's API whitelist.

Check it right after buyingExample output

curl -x http://USER:PASS@HOST:PORT https://ipinfo.io/json

ip
203.0.113.24
country
US
Matches the country you picked
Day 15
203.0.113.24
Same address for the whole term
Example addresses (203.0.113.0/24), not real exits
01 / 06Why half a proxy setup fails

A half-configured proxy is the most common reason a trading bot hits API whitelist errors.

Why half a proxy setup fails

The ccxt manual says httpProxy and httpsProxy only affect non-WebSocket requests; WebSocket connections need wsProxy or wssProxy as well. With only httpsProxy set, orders go through the proxy while market-data streams leave from your own IP.

Freqtrade is the same: its HTTP_PROXY and HTTPS_PROXY variables apply to Telegram, CoinGecko and the rest, but not to exchange requests. Those take the proxy from ccxt_config in the config file.

When the API key is bound to an IP whitelist, any request that leaves from another IP is rejected.

Set it up in 4 steps

  1. Get the proxy details

    In My proxies, find the per-GB static line generated with “Opens crypto exchanges” ticked, click Lock this line, then copy host, port, username and password into http://USERNAME:PASSWORD@HOST:PORT. For SOCKS5 use socks5://.

  2. ccxt: set both properties

    Set httpsProxy and wsProxy on the exchange object; see the ccxt example below.

  3. Freqtrade: put it in ccxt_config

    Add ccxt_config under exchange in your config file; see the Freqtrade example below.

  4. Check the exit

    On the same machine, open ipinfo.io through the proxy; the exit IP should be the one in your API whitelist.

ccxt example (Python)

import ccxt

ex = ccxt.kraken({"apiKey": "...", "secret": "..."})
proxy = "http://USERNAME:PASSWORD@HOST:PORT"
ex.httpsProxy = proxy   # REST
ex.wsProxy = proxy      # WebSocket (ccxt.pro)
print(ex.fetch_balance())

REST and WebSocket use the same proxy; replace USERNAME, PASSWORD, HOST and PORT with the values in My proxies.

Freqtrade example (config.json)

{
  "exchange": {
    "name": "kraken",
    "ccxt_config": {
      "httpsProxy": "http://USERNAME:PASSWORD@HOST:PORT",
      "wsProxy": "http://USERNAME:PASSWORD@HOST:PORT"
    }
  }
}

Exchange requests take the proxy from ccxt_config; environment variables do not reach them.

FAQ

How do I use SOCKS5?

In ccxt set socksProxy and wsSocksProxy to socks5://USERNAME:PASSWORD@HOST:PORT.

The exchange says my IP is not whitelisted

Check that both REST and WebSocket use the proxy, then open ipinfo.io through it and compare the exit IP with the whitelist. If the line was swapped, update the whitelist.

Can several bots share one line?

Technically yes, but whitelists and troubleshooting get mixed up. Usually give each strategy or server its own line and whitelist each one.

Further reading

Setup guides Proxy302 publishes on GitHub on the same topic:

Reference links

3
  1. ccxt Manual: Proxy

    Official documentation · Confirmed on:

    ccxt exchange properties httpProxy/httpsProxy apply to non-WebSocket requests only; WebSocket connections need wsProxy or wssProxy as well; SOCKS uses socksProxy and wsSocksProxy.

  2. Freqtrade docs: Using a proxy with Freqtrade

    Official documentation · Confirmed on:

    HTTP_PROXY/HTTPS_PROXY environment variables apply to everything except exchange requests; exchange requests take the proxy from exchange.ccxt_config (httpsProxy, wsProxy).

  3. Proxy302 product fact sheet and My proxies

    Product observation · Confirmed on:

    Static lines are HTTP or SOCKS5 as chosen at generation; My proxies shows host, port, username and password with copy buttons; Lock this line stops automatic swaps.

Ready to try it?

Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.