This project analyzes the relationship between Bitcoin market sentiment and trader performance using two datasets:
fear_greed_index.csv- Contains the Bitcoin Fear & Greed Index values and sentiment labels.
historical_data.csv- Contains historical Hyperliquid trader execution data, including trade direction, trade size, fees, and realized PnL.
The main objective is to explore whether trader behavior and profitability change under different market sentiment regimes such as Extreme Fear, Fear, Neutral, Greed, and Extreme Greed.
- bitcoin_sentiment_analysis.py
- Main analysis script.
- [fear_greed_index.csv](basepath +\fear_greed_index.csv)
- Sentiment dataset.
- historical_data.csv
- Trader dataset.
File: fear_greed_index.csv
Main columns:
dateclassificationvaluetimestamp
This dataset provides the daily market sentiment label and index value.
File: historical_data.csv
Main columns:
AccountCoinExecution PriceSize TokensSize USDSideDirectionTimestamp ISTStart PositionClosed PnLFeeOrder IDTrade IDTransaction Hash
This dataset provides trade-level execution and realized profitability data.
The script follows this flow:
- Load both CSV files.
- Clean and standardize date and numeric fields.
- Convert trade timestamps into calendar dates.
- Merge each trade with the same-day sentiment record.
- Engineer analysis fields such as:
is_profitis_lossabs_pnlsentiment_score
- Generate summary metrics.
- Create plots to visualize behavior and performance patterns.
- Save all outputs automatically into the
outputs/folder.
The script computes the following types of metrics:
- Total trades
- Unique traders
- Unique coins
- Total PnL
- Average PnL
- Median PnL
- PnL standard deviation
- Win rate
- Loss rate
- Profit factor
- Average win
- Average loss
- Maximum profit trade
- Maximum loss trade
- Average trade size
- Average fee
- Total fees
- Sharpe-like ratio
- Maximum drawdown
- Trades per sentiment
- Unique traders per sentiment
- Total PnL by sentiment
- Average PnL by sentiment
- Median PnL by sentiment
- PnL volatility by sentiment
- Win rate by sentiment
- Profit factor by sentiment
- Average trade size by sentiment
- Average fee by sentiment
- Trades by account
- Total PnL by account
- Average PnL by account
- Win rate by account
- Average trade size by account
- Total fees by account
- Trades by coin
- Total PnL by coin
- Average PnL by coin
- Win rate by coin
- Average trade size by coin
- Total fees by coin
- Trades per day
- Total daily PnL
- Average daily PnL
- Daily win rate
- Average daily trade size
- Average daily sentiment index value
The script saves the following charts inside outputs/plots/:
avg_pnl_by_sentiment.png- Average realized PnL for each sentiment regime.
win_rate_by_sentiment.png- Percentage of profitable trades by sentiment.
pnl_distribution_by_sentiment.png- Distribution of trade-level PnL for each sentiment.
trade_count_by_sentiment.png- Number of trades in each sentiment regime.
direction_by_sentiment.png- Buy and sell trade mix across sentiment regimes.
size_vs_pnl.png- Scatter plot of trade size versus realized PnL.
cumulative_pnl_over_time.png- Running cumulative PnL over time.
drawdown_over_time.png- Drawdown curve derived from cumulative PnL.
daily_activity_vs_sentiment.png- Daily trade activity compared to the Fear & Greed index.
coin_sentiment_heatmap.png
- Average PnL heatmap for top coins across sentiment regimes.
After running the script, the following files are created in outputs/:
merged_trader_sentiment.csvoverall_metrics.csvsentiment_metrics.csvdirection_metrics.csvtrader_metrics.csvcoin_metrics.csvdaily_metrics.csvcorrelation_matrix.csvanalysis_report.txt
Plot images are saved in:
outputs/plots/
Run the script from the project folder:
python bitcoin_sentiment_analysis.pyInstall the required libraries before running:
pip install pandas numpy matplotlibAt the end of execution, the project should provide:
- A merged trade-sentiment dataset
- Summary CSV files for analysis
- Visualization charts for key trading patterns
- A short text report highlighting the major findings
This output can be used directly for:
- assignment submission
- business insight reporting
- trading strategy exploration
- sentiment-based performance comparison
This project delivers a complete Python-based analysis pipeline for evaluating the impact of Bitcoin market sentiment on trader performance. It combines data cleaning, feature engineering, performance metrics, visual exploration, and exportable outputs in a single reusable script.