gateio / rest-v2

gateio Rest Api V2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

下单被拒绝,如何设置代理?

tqknight1984 opened this issue · comments

python3环境:
调用:
gate_trade.sell
or
gate_trade.buy

异常信息:Connection refused
应该是云服务不能访问api服务器,想设置代理。
比如想设置post代理请求,该如何修改一下代码?

def httpPost(url, resource, params, apiKey, secretKey):
headers = {
"Content-type" : "application/x-www-form-urlencoded",
"KEY":apiKey,
"SIGN":getSign(params, secretKey)
}

 conn = http.client.HTTPSConnection(url, timeout=10)

 tempParams = urllib.parse.urlencode(params) if params else ''
 print(tempParams)

 conn.request("POST", resource, tempParams, headers)
 response = conn.getresponse()
 data = response.read().decode('utf-8')
 params.clear()
 conn.close()
 return data

conn = http.client.HTTPSConnection('127.0.0.1', 1080, timeout=10)

可以尝试切换一下服务地址,如 api.gateio.life 或者 api.gateio.ws