Skip to main content

A python library for pulling in historical candles from coinbase.

Project description

cbhist

PyPi

A python library for pulling in historical candles from coinbase.

Dependencies :globe_with_meridians:

Python 3.11.6:

Raison D'être :thought_balloon:

The coinbase exchange API lets you pull down historical OHLC data but only 300 candles at a time. If you are trying to get data at the minute resolution this can take a long time. Typically the approach is to iterate across a time series and perform a request for each time chunk, however this can be sped up greatly by doing a binary search before doing an iterative pull to determine when the asset begins to have candles. Formalising this into a proper library produces a dataframe made it easier to work in different projects than re-inventing the wheel each time.

Installation :inbox_tray:

This is a python package hosted on pypi, so to install simply run the following command:

pip install cbhist

Usage example :eyes:

To pull a dataframe containing all the candles for a coinbase product:

import datetime

from cbhist.historical import fetch_historical

granularity = 60 # Candle for every minute
df = fetch_coinbase("ETH-USD", granularity, datetime.datetime(2010, 1, 1))

This results in a dataframe with a datetime index and OHLC (+ volume) columns.

License :memo:

The project is available under the MIT License.

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

cbhist-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file cbhist-0.0.2.tar.gz.

File metadata

  • Download URL: cbhist-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for cbhist-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c137e9175fc8323d93b2b2a95a257f869c020a2900372916677ecddd70794226
MD5 7b9f965a54fac19821f07308c0464587
BLAKE2b-256 c9b9e3062cd04e2ca078ded7b4dd5a4611e0b56879efdfdd6845183f93f32c3a

See more details on using hashes here.

Provenance

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