Using CoinGecko API for Cryptocurrency Analysis

Coingecko has one of the best API for cryptocurrency analysis along with Coinmarketcap. Though, as it is completely free I prefer to use Coingecko API. In this post, I’ll demonstrate some of the features of this API and determine which projects are far from their brightest times.

Disclaimer

I am not a financial advisor and that blog does not promote or demote any projects. None of the conclusions in that blog can be used for financial investments. Before making any financial decision you need to make your own research and act accordingly.

Import Libraries

import pandas as pd
import numpy as np

Install Coingecko API

pip install pycoingecko

Usage

from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()

#To get an information about any of the tokens

cg.get_coin_by_id('ethereum')

Information about Ethereum from Coingecko

coins=cg.get_coins_list()
df_coins=pd.DataFrame(coins, columns=['name'])
df_coins

#List of all coins

Apparently, there are 6680 crypto assets in Coingecko. Though, we are going to examine the first 500 assets according to their market cap.

#Get USD value of 250 crypto assets per page
coin_market1=cg.get_coins_markets(vs_currency='usd', per_page=250, page=1)
coin_market2=cg.get_coins_markets(vs_currency='usd', per_page=250, page=2)
#Combine lists
coin_market= coin_market1 + coin_market2
coin_market

We can use these values as columns. You can choose whichever you need for your analysis.

#Choose columns
df_market= pd.DataFrame(coin_market, columns=['id','symbol','market_cap_rank','current_price','ath','ath_date','atl','total_volume'])
df_market.set_index('id',inplace=True)

#Create a new column which shows the ratio of the current price of the asset to its highest value
df_market['ath_portion'] = df_market['ath'] / df_market['current_price']

#Filtering & Sorting
filter_volume = df_market['total_volume'] > 1000000 # i prefer to list assets has more than a million dollars daily volume
filter_ath_date = df_market['ath_date'] > '2020-01-01T00:00:00.000Z' # only list assets which reached to its ATH after 2020
df_market[filter_volume & filter_ath_date].sort_values('ath_portion', ascending=False).head(50)

Looks like Farm and Curve are the assets which lost the most of their values after reaching an all time high value after 2020.

#Get BTC value of 250 crypto assets per page
coin_market1=cg.get_coins_markets(vs_currency='btc', per_page=250, page=1)
coin_market2=cg.get_coins_markets(vs_currency='btc', per_page=250, page=2)

#Combine lists
coin_market= coin_market1 + coin_market2# Choose columns
df_market= pd.DataFrame(coin_market, columns=['id','symbol','market_cap_rank','current_price','ath','ath_date','atl','total_volume'])
df_market.set_index('id',inplace=True)

#Create a new column which shows the ratio of the current price of the asset to its highest value
df_market['ath_portion'] = df_market['ath'] / df_market['current_price']

#Filtering & Sorting
filter_volume = df_market['total_volume'] > 20 # i prefer to list assets has more than 20 BTC daily volume
filter_ath_date = df_market['ath_date'] > '2020-01-01T00:00:00.000Z' # only list assets which reached to its ATH after 2020
df_market[filter_volume & filter_ath_date].sort_values('ath_portion', ascending=False).head(50)

This time, I found the assets which lost the most value versus Bitcoin according to their ATH value. There was a DeFi hype last year and most of the assets in our list are consist of these DeFi projects.

There are many more details in Coingecko API which you can get more details on here. This analysis made for just educational purposes and is not sufficient to make an investment based on it. Some of the projects are dormant or forks of bitcoin or ethereum. By using CryptoMiso it is possible to determine which projects has more commits on Github. With the help of it, we can eliminate old/inactive projects too.

You can reach Jupyter file on GitHub.

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.