glassnode / glassnode-api-python-client

The official Python client library for Glassnode's API – https://docs.glassnode.com
45 stars 18 forks source link

OHLC returns null #4

Open josefansinger opened 3 years ago

josefansinger commented 3 years ago

OHLC returns null i.e. NoneType.

gn = GlassnodeClient()
gn.set_api_key(GLASSNODE_API_KEY)
ohlc = gn.get('https://api.glassnode.com/v1/metrics/market/price_usd_ohlc', a='ETH')
TurtleJelly commented 3 years ago

adding below line to the bottom of glassnode.py, however this is not the optimal way to solve the issue.

try:
    df = pd.DataFrame(json.loads(r.text))
    df = df.set_index('t')
    df.index = pd.to_datetime(df.index, unit='s')
    df = df.sort_index()
    s = pd.DataFrame()
    for r, c in df.iterrows():
        for k, v in c['o'].items():
            s.loc[r, k] = v
    return s

except Exception as e:
    print(e)