Cryptocurrency historical market price data scraper written in Python.
Note: This is a fork of the orignal repo. I wanted one that could do Multiples coins and specific dates. So i added on to this.
$ pip install cryptocmd
to install from the latest source use following command
$ pip install git+git://github.com/guptarohit/cryptoCMD.git
Following methods are available to get data in multiple formats from https://coinmarketcap.com
from cryptocmd import CmcScraper
# initialise scraper without time interval
scraper = CmcScraper("XRP")
# get raw data as list of list
headers, data = scraper.get_data()
# get data in a json format
xrp_json_data = scraper.get_data("json")
# export the data as csv file, you can also pass optional `name` parameter
scraper.export("csv", name="xrp_all_time")
# Pandas dataFrame for the same data
df = scraper.get_dataframe()
from cryptocmd import CmcScraper
# initialise scraper with time interval
scraper = CmcScraper("XRP", "15-10-2017", "25-10-2017")
# get raw data as list of list
headers, data = scraper.get_data()
# get data in a json format
json_data = scraper.get_data("json")
# export the data to csv
scraper.export("csv")
# get dataframe for the data
df = scraper.get_dataframe()
Date, Open, High, Low, Close, Volume, Market Cap
To get all time historical data of a cryptocurrency from a range of dates (From DD-MM-YY to DD-MM-YY)
from cryptocmd import CmcScraper
currency = input("enter currency: ") #eg.. ICX
date_from = input("enter begining date: ") #(DD-MM-YYYY) or left blank to get all dates
date_to = input ("enter end date: ") #(DD-MM-YYYY) or can be left blank to get all dates
# initialise scraper with time interval
if date_from and date_to:
scraper = CmcScraper(currency, date_from, date_to)
else:
scraper = CmcScraper(currency)
# get raw data as list of list
headers, data = scraper.get_data()
# get data in a json format
json_data = scraper.get_data("json")
# export the data to csv
scraper.export("csv")
# get dataframe for the data
df = scraper.get_dataframe()
Output file is a CSV
To get all time historical data of Multiple cryptocurrency from a range of dates (From DD-MM-YY to DD-MM-YY)
from cryptocmd import CmcScraper
currency_n = input("enter currency: ") #must be multiple coins eg. BTC ICX (as many coins as you like)
date_from = input("enter begining date: ") #Can be left blank to get all ranges (DD-MM-YYYY)
date_to = input ("enter end date: ") #Can be left blank to get all ranges (DD-MM-YYYY)
for currency in currency_n.split(" "):
# initialise scraper with time interval
if date_from and date_to:
scraper = CmcScraper(currency, date_from, date_to)
else:
scraper = CmcScraper(currency)
headers, data = scraper.get_data()
# get data in a json format
json_data = scraper.get_data("json")
# export the data to csv
scraper.export("csv")
# get dataframe for the data
df = scraper.get_dataframe()
Output: Each currency as its own CSV file.
The data is being scrapped from coinmarketcap โ๏ธ and it's free to use. ๐
Feel free to make a pull request!
If you found this useful, I'd appreciate your consideration in the below. โจโ
![Buy Me A Coffee](https://user-images.githubusercontent.com/7895001/52529389-e2da5280-2d16-11e9-924c-4fe3f309c780.png)