Skip to main content

Utility code for interacting with amberdata

Project description

pyamber

Build Status

Some utility code for interacting with amberdata. For more information on amberdata please check out https://amberdata.io/.

Installing pyamber

Install with pip

pip install pyamber

AmberRequest

AmberRequest is a class hiding the management of your key, the pagination of requests and conversion of your results to standard pandas containers.

from pyamber.request import AmberRequest, TimeInterval

if __name__ == '__main__':
    request = AmberRequest(key="...")
    f = request.prices.history(pair="eth_usd", time_interval=TimeInterval.HOURS)
    print(f)

Settings.cfg

We recommend to define a configuration file (*.cfg) containing

AMBERDATA = {'x-api-key': 'ENTER YOUR KEY HERE'}

Flask-AmberData

A Flask extension that provides integration with AmberData. In particular this flask extension provides management of the your AmberRequests. You can use configuration files such as settings.cfg to follow standard flask practices. The configuration is easy, just fetch the extension:

import pandas as pd
from flask import Flask

from pyamber.flask_amberdata import amberdata
from pyamber.request import TimeInterval

if __name__ == '__main__':
    app = Flask(__name__)
    app.config.from_pyfile('/amberdata/config/settings.cfg')
    amberdata.init_app(app)

    with app.app_context():
        assert amberdata.request.health
        x = amberdata.request.prices.history("eth_usd", time_interval=TimeInterval.DAYS, start_date=pd.Timestamp("2020-01-12"), end_date=pd.Timestamp("2020-01-16"))
        print(x)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyamber-0.0.9.tar.gz (7.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page