Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Token Correlation Heatmap

This project analyzes and visualizes the correlation between multiple cryptocurrency tokens using historical price data from the CoinGecko Pro API.

Features

  • Fetch historical price data for any set of tokens
  • Calculate log returns and token volatility
  • Generate a correlation heatmap for selected tokens
  • Save and load processed data for fast analysis

Setup

  1. Clone the repository

  2. Install dependencies

    pip install -r requirements.txt
    
  3. Add your CoinGecko Pro API key

    • Create a .env file in the token_heatmap folder:
      GECKO_API=your_api_key_here
      

Usage

  1. Fetch and save token price data

    • Run 01_data.ipynb to fetch historical prices for your chosen tokens and save the DataFrame.
  2. Analyze correlations

    • Open token_correlation.ipynb to load the saved data, calculate log returns, volatility, and plot the correlation heatmap.

Example

# Fetch prices for Bitcoin, Ethereum, and Solana
token_ids = ["bitcoin", "ethereum", "solana"]
api_key = os.getenv("GECKO_API")
df_prices = fetch_token_prices(token_ids, api_key=api_key)
# Plot correlation heatmap
corr = df_prices.pct_change().apply(lambda x: np.log1p(x)).corr()
sns.heatmap(corr, annot=True, cmap='coolwarm', vmin=-1, vmax=1)
plt.title("Token Correlation Heatmap")
plt.show()

Requirements

  • Python 3.8+
  • requests
  • pandas
  • numpy
  • matplotlib
  • seaborn
  • python-dotenv
  • joblib

License

MIT License


**Feel free to fork :)

About

This project offers a bases for analyzing and visualizing the relationships between multiple cryptocurrency tokens using historical price data from CoinGecko API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages