2.14 Cara memanggil API bursa

Penulis:Mimpi kecil, Dicipta: 2017-05-02 11:53:48, Dikemas kini: 2017-10-11 10:23:02

2.14 Cara memanggil API bursa

  • Fungsi HttpQuery

    img

    Apabila memanggil API pertukaran yang tidak memerlukan pengesahan (seperti API maklumat pasaran yang tidak berkaitan dengan maklumat akaun), contohnya:

    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”)

    String dalam format JSON boleh digunakan untuk mendapatkan data dengan menggunakan fungsi JSON.parse.

  • exchange.IOFungsi

    img

    API bursa yang dipanggil oleh fungsi IO mestilah memerlukan pengesahan (tidak disokong API yang boleh diakses secara langsung dengan HttpQuery).

    Penggunaan khusus boleh dilihat dalam dokumentasi API.


Lebih lanjut

qq47898077 因为python不支持HttpQuery,exchange.IO又必须要验证,所以我尝试用自带的urllip获取行情信息。但是Poloniex的API都有人工验证,你们是怎么解决的呢。

Mimpi kecilSaya juga menonton di gihub dan masih belajar: `` 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Pergilah. req = request.Request ((url, data = data, header = header, method = mode) # Log (("req:", req) # print dengan request.urlopen ((req, timeout=TIMEOUT) sebagai resp: if resp.getcode (()!=200: raise ApiNetworkError (('Bad response code: %s %s' % (resp.getcode(), resp.reason)) return resp.read ((() # self._parse ((resp.read))) `` Menghantar permintaan.