Skip to content

Repository files navigation

📈 Machine Learning Project — Predicting CAC 40 Daily Direction

🎯 1. Project Overview

The goal of this project is to predict the next-day direction of the CAC 40 index (Up / Down ) using historical data and engineered technical indicators.

This is a supervised classification problem using tabular time-series data.

Main question:
👉 “Given today's market conditions, can we predict whether tomorrow's CAC 40 closing price will go Up or Down?”

The project follows the complete ML workflow:

  • Data acquisition
  • Preprocessing & feature engineering
  • Model training & tuning
  • Evaluation with relevant metrics
  • Interpretation of results

📂 2. Dataset

Source: Downloaded with yfinance API

Ticker: ^FCHI Interval: Daily Period: Max

Core variables:

  • Date
  • Open
  • High
  • Low
  • Close
  • Volume

Engineered features:

  • Daily returns
  • Rolling means (5, 10, 20 days)
  • Volatility
  • RSI
  • MACD
  • Stochastic Oscillator
  • Volume trends
  • Date features (month, weekday, etc.)

🎯 3. Target Variable

We generate a 2-class classification label based on the next-day return:

  • 1 = Up (return > threshold)
  • 0 = Down (return < threshold)

Thresholds were optimized to balance the dataset.


🧹 4. Preprocessing Pipeline

✔ Missing values

  • Checked & forward-filled where needed
  • Dropped indicator warm-up rows

✔ Datetime parsing

  • Converted Date to datetime
  • Added calendar features (month, day of week…)

✔ Feature Engineering

The following indicators were computed:

  • Rolling returns
  • Rolling volatility
  • RSI
  • MACD + signal line
  • Stochastic
  • Volume-based features
  • Standard scaling where required

✔ Feature Selection

  • Correlation filtering
  • Permutation importance

🤖 5. Machine Learning Models

We tested multiple algorithms:

Baseline models

  • Decision Tree
  • Random Forest
  • KNN

Advanced models

  • LightGBM
  • Calibrated Classifier
  • Final Stacking Classifier

Tuning

  • GridSearchCV
  • TimeSeriesSplit for chronological validation
  • Optuna for best hyperparameters

📈 6. Evaluation

Metrics used

  • F1-binary
  • Accuracy
  • Confusion Matrix
  • Classification Report

🚀 7. Model Interpretation with a Streamlit Application (Full Interactive Dashboard)

This project includes a complete Streamlit dashboard that allows you to:

  • Fetch real-time market data from Yahoo Finance
  • Rebuild the full feature engineering pipeline
  • Predict next-day UP / DOWN direction
  • Visualize probabilities and historical charts
  • Display live TradingView charts inside the app
  • Explore SHAP explainability (global + local)

The app uses the same preprocessing functions and the same LightGBM model as the training notebook, ensuring consistency between offline and live predictions.

▶️ How to run the Streamlit app

Make sure you are in the project root folder, then run:

streamlit run streamlit_app/app.py

👤 8. Author

Gabriel Enthoven
BSc in Data Science for Responsible Business
EM Lyon & Centrale Lyon


🏁 9. Conclusion

This project shows that:

  • Technical indicators give predictive signal on market direction
  • Stacking improves performance compared to individual models
  • Financial time-series remain very noisy and hard to predict
  • The pipeline is clean, reproducible, robust, and interpretable

🚀 How to Use — User Guide

Welcome to the Financial Direction Predictor!
This guide explains how to install the project, reproduce the analysis, and run the interactive prediction app.


🔧 1. Installation — Quick Setup

Clone the repository:

git clone https://github.com/gabentho/ML-Project-Financial-Predictions.git
cd ML-Project-Financial-Predictions

Create and activate the conda environment:

conda env create -f environment.yml
conda activate ml-project-financial-predictions

📄 2. Use the Analysis Notebook

- Open the main notebook Cleaned_notebook.ipynb in JupyterLab or any compatible environment    
- Inside you will find:  
- data cleaning routines  
- feature engineering and technical indicators  
- model training and tuning  
- evaluation of model performance  
- result interpretation  

⚙️ This option lets you reproduce the full analysis, test your own hypotheses or adapt the pipeline if you like data science.

🌐 3. Run the Interactive Web App (Streamlit)

For fast and user-friendly predictions, you can launch the web dashboard.

▶️ Start the application:

From the project root, run:

streamlit run streamlit_app/app.py

This will open a web interface in your browser.

In the application, you can:

•	Enter any Yahoo Finance ticker (default: ^FCHI)   
•	Select how many years of historical data to load  
•	Get a next-day prediction: UP 📈 or DOWN 📉  
•	View prediction probabilities  
•	Explore historical charts & technical indicators  
•	Use SHAP explainability (global + local)  
•	Inspect the engineered dataset  

⚠️ Notes & Recommendations

•	An internet connection is required (Yahoo Finance live data)  
•	Ensure your conda environment is activated before launching Streamlit    
•	Predictions are probabilistic — this is an academic project, not financial advice    

Everything runs in real time — no manual data preparation needed.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages