Getting data from CoinGecko
The last data source we cover is dedicated purely to cryptocurrencies. CoinGecko is a popular data vendor and crypto tracking website, on which you can find real-time exchange rates, historical data, information about exchanges, upcoming events, trading volumes, and much more.
We can list a few of the advantages of CoinGecko:
- completely free, no need to register for an API key
- aside from prices, they also provide updates and news about crypto
- it covers many coins, not only the most popular ones
In this recipe, we download Bitcoin's OHLC from the last 14 days.
How to do it…
Execute the following steps to download data from CoinGecko.
- Import the libraries:
from pycoingecko import CoinGeckoAPI
from datetime import datetime
- Instantiate the CoinGecko API:
cg = CoinGeckoAPI()
- Get Bitcoin's OHLC prices from the last 14 days:
ohlc = cg.get_coin_ohlc_by_id(id="bitcoin", vs_currency="usd", days="14")
ohlc_df...