bitfinexcom/bitfinex-api-py

bitfinex-api-py/bfxapi/rest/ public stats data

YZhao-BlockFi opened this issue · 2 comments

Hello,

I'm using Bitfinex API to pull some volume 1d/7d/30d data showing in this webpage: https://www.bitfinex.com/stats/#volume. I'm referring to the following code/doc to create my function:

https://github.com/bitfinexcom/bitfinex-api-py/blob/master/bfxapi/rest/bfx_rest.py
https://docs.bitfinex.com/reference/rest-public-stats1

async def log_public_stats():
status = await bfx.rest.get_public_stats("vol.1d", "30m", 'fUSD', "hist", "long")
print ("Public Stats:")
print (status)

No matter what I put in key, size, symbol,... parameters, I can't get any data. Can someone help me on this? Thank you!

Best,
y

Hello YZhao, sorry for the delay.
I've prepared an example code snippet for you

import asyncio

from bfxapi import Client

async def example():
  bfx = Client()
  data = await bfx.rest.get_public_stats(
    "pos.size", "1m", 'tBTCUSD', "hist", "long"
  )

  print(data)

t = asyncio.ensure_future(example())
asyncio.get_event_loop().run_until_complete(t)

Output
[[1668789000000, 106432.57017588], [1668788940000, 106432.57017588], [1668788880000, 106432.44957314], [1668788820000, 106432.45039416], [1668788760000, 106432.70030638], [1668788700000, 106432.78555592], [1668788640000, 106432.84044877], [1668788580000, 106432.8600154], [1668788520000, 106430.8000145], [1668788460000, 106430.8000145], [1668788400000, 106426.56542111], [1668788340000, 106423.87252514], [1668788280000, 106423.85551825], [1668788220000, 106423.16270861], [1668788160000, 106422.69770973], [1668788100000, 106422.69770973], [1668788040000, 106422.69270973], [1668787980000, 106422.69270973], [1668787920000, 106422.69270973], [1668787860000, 106422.68770973], [1668787800000, 106422.68770973], [1668787740000, 106422.68770973], [1668787680000, 106422.68770973], [1668787620000, 106422.68770973], [1668787560000, 106422.66270973], [1668787500000, 106422.66270973], [1668787440000, 106422.66270973], [1668787380000, 106424.82428507], [1668787320000, 106424.72428507], [1668787260000, 106423.28710826], [1668787200000, 106423.28710826], [1668787140000, 106423.27210826], [1668787080000, 106423.27210826], [1668787020000, 106423.27210826], [1668786960000, 106423.32209828], [1668786900000, 106422.45946907], [1668786840000, 106422.46346454], [1668786780000, 106422.46246454], [1668786720000, 106422.46246454], [1668786660000, 106422.46246454], [1668786600000, 106422.45846454], [1668786540000, 106422.45846454], [1668786480000, 106422.45846454], [1668786420000, 106422.45846454], [1668786360000, 106422.35175214], [1668786300000, 106422.35722167], [1668786240000, 106422.35722167], [1668786180000, 106422.28116629], [1668786120000, 106422.28516629], [1668786060000, 106422.28901629], [1668786000000, 106422.28901629], [1668785940000, 106421.55380786], [1668785880000, 106421.55380786], [1668785820000, 106421.55979406], [1668785760000, 106421.55979406], [1668785700000, 106421.55979406], [1668785640000, 106421.55979406], [1668785580000, 106421.55979406], [1668785520000, 106421.56479406], [1668785460000, 106421.53979406], [1668785400000, 106421.55578026], [1668785340000, 106421.54078026], [1668785280000, 106421.55578026], [1668785220000, 106421.26556026], [1668785160000, 106421.2880864], [1668785100000, 106421.27477238], [1668785040000, 106421.27484579], [1668784980000, 106421.27484579], [1668784920000, 106421.26754813], [1668784860000, 106421.26754813], [1668784800000, 106421.26954813], [1668784740000, 106421.03276133], [1668784680000, 106419.79097453], [1668784620000, 106419.30949206], [1668784560000, 106416.07996572], [1668784500000, 106416.09015821], [1668784440000, 106416.09496572], [1668784380000, 106416.32375116], [1668784320000, 106416.37172957], [1668784260000, 106416.26018241], [1668784200000, 106416.10312241], [1668784140000, 106416.10321189], [1668784080000, 106416.17829508], [1668784020000, 106416.16530508], [1668783960000, 106416.16330508], [1668783900000, 106416.1849284], [1668783840000, 106416.22895292], [1668783780000, 106414.75246082], [1668783720000, 106414.72628302], [1668783660000, 106414.71528387], [1668783600000, 106414.76528387], [1668783540000, 106415.21497041], [1668783480000, 106415.21497041], [1668783420000, 106415.21503976], [1668783360000, 106415.21503976], [1668783300000, 106415.14003976], [1668783240000, 106414.84314316], [1668783180000, 106414.83814316], [1668783120000, 106414.83334296], [1668783060000, 106414.97928496], [1668783000000, 106414.83257256], [1668782940000, 106414.82903416], [1668782880000, 106414.92403416], [1668782820000, 106414.80361416], [1668782760000, 106414.83061416], [1668782700000, 106414.75320251], [1668782640000, 106414.65035904], [1668782580000, 106416.46844789], [1668782520000, 106416.50887128], [1668782460000, 106416.50942966], [1668782400000, 106415.99377468], [1668782340000, 106416.00677468], [1668782280000, 106416.90811427], [1668782220000, 106416.96211427], [1668782160000, 106416.96711427], [1668782100000, 106418.57330547], [1668782040000, 106420.50744045], [1668781980000, 106420.54203058], [1668781920000, 106417.51869374], [1668781860000, 106418.56922667]]

To get the volume I suggest to directly query

https://api-pub.bitfinex.com/v2/stats1/vol.1d:30m:BFX/hist

import requests
data = requests.get('https://api-pub.bitfinex.com/v2/stats1/vol.1d:30m:BFX/hist').json()