Predict and visualize market sentiment (Fear/Greed) using trader-level data from Hyperliquid and the Bitcoin Fear & Greed Index.
π Built with Scikit-learn, Streamlit, Pandas, and real-world Web3 trading data.
Explore how trader performance and behavior correlates with market sentiment and build an end-to-end system that:
- π§Ό Cleans and merges multi-source financial datasets
- π Performs statistical testing & rolling window feature engineering
- π€ Trains a predictive model to forecast sentiment
- π Hosts a live dashboard for predictions and insights
market-sentiment-trading-analysis/
βββ data/ # Raw and processed data files
β βββ fear_greed_index.csv # Raw sentiment data
β βββ historical_data.csv # Raw trader data
β βββ merged_trader_sentiment_data.csv # Preprocessed & merged data
β βββ feature_engineered_data.csv # Cleaned + feature-rich dataset
β
βββ src/ # Source code for data processing & modeling
β βββ clean_and_merge.py # Data cleaning & joining script
β βββ statistical_tests.py # T-tests & correlation analysis
β βββ feature_engineering.py # Rolling stats + new features
β βββ predict_sentiment_model.py # Model training & evaluation
β βββ improve_model.py # Optimized model
β
βββ outputs/ # Generated outputs
β βββ models/ # Trained models and scalers
β β βββ sentiment_rf_model.pkl
β β βββ sentiment_rf_model_optimized.pkl
β β βββ scaler.pkl
β β
β βββ eda/ # Visualizations from exploratory analysis
β β βββ pnl_over_time.png
β β βββ sentiment_distribution.png
β β βββ trade_count_over_time.png
β β βββ volume_over_time.png
β β
β βββ statstics/ # Statistical test results
β βββ statistical_tests.csv
β βββ correlation_results.csv
β
βββ app/ # Dashboard app for visualization
β βββ dashboard.py # Streamlit dashboard
β
βββ requirements.txt # Project dependencies
βββ README.md # Project documentation
git clone https://github.com/yashdew03/market-sentiment-trading-analysis.git
cd market-sentiment-trading-analysispython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtpython src/clean_and_merge.py
python src/statistical_tests.py
python src/feature_engineering.py
python src/predict_sentiment_model.py
python src/improve_model.pystreamlit run app/dashboard.pyπ EDA Charts: Visualize how trader behavior changes with sentiment
π§ͺ Statistical Testing: Validate if sentiment significantly affects trading metrics
π οΈ Feature Engineering: Rolling mean, std, trade volume patterns
π€ Random Forest Model: Predict sentiment from trader metrics
π Streamlit UI: Upload your own trade data and get sentiment predictions
| Purpose | Tools Used |
|---|---|
| Data Analysis | pandas, numpy |
| Statistical Tests | scipy, statsmodels |
| Machine Learning | scikit-learn, joblib |
| Visualization | matplotlib, seaborn |
| Dashboard | streamlit |
- Data Cleaning: Handled nulls, converted timestamps, merged datasets.
- Feature Engineering: Rolling windows (3D mean/std), trade count aggregations.
- Statistical Testing: T-tests, correlation significance.
- Modeling: Random Forest with scaling + inference pipeline.
- Evaluation: Confusion matrix, F1-score, recall/precision.
Accuracy = 81%
F1-score (Greed class) = 0.89
Random Forest was selected over others for interpretability and robustness.
- Python 3.8+
- Libraries listed in
requirements.txt
Contributions, issues, and feature requests are welcome! Feel free to check the issues page (if you have one) or open a new issue to discuss changes. Pull requests are also appreciated.
- Built by Yash Dewangan
- Github: YashDewangan
- Email: [email protected]
- Linkedin: YashDewangan
Enjoy using the Predictive Model for the Market Sentiment in Indian Stock Market! π