# cbhist
<a href="https://pypi.org/project/cbhist/">
<img alt="PyPi" src="https://img.shields.io/pypi/v/cbhist">
</a>
A python library for pulling in historical candles from coinbase.
## Dependencies :globe_with_meridians:
Python 3.11.6:
- [pandas](https://pandas.pydata.org/)
- [requests](https://requests.readthedocs.io/en/latest/)
- [tqdm](https://github.com/tqdm/tqdm)
- [tenacity](https://tenacity.readthedocs.io/en/latest/)
## Raison D'ĂȘtre :thought_balloon:
The [coinbase exchange API](https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles) 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:
```python
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](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/8W9aG/cbhist",
"name": "cbhist",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "coinbase history historical price candle",
"author": "Will Sackfield",
"author_email": "will.sackfield@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8d/a4/49758dc5070822ea81a12ee03c220bbdc7fe76c36857d5d6ef6861a44e1f/cbhist-0.0.3.tar.gz",
"platform": null,
"description": "# cbhist\n\n<a href=\"https://pypi.org/project/cbhist/\">\n <img alt=\"PyPi\" src=\"https://img.shields.io/pypi/v/cbhist\">\n</a>\n\nA python library for pulling in historical candles from coinbase.\n\n## Dependencies :globe_with_meridians:\n\nPython 3.11.6:\n\n- [pandas](https://pandas.pydata.org/)\n- [requests](https://requests.readthedocs.io/en/latest/)\n- [tqdm](https://github.com/tqdm/tqdm)\n- [tenacity](https://tenacity.readthedocs.io/en/latest/)\n\n## Raison D'\u00eatre :thought_balloon:\n\nThe [coinbase exchange API](https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles) 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.\n\n## Installation :inbox_tray:\n\nThis is a python package hosted on pypi, so to install simply run the following command:\n\n`pip install cbhist`\n\n## Usage example :eyes:\n\nTo pull a dataframe containing all the candles for a coinbase product:\n\n```python\nimport datetime\n\nfrom cbhist.historical import fetch_historical\n\ngranularity = 60 # Candle for every minute\ndf = fetch_coinbase(\"ETH-USD\", granularity, datetime.datetime(2010, 1, 1))\n```\n\nThis results in a dataframe with a datetime index and OHLC (+ volume) columns.\n\n## License :memo:\n\nThe project is available under the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A python library for pulling in historical candles from coinbase.",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/8W9aG/cbhist"
},
"split_keywords": [
"coinbase",
"history",
"historical",
"price",
"candle"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8da449758dc5070822ea81a12ee03c220bbdc7fe76c36857d5d6ef6861a44e1f",
"md5": "5c68bab38ae0be9bde5ff632c06919e7",
"sha256": "61306f4c712c86b79d0e5a1e870fc093c968ee09f29222adbb350fb00d78a02e"
},
"downloads": -1,
"filename": "cbhist-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "5c68bab38ae0be9bde5ff632c06919e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4528,
"upload_time": "2024-05-29T21:49:19",
"upload_time_iso_8601": "2024-05-29T21:49:19.686599Z",
"url": "https://files.pythonhosted.org/packages/8d/a4/49758dc5070822ea81a12ee03c220bbdc7fe76c36857d5d6ef6861a44e1f/cbhist-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-29 21:49:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "8W9aG",
"github_project": "cbhist",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
">=",
"2.31.0"
]
]
},
{
"name": "pandas",
"specs": [
[
">=",
"2.0.3"
]
]
},
{
"name": "tqdm",
"specs": [
[
">=",
"4.66.4"
]
]
},
{
"name": "tenacity",
"specs": [
[
">=",
"8.3.0"
]
]
}
],
"lcname": "cbhist"
}