In my previous articles about connecting to exchanges to obtain data, I didn't have to worry about network issues since I was running it directly on the foreign server I purchased. However, considering that most people are still running it locally and need to use a proxy, I recently took some time to try out the precautions for using a proxy locally.
First, if you only need to obtain data, you can do it without an apiKey
, just specify the proxy directly and initialize the exchange instance with the proxies
field:
exchange = ccxt.binance({
'timeout': 60000,
'proxies': {
'http': '127.0.0.1:7890',
'https': '127.0.0.1:7890',
}
})
exchange.load_markets()
The proxy software I use is clash, and the proxy port defaults to 7890.
You can search for other proxy software yourself, or you should be able to find it within the software. If it's some closed-source software, it might be a bit difficult to find, and you may have to capture packets to see.
For operations like trading, Binance requires setting an IP whitelist. If you don't have your own server, you can only set it to the IP of the purchased node, which might carry some risks, I think. It's still safer to run it on your own server.
You can check the IP of your proxy node by visiting this website: https://ipinfo.io/
However, for safety's sake, I still do not recommend using purchased airport nodes to run quantitative programs, but it is acceptable to experiment with a small funds account during the learning phase.