A comprehensive data science pipeline analyzing how Bitcoin Fear/Greed sentiment influences trader behavior and performance on Hyperliquid — uncovering actionable patterns for smarter trading strategies.
Live Dashboard:primetradeds.streamlit.app

211,224 trades · 32 unique accounts · 246 coins · 2 years of data · 13+ visualizations · Predictive ML Models
- 🎯 Objective
- 📂 Project Structure
- 📊 Dataset Overview
- 🔧 Setup & Installation
- 🚀 How to Run
- 🌐 Deployment
- 📋 Part A — Data Preparation
- 📈 Part B — Analysis & Insights
- 💡 Part C — Actionable Strategy Recommendations
- 🧠 Bonus — Predictive Model & Clustering
- 📊 Dashboard
- 🛠️ Tech Stack
- 👤 Author
Analyze how Bitcoin market sentiment (Fear & Greed Index) relates to trader behavior and performance on Hyperliquid — a decentralized perpetual exchange — to uncover patterns that could inform smarter trading strategies.
This project delivers:
| Deliverable | Description |
|---|---|
| ✅ Data Pipeline | Automated cleaning, alignment, and metric engineering for 211K+ trades |
| ✅ Statistical Analysis | Welch's t-tests comparing Fear vs Greed day performance |
| ✅ Trader Segmentation | 3 segmentation schemes (frequency, consistency, leverage) |
| ✅ 13+ Visualizations | Dark-themed, publication-quality charts |
| ✅ Strategy Recommendations | 2 actionable, data-backed strategy rules |
| ✅ Predictive Model | Random Forest achieving 60.7% accuracy on next-day PnL prediction |
| ✅ Behavioral Clustering | K-Means archetypes (Elite Performers, Selective Winners, etc.) |
| ✅ Interactive Dashboard | Streamlit app for real-time exploration |
PrimeTradeDS/
│
├── 📊 data/
│ ├── fear_greed_index.csv # Bitcoin Fear & Greed Index (2,644 days)
│ └── historical_data.csv # Hyperliquid trader data (211,224 trades)
│
├── 🔬 src/
│ ├── analysis.py # Core analysis pipeline (Parts A + B)
│ ├── visualizations.py # Chart generation engine (13+ charts)
│ └── bonus_models.py # Predictive model + clustering (Bonus)
│
├── 🖥️ dashboard/
│ └── app.py # Streamlit interactive dashboard
│
├── 📈 outputs/
│ ├── charts/ # All generated visualizations (PNG)
│ │ ├── 01_sentiment_distribution.png
│ │ ├── 02_pnl_by_sentiment.png
│ │ ├── 03_behavior_by_sentiment.png
│ │ ├── 04_daily_pnl_timeline.png
│ │ ├── 06_segment_performance.png
│ │ ├── 07_heatmap_*.png
│ │ ├── 08_top_bottom_traders.png
│ │ ├── 09_correlation_matrix.png
│ │ ├── 10_feature_importance.png
│ │ ├── 11_confusion_matrix.png
│ │ ├── 12_elbow_method.png
│ │ └── 13_trader_archetypes.png
│ │
│ └── tables/ # Analysis result tables (CSV + JSON)
│ ├── data_summary.json
│ ├── daily_metrics.csv
│ ├── sentiment_performance.json
│ ├── trader_segments.csv
│ ├── cluster_summary.csv
│ └── model_results.json
│
├── 📓 notebooks/
│ └── exploration.ipynb # Jupyter notebook (optional exploration)
│
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md # You are here!
| Property | Value |
|---|---|
| Rows | 2,644 |
| Columns | 5 (timestamp, value, classification, date, sentiment_binary) |
| Date Range | 2018-02-01 → 2025-05-02 |
| Missing Values | 0 |
| Duplicates | 0 |
| Categories | Extreme Fear, Fear, Greed, Extreme Greed |
| Property | Value |
|---|---|
| Rows | 211,224 |
| Columns | 18 |
| Date Range | 2023-05-01 → 2025-05-01 |
| Unique Accounts | 32 |
| Unique Coins | 246 |
| Key Fields | Account, Coin, Execution Price, Size USD, Side, Closed PnL, Fee, Timestamp |
📌 Alignment: Both datasets were merged on
dateat daily granularity. The overlapping period covers ~730 trading days. Only 6 trades were dropped due to no sentiment match.
- Python 3.10+
- pip
# 1. Clone the repository
git clone https://github.com/adarshcod30/PrimeTradeDS.git
cd PrimeTradeDS
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run the full analysis pipelinecd src
python analysis.py # Part A + B: Data prep + Analysis
python visualizations.py # Generate all 13+ charts
python bonus_models.py # Bonus: Predictive model + clustering# 4. Launch the interactive dashboardcd ..
streamlit run dashboard/app.pyBoth datasets were loaded, inspected, and cleaned:
- Timestamps converted to proper
datetimeobjects - Numeric columns coerced (handling mixed types in Size, PnL, Fee)
- Date alignment performed via inner join on
datecolumn - Duplicates checked and removed
- Missing values handled (0 missing in both datasets after cleaning)
The following daily per-account metrics were computed:
| Metric | Formula | Purpose |
|---|---|---|
total_pnl | Sum of Closed PnL per day per account | Daily profit/loss |
trade_count | Count of trades per day | Activity level |
win_rate | Profitable trades / Total trades | Success ratio |
avg_size_usd | Mean position size in USD | Risk appetite |
long_ratio | BUY trades / Total trades | Directional bias |
avg_pnl_per_trade | Total PnL / Trade count | Efficiency |
total_volume | Sum of Size USD | Capital deployed |
Result: 2,340 account-day observation rows generated from 211,218 merged trades.
| Metric | Fear (Mean) | Greed (Mean) | T-Stat | P-Value | Significant? |
|---|---|---|---|---|---|
| Total PnL | $5,185.15 | $3,973.05 | 0.93 | 0.353 | ❌ |
| Win Rate | 35.71% | 36.10% | -0.26 | 0.796 | ❌ |
| Avg PnL/Trade | $71.96 | $115.18 | -1.03 | 0.303 | ❌ |
| Trade Count | 105.36 | 82.57 | 2.26 | 0.024 | ✅ |
| Avg Size USD | $8,529.86 | $6,199.41 | 1.91 | 0.056 | |
| Long Ratio | 52.15% | 47.23% | 3.06 | 0.002 | ✅ |
🔍 Insight 1: Traders are significantly more active on Fear days (105 vs 83 trades/day, p=0.024). Fear-driven volatility creates more trading opportunities.
🔍 Insight 2: Traders show a strong long bias on Fear days (52.1% vs 47.2%, p=0.002). Counter-intuitively, traders buy the dip during fear — a contrarian signal.
🔍 Insight 3: While average PnL per trade is higher on Greed days ($115 vs $72), the total PnL is actually higher on Fear days due to increased volume — suggesting that volume, not accuracy, drives Fear-day profits.
Three segmentation schemes were applied:
| Segment | Criteria | Groups |
|---|---|---|
| Frequency | Median split on trading days | Frequent / Infrequent |
| Consistency | Sharpe ratio (mean PnL / std PnL) | Consistent Winner / Inconsistent |
| Leverage | Median split on avg leverage | High / Low (when data available) |
Based on the statistical analysis and segmentation, here are 2 data-backed strategy ideas:
Rule: During Fear days, increase trade frequency for Frequent Traders (those with high activity), but with smaller position sizes.
Rationale:
- Fear days generate 27.6% more trades on average (statistically significant, p=0.024)
- Total PnL is 30.5% higher on Fear days ($5,185 vs $3,973) due to volume
- However, per-trade efficiency is lower ($72 vs $115), so many small trades capture the volatility premium better than large bets
- Frequent traders already have the skill to execute high-volume strategies
Implementation:
IF sentiment == "Fear":
target_trade_count = baseline_count * 1.3 # Increase activity 30%
position_size = baseline_size * 0.75 # Reduce size 25%
bias = "long" # Exploit buy-the-dip tendency
Rule: During Greed days, reduce trade frequency for Inconsistent Traders and focus on higher-conviction, larger trades with a balanced long/short ratio.
Rationale:
- Greed-day per-trade PnL is 60% higher ($115 vs $72) — quality > quantity
- Long ratio drops to 47.2% (near balanced) — suggesting the market rewards two-sided trading on Greed days
- Inconsistent traders benefit from waiting for clearer setups rather than overtrading
- Position sizes can be slightly larger given higher per-trade expected value
Implementation:
IF sentiment == "Greed":
target_trade_count = baseline_count * 0.8 # Reduce activity 20%
position_size = baseline_size * 1.15 # Increase size 15%
bias = "balanced" # Long/short balanced
min_conviction_threshold = 0.7 # Only take high-confidence trades
A Random Forest and Gradient Boosting classifier were trained to predict next-day profitability bucket (Loss / Neutral / Profit) using:
Features: Sentiment, current-day PnL, win rate, trade count, position size, volume, lag features (1-day, 2-day), rolling 3-day PnL mean/std
| Model | CV Accuracy | Std |
|---|---|---|
| Random Forest | 60.7% | ±4.3% |
| Gradient Boosting | 57.1% | ±4.4% |
Baseline (random): 33.3% — our model achieves 1.82× baseline accuracy.
Top predictive features: trader_count, pnl_rolling3, total_volume, vol_rolling3 — indicating that market-wide activity and momentum are stronger predictors than sentiment alone.
K-Means clustering (k=4) identified distinct trader archetypes:
| Archetype | Count | Avg PnL | Win Rate | Avg Trades | Avg Size (USD) |
|---|---|---|---|---|---|
| 🎯 Selective Winners | 19 | $7,321 | 32.1% | 2,908 | $7,000 |
| 🏆 Elite Performers | 5 | $7,056 | 37.3% | 5,111 | $23,397 |
| 📉 Struggling Traders | 8 | $6,710 | 41.1% | 16,302 | $4,002 |
🔑 Key Insight: Elite Performers trade large positions ($23K avg) but are selective. Struggling Traders have the highest win rate (41%) but overtrade (16K trades), eroding gains through fees.
An interactive Streamlit dashboard is deployed and available for real-time exploration:
Live:primetradeds.streamlit.app
Or run locally:
streamlit run dashboard/app.pyDashboard features:
- Guided sidebar with contextual descriptions — anyone can understand the controls without prior context
- Human-readable trader labels (Trader-01, Trader-02...) instead of raw hex addresses
- Sentiment vs Performance — violin plots, PnL timelines, and statistical significance tests
- Behavioral Patterns — trade frequency, position sizing, and long/short bias comparisons
- Trader Segments — segmentation explorer with leaderboard and cross-analysis
- Predictive Model — feature importance, confusion matrix, and cluster archetypes
- Key Takeaways — summary of all insights + two strategy recommendation cards
The dashboard is deployed on Streamlit Community Cloud:
| Property | Value |
|---|---|
| URL | primetradeds.streamlit.app |
| Platform | Streamlit Community Cloud |
| Branch | main |
| Main file | dashboard/app.py |
To deploy your own instance:
- Fork this repository
- Go to share.streamlit.io
- Connect your GitHub account and select the repo
- Set Main file path to
dashboard/app.py - Click Deploy
| Category | Technology |
|---|---|
| Language | Python 3.10+ |
| Data Processing | Pandas, NumPy |
| Visualization | Matplotlib, Seaborn, Plotly |
| Machine Learning | scikit-learn (Random Forest, Gradient Boosting, K-Means) |
| Statistical Testing | SciPy (Welch's t-test) |
| Dashboard | Streamlit |
| Export | Kaleido (chart export) |
| Deployment | Streamlit Community Cloud |
- Data Preparation: Loaded 211K+ trades and 2,644 days of sentiment data. Cleaned, parsed timestamps, engineered 7 daily metrics per account, and merged on date via inner join.
- Statistical Analysis: Applied Welch's two-sample t-tests to compare Fear vs Greed day metrics. Used α=0.05 significance threshold.
- Segmentation: Created 3 trader segmentation schemes (frequency, consistency, leverage) using median splits and Sharpe ratio.
- Predictive Modeling: Built Random Forest + Gradient Boosting classifiers with lag features and rolling statistics to predict next-day profitability.
- Clustering: Applied K-Means (k=4) with PCA visualization to identify behavioral archetypes.
- Fear days drive volume, not accuracy — 27.6% more trades, but per-trade PnL is 37.5% lower
- Traders buy the dip — statistically significant long bias on Fear days (52.1% vs 47.2%, p=0.002)
- Overtrading kills returns — Struggling Traders have the highest win rate (41%) but the most trades, eroding profits through fees
- Momentum > Sentiment — Rolling PnL and volume are stronger predictors than raw sentiment
- Fear Days: Increase frequency, decrease size — harvest volatility with controlled risk
- Greed Days: Decrease frequency, increase conviction — precision over volume










