Closed HFLeon closed 3 years ago
Your url
contains a single quote at the end.
I would suggest following our installation guide and use this guide to help you with the order creation instead. It will ease you with such request format issues.
删除试了下,不是这个问题
Python-SDK中对应API的 proxy 在哪里设置,这个参数好像没开放呢
Configuration
有一个 proxy
字段可以设置 proxy 地址
` import time import hashlib import hmac import requests import json
def gen_sign(method, url, query_string=None, payload_string=None): key = '' # api_key secret = '' # api_secret t = time.time() m = hashlib.sha512() m.update((payload_string or "").encode('utf-8')) hashed_payload = m.hexdigest() s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t) sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest() return {'KEY': key, 'Timestamp': str(t), 'SIGN': sign}
if name == "main": url = "https://api.gateio.ws/api/v4/spot/orders'" common_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} body = {"currency_pair": "ETH_USDT", "account": "margin", "type": "limit", "side": "buy", "time_in_force": "poc", "amount": 0.01, "price": 2500.0, "text": "t-u7892308"} request_content = json.dumps(body) sign_headers = gen_sign('POST', '/api/v4/spot/orders', "", request_content) sign_headers.update(common_headers) print('signature headers: %s' % sign_headers) res = requests.post(url, headers=sign_headers, data=request_content) print(res.status_code) print(res.content) `