This repository contains a data analysis pipeline investigating the relationship between trader performance (derived from trading history data on Hyperliquid) and broader cryptocurrency market sentiment (measured by the Bitcoin Fear and Greed Index).
The core objective of this project is to explore whether market sentiment (fear vs. greed) correlates with or influences:
- Trader Profitability (PnL): How average daily profits and losses vary under different sentiment classifications.
- Trading Activity & Volume: Whether extreme fear or greed leads to higher daily trading volumes and trade counts.
- Transaction Costs: How total daily transaction fees behave under various sentiment regimes.
Analysis.ipynb: Main Jupyter notebook containing the data preprocessing, exploratory data analysis, correlation studies, and visualization.historical_data.csv: A comprehensive log of historical trades, including price, size, side (BUY/SELL), timestamp, closed PnL, and fees.fear_greed_index.csv: Historical daily records of the Bitcoin Fear and Greed Index, classifying days into categories like Extreme Fear, Fear, Greed, and Extreme Greed.requirements.txt: Python package requirements.read_notebook.py: A utility script to inspect Jupyter notebook cells.
This dataset contains trade-level execution details for a trader's account. Key columns include:
| Column | Description | Data Type |
|---|---|---|
Account |
The trader's wallet address | String (Hexadecimal) |
Coin |
Token code or identifier | String |
Execution Price |
Execution price of the trade | Float |
Size Tokens |
Quantity of tokens traded | Float |
Size USD |
Transaction size in USD | Float |
Side |
Trade direction (BUY or SELL) |
String |
Timestamp IST |
Trade execution time (IST, format: %d-%m-%Y %H:%M) |
String / Datetime |
Closed PnL |
Realized profit and loss in USD (populated for closing trades) | Float |
Fee |
Transaction fees paid | Float |
Order ID |
Unique identifier for the order | Integer |
This dataset represents the daily market sentiment for Bitcoin. Key columns include:
| Column | Description | Data Type |
|---|---|---|
timestamp |
Unix timestamp of the index record | Integer |
value |
Sentiment score ranging from 0 (Extreme Fear) to 100 (Extreme Greed) | Integer |
classification |
Qualitative sentiment category (e.g., Fear, Extreme Fear, Greed, Extreme Greed) | String |
date |
Calendar date (format: YYYY-MM-DD) |
String / Datetime |
Make sure you have Python 3.8+ installed on your system.
Install the required libraries listed in requirements.txt:
pip install -r requirements.txtTo view and execute the analysis pipeline:
- Start the Jupyter notebook server in the project directory:
jupyter notebook
- Open
Analysis.ipynband run all cells.
- Type Conversion: Converts time columns to
datetimeobjects. Converts string numeric values to proper floats/ints, coercing errors toNaN. - Daily Aggregation: Groups the detailed trade data from
historical_data.csvby date to calculate:total_pnl: Sum of realized profits/losses per day.total_volume: Sum of size in USD per day.total_trades: Count of trades executed per day.total_fees: Sum of transaction fees paid per day.
- Merging: Performs an inner join of the daily trading statistics and the daily Fear & Greed index using the date.
- Daily PnL by Sentiment: Generates a bar plot showing the average daily PnL across different sentiment classifications (e.g., Fear, Extreme Fear, Greed, Extreme Greed).
- Daily Volume by Sentiment: Generates a bar plot illustrating average trading volume across different market sentiments.
- Computes a correlation matrix between
total_pnl,total_volume,total_trades,total_fees, and the Fear & Greed indexvalue. - Renders a Seaborn heatmap representing these correlations to identify linear relationships between sentiment score and trading metrics.
- Trading Volume & Sentiment: Extreme market sentiment (extreme greed/fear) often corresponds to elevated volumes.
- Profitability (PnL): Highlights whether trading profits increase during bullish sentiment (Greed) or defensive phases (Fear).
- Correlation Strength: Indicates the level of linear dependency between sentiment metrics and fees or transaction counts.