banner
stmoonar

stmoonar

无心而为
github
telegram
email
zhihu
x

Binance API Usage (Supplement, Local Proxy)

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 proxies, I recently took some time to try out the precautions for using proxies 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.

image

You can search for other proxy software on your own, 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.

image

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 risk, 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/

image

However, for safety's sake, I still do not recommend using purchased airport nodes to run quantitative programs. But during the learning phase, using a small fund account for experiments is still acceptable.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.