2.14 Cách gọi API của sàn giao dịch

Tác giả:Giấc mơ nhỏ, Tạo: 2017-05-02 11:53:48, Cập nhật: 2017-10-11 10:23:02

2.14 Cách gọi API của sàn giao dịch

  • HttpQuery

    img

    Khi gọi một số API giao dịch không cần xác thực (ví dụ như API thông tin thị trường không liên quan đến thông tin tài khoản), ví dụ:

    https://www.okcoin.com/api/v1/future_estimated_price.do?symbol=btc_usd // 获取交割预估价
    

    HttpQueryhttps://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  // 获取合约持仓量
    

    HttpQueryhttps://www.okcoin.com/api/v1/future_hold_amount.do?symbol=btc_usd&contract_type=next_week”)

    Dữ liệu được lấy từ các chuỗi trong định dạng JSON có thể được phân tích với các đối tượng bằng JSON.parse.

  • exchange.IOChức năng

    img

    API giao dịch để gọi hàm IO phải được xác minh (không hỗ trợ các API có thể truy cập trực tiếp bằng HttpQuery).

    Sử dụng cụ thể có thể được xem trong tài liệu API.


Thêm nữa

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

Giấc mơ nhỏTôi cũng đang xem trên gihub và đang học: `` 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 Các tiêu đề của bài đăng được hiển thị ở đây Không. 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))) `` Gửi yêu cầu.