2.14 So rufen Sie die API der Börse auf
-
HttpQuery-Funktionen
Wenn Sie eine Exchange-API aufrufen, die keine Authentifizierung erfordert (z. B. eine API für Geschäftsinformationen, die nicht mit Kontoinformationen verbunden sind), beispielsweise:
https://www.okcoin.com/api/v1/future_estimated_price.do?symbol=btc_usd // 获取交割预估价HttpQuery("https://www.okcoin.com/api/v1/future_estimated_price.do?symbol=btc_usd")
https://www.okcoin.com/api/v1/future_hold_amount.do?symbol=btc_usd&contract_type=next_week // 获取合约持仓量HttpQuery("https://www.okcoin.com/api/v1/future_hold_amount.do?symbol=btc_usd&contract_type=next_week")
Die gewonnene Zeichenfolge ist im JSON-Format und kann mit der JSON.parse-Funktion als Objekt analysiert werden, um die Daten zu erhalten.
-
Exchange.IO-Funktion
Die Exchange-API, die die IO-Funktion aufruft, muss verifiziert werden (nicht unterstützt). Die API, die direkt mit HttpQuery zugänglich ist.
Für weitere Informationen siehe die API-Dokumentation.
因为python不支持HttpQuery,exchange.IO又必须要验证,所以我尝试用自带的urllip获取行情信息。但是Poloniex的API都有人工验证,你们是怎么解决的呢。
python 这样写,我也是 看gihub 上的还在学习:
def _call(self, mode, uri, data = None):
url = '%s://%s%s' % (SCHEME, self._host, uri)
# Log(mode + ' ' + url) # print
headers = DEFAULT_GET_HEADERS if mode=='GET' else DEFAULT_POST_HEADERS
req = request.Request(url, data = data, headers=headers, method=mode)
# Log("req:", req) # print
with request.urlopen(req, timeout=TIMEOUT) as resp:
if resp.getcode()!=200:
raise ApiNetworkError('Bad response code: %s %s' % (resp.getcode(), resp.reason))
return resp.read() # self._parse(resp.read())
发送 请求。
- 1


