{ "info": { "author": "Alejandro Escontrela ,Felipe Faria ", "author_email": "alejandroescontrela@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# CoinMarketCap Historical Data Retrieval \n\nObtain [USD price history](https://coinmarketcap.com/currencies/bitcoin/historical-data/) data for [CoinMarketCap](http://www.coinmarketcap.com)-listed cryptocurrencies.\n\nUse this library as a **command-line script** to obtain historical cryptocurrency data on the fly, or **import the `cmc` library** to obtain cryptocurrency data within your Python program. \n\n## Contents\n* [Installation](#installation)\n* [Usage](#usage)\n * [Command Line](#command-line)\n * [Usage](#command-line-usage)\n * [Examples](#command-line-examples)\n * [Module](#module)\n * [Usage](#module)\n * [Examples](#library-examples)\n* [Legacy](#legacy)\n* [Updates](#updates)\n***\n\n## Installation\n\nInstall coinmarketcap-history with pip:\n\n```shell\n$ pip install cmc\n```\n\n***\n\n## Usage\n\n### Command Line\nThe command line tool is useful for US tax reporting, among other things. If you wish to report the cost basis for a trade (or for coins acquired through mining), the IRS requires you to denominate that cost basis in USD. In the case of token-for-token trades (e.g. purchasing ETH with BTC), that requires you know the USD:BTC exchange rate at the time of the trade.\n\nRather than getting the exchange rate at the exact moment of your trade, which is generally not feasible, the IRS standard is to use the average of a stock's high and low price for the day. CoinMarketCap doesn't provide this figure, but this tool does.\n\n#### Command Line Usage\n\nTo gather cryptocurrency data, open a terminal and run:\n```shell\n$ coinmarketcap \n```\nwhere:\n\n* `currency` is the (case-insensitive) name of the currency / token as displayed on CoinMarketCap, with dashes in place of spaces (i.e. bitcoin).\n* `start_date` is the beginning of the range to fetch data for in `yyyy-mm-dd` format (i.e. 2017-10-01 for 2017 October 10th).\n* `end_year` is the end of the range to fetch data for in `yyyy-mm-dd` format.\n\nData is returned in the following tabular format:\n\n\n| |Bitcoin | | | | | | |\n|----------|----------|----------|----------|----------|----------|----------|----------|\n| Date | Open | High | Low | Close | Volume |Market Cap| Average |\n|... |... |... |... |... |... |... |... |\n\nData for multiple cryptocurrencies can be obtained with:\n```shell\n$ coinmarketcap \n```\n**Note:** currencies must be comma-separated, with no spaces in between.\n\nData for multiple cryptocurrencies is returned in the following tabular format:\n\n\n| |Bitcoin | | | | | | |Ripple | | | | | | |\n|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|\n| Date | Open | High | Low | Close | Volume |Market Cap| Average | Open | High | Low | Close | Volume |Market Cap| Average |\n|... |... |... |... |... |... |... |... |... |... |... |... |... |... |... |\n\nThe above information can also be found by running:\n```shell\n$ coinmarketcap -h\n```\n\nWrite outputs to a file by running:\n\n```shell\n$ coinmarketcap > \n```\n\nFor faster retrieval, cryptocurrency data can be gathered asynchronously by supplying the `--asynchro` flag:\n\n```shell\n$ coinmarketcap --asynchro\n```\n\nRunning `coinmarketcap` asynchronously greatly reduces the amount of time required to obtain data for cryptocurrencies, especially when gathering data for multiple cryptocurrencies at a time:\n\n\n\n**Note:** Asynchronous runtimes may vary according to CPU architecture. Benchmark performed with a 64-bit 6-core AMD processor.\n\n#### Command Line Examples\nCollecting data for one cryptocurrency:\n```shell\n$ coinmarketcap bitcoin 2017-01-01 2017-12-31\n```\n\nCollecting data for multiple cryptocurrencies:\n```shell\n$ coinmarketcap bitcoin,ripple,ethereum 2017-01-01 2017-12-31\n```\n\nCollecting data for multiple cryptocurrencies asynchronously(faster):\n```shell\n$ coinmarketcap bitcoin,ripple,ethereum 2017-01-01 2017-12-31 --asynchro\n```\n\nWriting output to a file:\n```shell\n$ coinmarketcap bitcoin 2017-01-01 2017-12-31 > bitcoin_history.csv\n```\n\nWriting output for multiple cryptocurrencies to a file:\n```shell\n$ python coinmarketcap.py bitcoin,ripple,ethereum 2017-01-01 2017-12-31 > bitcoin_ripple_ethereum_history.csv\n```\n***\n\n### Module\n\nIn addition to command-line functionality, coinmarketcap-history provides the `cmc` library, which allows users to obtain CoinMarketCap data from within a Python program. Historical is returned in the form of a [Pandas DataFrame](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html), which allows for easy use.\n\nTo get started with the `cmc` library, import it from within your program:\n\n```python\nfrom cmc import coinmarketcap\n```\n\nData for cryptocurrencies can be gathered using the `getDataFor()` method:\n\n#### `getDataFor()`\n* **params:**\n * `cryptocurrencies`: string or list\n * crypto(s) to be scraped. supply a string for a single cryptocurrency, or supply a list of strings for multiple cryptocurrencies.\n * `start_date`: datetime object\n * datetime object for the beginning of the range to fetch data for. Must contain values for year, month, and day.\n * `end_date`: datetime object\n * datetime object for the ebd of the range to fetch data for. Must contain values for year, month, and day.\n * `fields` **(optional)**: list\n * columns to obtain upon data retrieval. Options are:\n * ['Open','High','Low','Close','Volume','Market Cap','Average']\n * if `fields` is not specified, all fields are returned.\n * `async` **(optional)**: boolean\n * if `True`, data is gathered asynchronously. This is especially useful when gathering data for multiple cryptocurrencies at a time, which can be slow when gathered synchronously. If `async` is not specified, data is gathered synchronously.\n\n * `DOWNLOAD_DIR` **(optional)**: string\n * String of the relative path to save data to and load data from. If `DOWNLOAD_DIR` is not specified, no data is saved.\n* **returns:**\n * `out`: [Pandas DataFrame](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html)\n * A DataFrame containing historical price information for the specified cryptocurrencies through the desired daterange.\n\n#### Library Examples\nGathering data for a single cryptocurrency:\n```python\nfrom cmc import coinmarketcap\nfrom datetime import datetime\n\ncrypto = 'bitcoin'\nstart_date, end_date = datetime(2017,6,1), datetime(2018,6,1)\n\ndf_bitcoin = coinmarketcap.getDataFor(crypto, start_date, end_date)\n```\n\nGetting data for multiple cryptocurrencies:\n\n```python\nfrom cmc import coinmarketcap\nfrom datetime import datetime\n\ncryptos = ['bitcoin','ripple','ethereum']\nstart_date, end_date = datetime(2017,6,1), datetime(2018,6,1)\n\ndf_cryptos = coinmarketcap.getDataFor(cryptos, start_date, end_date)\n```\n\nTo cache retrieved data, simply supply a string for `DOWNLOAD_DIR`. The string should be a relative path to the desired download directory. Data is stored in the lightweight `.msg` format.\n\nSaving data and pulling cached data:\n```Python\nfrom cmc import coinmarketcap\nfrom datetime import datetime\n\ncryptos = ['bitcoin','ripple','ethereum']\nstart_date, end_date = datetime(2017,6,1), datetime(2018,6,1)\n\n# retrieves data and stores .msg files in DOWNLOAD_DIR\ndf_cryptos = coinmarketcap.getDataFor(cryptos, start_date, end_date, DOWNLOAD_DIR = 'data/coinmarketcap')\n\n# does not retreive data. Instead, pulls cached data from DOWNLOAD_DIR\ndf_cryptos = coinmarketcap.getDataFor(cryptos, start_date, end_date, DOWNLOAD_DIR = 'data/coinmarketcap')\n```\n\nPulling specified columns only:\n```python\nfrom cmc import coinmarketcap\nfrom datetime import datetime\n\ncryptos = ['bitcoin','ripple','ethereum']\nstart_date, end_date = datetime(2017,6,1), datetime(2018,6,1)\n\ndf_cryptos = coinmarketcap.getDataFor(cryptos, start_date, end_date, fields = ['High','Low','Close'])\n```\n***\n\n# Legacy\n\nLegacy code can be obtained from the `coinmarketcap-history-legacy` repository found [here](https://github.com/Alescontrela/coinmarketcap-history-legacy).\n***\n\n# Updates\n\n### 2.0.0 - July 6th, 2018\n* as of version 2, coinmarketcap-history now offers support for Python 3. Additionally, the `cmc` artifact allows for global use of the `coinmarketcap` command line tool, as well as dedicated support for in-program operations.\n### 2.0.2 - May 30th, 2019\n* as of version 2.0.2, coinmarketcap-history can now be run asynchronously inside jupyter notebooks thanks to [changes in the way they handle event loops](https://blog.jupyter.org/ipython-7-0-async-repl-a35ce050f7f7).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Alescontrela/coinmarketcap-history", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "cmc", "package_url": "https://pypi.org/project/cmc/", "platform": "", "project_url": "https://pypi.org/project/cmc/", "project_urls": { "Homepage": "https://github.com/Alescontrela/coinmarketcap-history" }, "release_url": "https://pypi.org/project/cmc/2.0.3.1/", "requires_dist": [ "aiohttp", "aiodns", "pandas", "tqdm", "requests", "asyncio ; python_version < \"3.4\"" ], "requires_python": "", "summary": "Get the price history for CoinMarketCap-listed currencies", "version": "2.0.3.1" }, "last_serial": 5341040, "releases": { "2.0.0": [ { "comment_text": "", "digests": { "md5": "1b88de0945f664182b9906fcf8b7d015", "sha256": "ea94e3bba041457adf20b954f2ec5724b76ce9848b5d934c6949c1d8de497cba" }, "downloads": -1, "filename": "cmc-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1b88de0945f664182b9906fcf8b7d015", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8208, "upload_time": "2018-07-06T17:14:09", "url": "https://files.pythonhosted.org/packages/7a/d2/ee75c4f6e7deb8585da2764f522ff0d8035338d823a1b32fabda59373158/cmc-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1f801854caba328ec665ec0f20e32470", "sha256": "afcf17d2c2f4e0955cc82c3a339631c4c2634f749120638e06376c5427015b97" }, "downloads": -1, "filename": "cmc-2.0.0.tar.gz", "has_sig": false, "md5_digest": "1f801854caba328ec665ec0f20e32470", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6934, "upload_time": "2018-07-06T17:14:10", "url": "https://files.pythonhosted.org/packages/44/85/ac36fbcc7eb6b69406e6021a795c55ae91bf6a35da95f60275b4155bc12e/cmc-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "47dfe655bd1b51edaa51efdb98c3f94e", "sha256": "696cb46df19919bdfe5966a6b89252d91c0790cb2735555922ac761eab2417e6" }, "downloads": -1, "filename": "cmc-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "47dfe655bd1b51edaa51efdb98c3f94e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9053, "upload_time": "2018-07-06T19:27:00", "url": "https://files.pythonhosted.org/packages/af/f6/b2be27a239256786fb1b3ff46c96d45e2793316339ed79d0e85d80495761/cmc-2.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b23fade9146a713add5184424bfbd12", "sha256": "eea96541759fa38b1cd23f60e3955c1ed35a9510b1b11c24dca88c78face8d36" }, "downloads": -1, "filename": "cmc-2.0.1.tar.gz", "has_sig": false, "md5_digest": "8b23fade9146a713add5184424bfbd12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7967, "upload_time": "2018-07-06T19:27:01", "url": "https://files.pythonhosted.org/packages/30/ac/4298433975fe55779cc467cac76a67445183d38c2e54dd81035d4964438c/cmc-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "299fd1f482ea6f94c0c8434962fa78fd", "sha256": "3dac74fc1685136edc45937820178165160903edc38b7ac8fb03a0074622d3c4" }, "downloads": -1, "filename": "cmc-2.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "299fd1f482ea6f94c0c8434962fa78fd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10162, "upload_time": "2019-05-31T02:35:37", "url": "https://files.pythonhosted.org/packages/c8/54/b7b36c966f7ce6290db0e6470226ca558abad7e436688415df8d6902fde6/cmc-2.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b887d7b75d3633d5a92042e9b87575b8", "sha256": "506b048124893a26f485397967f59056a643631aa003a3a5d381d5082a69d30f" }, "downloads": -1, "filename": "cmc-2.0.2.tar.gz", "has_sig": false, "md5_digest": "b887d7b75d3633d5a92042e9b87575b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8322, "upload_time": "2019-05-31T02:35:38", "url": "https://files.pythonhosted.org/packages/a0/7e/1a3a81c6e4433a599697be92687bc0df34bc59978b2bc330ca3f47751ad8/cmc-2.0.2.tar.gz" } ], "2.0.3.1": [ { "comment_text": "", "digests": { "md5": "7bd305f79e716f220488d914d4c29204", "sha256": "33196d288e163c4dec07f973f0ad4eaabe55e21f3414a9bb6c6b418992598f27" }, "downloads": -1, "filename": "cmc-2.0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7bd305f79e716f220488d914d4c29204", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10292, "upload_time": "2019-05-31T04:20:39", "url": "https://files.pythonhosted.org/packages/e4/c1/88843f0e993694fe8a38e5afcaa9932310e43956351fc2085dee2766ee36/cmc-2.0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0883a3700a675c981baab677314fc71", "sha256": "e6064739e2baf08c20e40fcab80619e384c043f83e352c0c224154376389864e" }, "downloads": -1, "filename": "cmc-2.0.3.1.tar.gz", "has_sig": false, "md5_digest": "a0883a3700a675c981baab677314fc71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8529, "upload_time": "2019-05-31T04:20:40", "url": "https://files.pythonhosted.org/packages/2c/6b/841f738825e99f345659117f6ff39f2da645fffcc2ebb49a2cb426e6e1a1/cmc-2.0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7bd305f79e716f220488d914d4c29204", "sha256": "33196d288e163c4dec07f973f0ad4eaabe55e21f3414a9bb6c6b418992598f27" }, "downloads": -1, "filename": "cmc-2.0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7bd305f79e716f220488d914d4c29204", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10292, "upload_time": "2019-05-31T04:20:39", "url": "https://files.pythonhosted.org/packages/e4/c1/88843f0e993694fe8a38e5afcaa9932310e43956351fc2085dee2766ee36/cmc-2.0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0883a3700a675c981baab677314fc71", "sha256": "e6064739e2baf08c20e40fcab80619e384c043f83e352c0c224154376389864e" }, "downloads": -1, "filename": "cmc-2.0.3.1.tar.gz", "has_sig": false, "md5_digest": "a0883a3700a675c981baab677314fc71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8529, "upload_time": "2019-05-31T04:20:40", "url": "https://files.pythonhosted.org/packages/2c/6b/841f738825e99f345659117f6ff39f2da645fffcc2ebb49a2cb426e6e1a1/cmc-2.0.3.1.tar.gz" } ] }