Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Endpoint request: Charts #26

Open
icheered opened this issue Aug 5, 2021 · 1 comment
Open

API Endpoint request: Charts #26

icheered opened this issue Aug 5, 2021 · 1 comment

Comments

@icheered
Copy link

icheered commented Aug 5, 2021

The chart on the main screen is simply a dataset retrieved with a simple API call but required the user to be logged in (it must include JWT auth params). It would be great if this is also available on the official API endpoint so that its possible to display this data outside of the bitvavo client (for use cases like dashboards with graphs for different assets like stocks and crypto).

@NostraDavid
Copy link

You could work around this by grabbing the candles and averaging the open and close
(note that timedelta(days=1) is the most important bit here)

from datetime import datetime, timedelta

response = bitvavo.candles(
    symbol="SHIB-EUR",
    interval="1m",
    options={
        "start": int((datetime.now() - timedelta(days=1)).timestamp() * 1000),
        "limit": 1440,
        "end": int(datetime.now().timestamp() * 1000),
    },
)
print(response)

For whatever weird reason, candles come as a list, so here is a snippet based on the docs to make it make sense :)

for candle in response:
    average = (float(candle[1]) + float(candle[4])) / 2
    print(
        f"average: {average} - timestamp {candle[0]}, open {candle[1]}, high {candle[2]}, low {candle[3]}, close {candle[4]}, volume {candle[5]}"
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants