A Python application that identifies cryptocurrencies that do not follow the general altcoin market by analyzing price correlations and price distance.
This code was generated by manus AI with the following tasks.
This application performs the following tasks:
- Fetches the top 100 cryptocurrencies by market cap from CoinGecko
- Downloads 180 days of historical price data for each coin
- Calculates average percentage gain/loss for these coins
- Creates a correlation matrix to identify coins that don't follow the general altcoin market
- Analyzes coins that are out of 30% price distance from the overall market
- Creates a web visualization showing market average vs. individual coin performance
- Python 3.10+
- Required Python packages:
- pandas
- numpy
- matplotlib
- seaborn
- requests
- ccxt
- flask
# Clone the repository
git clone https://github.com/yourusername/crypto-correlation-analyzer.git
cd crypto-correlation-analyzer
# Install required packages
pip install -r requirements.txtYou can run the entire pipeline with:
python main.pyOr run individual scripts:
# Step 1: Fetch top 100 coins by market cap
python fetch_top_coins.py
# Step 2: Download historical data (180 daily candles)
python download_historical_data.py
# Step 3: Analyze correlations and identify uncorrelated coins
python analyze_correlations.py
# Step 4: Analyze price distance from market average
python analyze_price_distance.py
# Step 5: Create web visualization
python create_web_visualization.pyTo view the web visualization:
cd web_visualization
python app.pyThen open your browser and navigate to http://localhost:5000
The application generates several output files:
top_coins.csv- List of top 100 coins by market caphistorical_data/- Directory containing historical price data for each coinanalysis_results/- Directory containing analysis results:average_returns.csv- Average percentage changes for each coincorrelation_matrix.csv- Correlation matrix of all coinscorrelation_heatmap.png- Visualization of the correlation matrixaverage_correlations.csv- Average correlation of each coin with othersuncorrelated_coins.csv- List of coins that don't follow the general marketaverage_correlations.png- Visualization of average correlationsprice_distance.csv- Price distance from market average for each coinout_of_threshold_coins.csv- List of coins that are out of 30% price distanceprice_distance.png- Visualization of price distance from marketcomparison_data.json- Data for web visualization
-
Data Collection: The application uses the CoinGecko API to fetch the top 100 cryptocurrencies by market cap and their historical price data.
-
Data Processing: Daily returns are calculated for each coin, and a correlation matrix is created to measure how each coin's price movements correlate with others.
-
Correlation Analysis: Coins with low average correlation to the rest of the market are identified as those that don't follow the general altcoin market trends.
-
Price Distance Analysis: Coins that are out of 30% price distance from the overall market are identified as having abnormal price action.
-
Web Visualization: A web interface is created to visualize the market average vs. individual coin performance, allowing for interactive exploration of the results.
- The application implements robust rate limiting handling to work within CoinGecko API constraints
- The correlation threshold for identifying uncorrelated coins is set to 0.3 by default
- The price distance threshold is set to 0.3 (30%) by default