Real-time stock forecasting using FastAPI, Streamlit and ML
An end-to-end machine learning system that predicts future stock prices using historical market data.
This project uses real-time stock data, a prediction API, and an interactive dashboard to visualize historical trends and future forecasts with confidence intervals.
Its features include:
- Real-time stock data using Yahoo Finance
- Stock price forecasting using statistical modeling
- Confidence interval visualization for predictions
- FastAPI backend serving prediction API
- Interactive Streamlit dashboard
- Historical + predicted price visualization
Tech used: Python, FastAPI, Streamlit, NumPy, Pandas, Matplotlib, yfinance
Working:
- Historical stock data is downloaded using yfinance.
- Returns and volatility are calculated from historical prices.
- A forecasting model predicts future prices using stochastic returns.
- Confidence intervals are generated to show prediction uncertainty.
- Predictions are served through a FastAPI backend.
- A Streamlit dashboard visualizes historical prices and predicted future values.
To start the FastAPI backend: uvicorn app.main:app –reload
To run the Streamlit dashboard: streamlit run dashboard.py
The dashboard show (based on the stock selected):
- Historical stock price trend
- Predicted future price
- Confidence interval band around predictions
