Skip to content

Omgiri01/Primetrade-Data-Science-Assignment

Repository files navigation

Trader Performance vs Market Sentiment on Hyperliquid

Overview

This repository contains the analysis for the Primetrade.ai Data Science Intern assignment. The objective is to analyze how market sentiment (Bitcoin Fear/Greed Index) relates to trader behavior and performance on the Hyperliquid platform.

Contents

  • analysis.ipynb: The primary Jupyter Notebook containing the data preparation, exploratory data analysis, visualizations, and predictive modeling.
  • app.py: A lightweight Streamlit dashboard to interactively explore trader metrics and sentiment data.
  • aggregated_trader_metrics.csv: The processed and aggregated data generated by the notebook, used for the dashboard.
  • *.png: Output charts generated during the analysis.

Setup & How to Run

Prerequisites

  • Python 3.8+
  • Required libraries: pandas, numpy, matplotlib, seaborn, scikit-learn, streamlit, plotly, jupyter

Install dependencies using:

pip install pandas numpy matplotlib seaborn scikit-learn streamlit plotly jupyter

Running the Analysis

  1. Place sentiment.csv and trader_data.csv in the root directory.
  2. Open and run analysis.ipynb in Jupyter Notebook or JupyterLab to execute the end-to-end analysis and generate the model and charts.
jupyter notebook analysis.ipynb

Running the Dashboard (Bonus)

To explore the interactive dashboard:

streamlit run app.py

Write-up

Methodology

  1. Data Preparation: The trader dataset was aggregated daily per account. Key metrics such as Daily PnL, Trade Frequency, Average Trade Size, Win Rate, and Total Volume (as a proxy for leverage/aggressiveness) were calculated. The Long/Short Ratio was derived to understand market bias.
  2. Alignment: Trader timestamps (IST) were converted to a consistent daily frequency and merged with the Bitcoin Fear/Greed Index based on the date.
  3. Segmentation: Traders were segmented using the medians into:
    • Frequent vs Infrequent (based on Trade Count)
    • Winner vs Loser (based on Win Rate)
    • High Volume vs Low Volume (based on Total Trade Volume USD)
  4. Modeling: A K-Means clustering algorithm grouped traders into 3 behavioral archetypes. Additionally, a Random Forest Classifier was trained to predict the next-day profitability bucket (Win/Loss) using current day behavior and sentiment features.

Insights

  1. PnL & Win Rate vs Sentiment: Traders generally experience higher PnL and wider win-rate distributions during Greed days compared to Fear days, suggesting that trending bullish markets provide better returns on Hyperliquid.
  2. Behavioral Shifts: On average, the trade frequency drops during Fear days, but the Long/Short ratio remains relatively balanced or tilts slightly short. During Greed days, trade size and frequency spike, indicating higher aggressiveness.
  3. Segment Performance: Frequent traders suffer more significant drawdowns during Fear days but outperform Infrequent traders during Greed days. Infrequent traders exhibit a more consistent, albeit lower, return profile across different market sentiments.

Strategy Recommendations

  • Rule of Thumb 1 (Dynamic Leverage & Frequency): During Extreme Fear days, throttle back trade frequency and reduce leverage (position sizing). The data shows frequent trading during Fear days leads to outsized losses. Algorithms or discretionary traders should widen timeframes and wait for high-conviction setups.
  • Rule of Thumb 2 (Trend Following on Greed): During Greed days, increase position sizing for the "Winner" segment while maintaining a Long bias. Consistent winners capitalize effectively on Greed days; allocating more capital to these archetypes (or mirroring their behavior) during bullish sentiment yields optimal PnL.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors