使用python通過聚幣API擷取價格資料

來源:互聯網
上載者:User

聚幣官網API並沒有給出樣本,相當扯淡

# -*-coding=utf-8-*-'''功能:從聚幣中擷取幣的各種資訊1,比特幣(btc)2,以太坊(ETH)6,其他'''import requests'''函數命:real_time_ticker功能:擷取某個幣的即時價格傳回值內容:high - 最高價low - 最低價buy - 買一價sell - 賣一價last - 最近一次成交價vol - 成交量volume - 成交額'''def real_time_ticker(coin):    url = 'https://www.jubi.com/api/v1/ticker/'    try:        data = requests.post(url,data = {'coin':coin}).json()    except:        print("沒辦法擷取到幣價ticker")    return data'''函數名;real_time_depth功能:擷取某個幣的買賣單價格和數量傳回值內容:asks - 買單[價格, 委單量],價格從高到低排序bids - 賣單[價格, 委單量],價格從高到低排序'''def real_time_depth(coin):    url = 'https://www.jubi.com/api/v1/depth/'    data = requests.post(url,data = {'coin':coin}).json()    data_bids = data['bids']    data_asks = data['asks']    for i in data_bids:        print(i[0])        print(" ")        print(i[1])    for j in data_asks:        print(j[0])        print(" ")        print(j[1])'''函數名:real_time_order功能:返回最近100個交易,按時間倒序排列返回內容:date - 時間戳記price - 交易價格amount - 交易數量tid - 交易IDtype - 交易類型'''def real_time_order(coin):    url = 'https://www.jubi.com/api/v1/orders/'    try:        request = requests.get(url,params = {'coin':coin})    except:        print("沒能夠擷取order")    data = request.json()    return data

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.