数据实时从 coinmarketcap.com 抓取,需要联网且依赖对方页面结构;日期参数格式为 DD-MM-YYYY,容易写成 YYYY-MM-DD;README 未说明速率限制,批量抓取时注意请求频率
cryptoCMD
guptarohitBSD-3-Clause活跃维护用 Python 抓取 CoinMarketCap 的历史价格数据,方便做量化回测或行情分析时直接拿到干净的加密货币历史行情。
Cryptocurrency historical price data library in Python. Data from https://coinmarketcap.com.
pip install cryptocmdREADME 未说明,纯 Python 抓取库,无 GPU 或显存要求
从 CoinMarketCap 抓取加密货币历史行情数据的 Python 库,省去自己写爬虫
用 Python 抓取 CoinMarketCap 的历史价格数据,方便做量化回测或行情分析时直接拿到干净的加密货币历史行情。
核心能力
- 按币种代码抓取全时段历史行情
- 支持指定起止日期区间取数
- 输出 list、JSON、CSV 和 Pandas DataFrame
- 币种代码重名时可用 coin_name 指定
- 导出 CSV 时可自定义文件名
容易踩的坑
- v0.6.5最新正式版2026-04-26 · 2026-04-26 00:58 UTC
Fixed
- Restored data fetching by migrating to working CMC API endpoints (https://github.com/guptarohit/cryptoCMD/pull/168)
Changed
- Dropped Python 3.7 support; minimum is now Python 3.9. Added Python 3.13 support. (https://github.com/guptarohit/cryptoCMD/pull/71)
- Migrated build tooling from poetry to uv + hatchling; removed setup.py (https://github.com/guptarohit/cryptoCMD/pull/169, https://github.com/guptarohit/cryptoCMD/pull/170)
- v0.6.40.6.42023-10-15 · 2023-10-15 16:08 UTC
查看更新说明
Added
- In addition to Date, Open, High, Low, Close, Volume, Market Cap, the following time columns are returned: Time Open, Time High, Time Low, Time Close.
- v0.6.30.6.32023-07-22 · 2023-07-22 16:43 UTC
查看更新说明
Added
- option
id_numberfor getting data of a coin (useful for case when coin have conflicting coin code) #51
- option
- v0.6.20.6.22023-07-15 · 2023-07-15 10:31 UTC
查看更新说明
Added
- option
coin_namefor getting data of coin which have conflicting coin code #62
- option
- v0.6.10.6.12022-02-19 · 2022-02-19 21:56 UTC
查看更新说明
Added
- option to download price data in other fiat currencies #43
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
cryptoCMD: cryptoCurrency Market Data
Cryptocurrency historical market price data scraper written in Python.
Installation
pip install cryptocmd
to install from the latest source use following command
pip install git+git://github.com/guptarohit/cryptoCMD.git
Usage
CoinMarketCap Scraper
Following methods are available to get data in multiple formats from https://coinmarketcap.com
To get all time historical data of a cryptocurrency
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()
To get data of a cryptocurrency which have same coin code as others
from cryptocmd import CmcScraper
# initialise scraper with coin name as well
scraper = CmcScraper(coin_code="sol", coin_name="solana")
# get raw data as list of list
headers, data = scraper.get_data()
# get data in a json format
solana_json_data = scraper.get_data("json")
# export the data as csv file, you can also pass optional `name` parameter
scraper.export("csv", name="solana_all_time")
# Pandas dataFrame for the same data
df = scraper.get_dataframe()
To get data of a cryptocurrency for some days
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()
Following are the columns of the data
Date, Open, High, Low, Close, Volume, Market Cap, Time Open, Time High, Time Low, Time Close
Acknowledgements
The data is being scrapped from coinmarketcap :v: and it's free to use. :tada:
Contributing
Feel free to make a pull request! :octocat:
If you found this useful, I'd appreciate your consideration in the below. ✨☕