An open API service indexing awesome lists of open source software.

https://github.com/josericodata/sp500forecaster

Interactive S&P 500 stock price prediction app using machine learning and Streamlit. Visualise trends, forecast prices, and explore data insights.
https://github.com/josericodata/sp500forecaster

ai autoregressive-model datascience dublin dublin-ireland europe ireland machine-learning ml portfolio predictiveanalytics python sp500 stock-market stockprediction streamlit streamlitapps tech time-series-analysis ubuntu

Last synced: about 1 month ago
JSON representation

Interactive S&P 500 stock price prediction app using machine learning and Streamlit. Visualise trends, forecast prices, and explore data insights.

Awesome Lists containing this project

README

        

# ๐Ÿ“Š **SP500Forecaster**
### **Predicting S&P 500 Stocks with ML**

**SP500Forecaster is a machine learning-powered stock price prediction app specifically designed for S&P 500 companies. Built with Python and Streamlit, it leverages historical stock data to forecast future trends and empower investors with data-driven insights.**

---

## ๐Ÿงฌ **Project Structure**
```bash
SP500Forecaster
โ”œโ”€โ”€ assets/
โ”‚ โ”œโ”€โ”€ data/
โ”‚ โ”‚ โ””โ”€โ”€ sp500_tickers.csv
โ”‚ โ””โ”€โ”€ gifs/
โ”‚ โ””โ”€โ”€ sp500forecaster.gif
โ”œโ”€โ”€ streamlit_app/
โ”‚ โ”œโ”€โ”€ modules/
โ”‚ โ”‚ โ””โ”€โ”€ helper.py
โ”‚ โ”œโ”€โ”€ pages/
โ”‚ โ”‚ โ””โ”€โ”€ 01_๐Ÿ“ˆ_StockPredictor.py
โ”‚ โ””โ”€โ”€ 00_โ„น๏ธ_Info.py
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt
```

---

## ๐Ÿ› ๏ธ **How It's Built**

SP500Forecaster is built with the following core frameworks and tools:

- **Streamlit** - To create an intuitive web interface
- **Yahoo Finance API (YFinance)** - To fetch up-to-date financial data
- **Statsmodels** - To implement the AutoReg time-series forecasting model
- **Plotly** - To generate dynamic and interactive financial charts
- **Pandas** - To manipulate and process financial datasets

---

## ๐Ÿง‘โ€๐Ÿ’ป **How It Works**

1. The user selects a stock ticker from the S&P 500 list.
2. Historical stock data is retrieved using the Yahoo Finance API.
3. The AutoReg (Auto Regressive) model is trained on two years of historical data.
4. The model generates forecasts for the next 5โ€“180 days.
5. Results are displayed with interactive charts and tables.

---

## โœจ **Key Features**

- **Real-time S&P 500 stock data** - Access accurate and up-to-date information.
- **Interactive charts** - View historical trends and future predictions visually.
- **Custom prediction ranges** - Forecast stock prices for 5 to 180 days.
- **Downloadable CSV** - Save prediction results for further analysis.
- **User-friendly interface** - Accessible for novice and experienced users alike.

---

## ๐Ÿš€ **Getting Started**

### **Local Installation**

1. Clone the repository:
```bash
git clone https://github.com/user/SP500Forecaster.git
```
**Hint:** Replace `user` with `josericodata` in the URL above. I am deliberately asking you to pause here so you can support my work. If you appreciate it, please consider giving the repository a star or forking it. Your support means a lotโ€”thank you! ๐Ÿ˜Š

2. Navigate to the repository directory:
```bash
cd SP500Forecaster
```

3. Create a virtual environment:
```bash
python3 -m venv venvStreamlit
```

4. Activate the virtual environment:
```bash
source venvStreamlit/bin/activate
```

5. Install requirements:
```bash
pip install -r requirements.txt
```

6. Navigate to the app directory:
```bash
cd streamlit_app
```

7. Run the app:
```bash
streamlit run 00_โ„น๏ธ_Info.py
```

The app will be live at ```http://localhost:8501```

---

## ๐ŸŽฌ **Demo**

### Stock Predictor Page:
![S&P500 Price Predictor](https://raw.githubusercontent.com/josericodata/SP500Forecaster/main/assets/gifs/sp500forecaster.gif)

---
### โ–ถ๏ธ Watch the YouTube Tutorial

[![Build a Stock Predictor App in 4 Minutes with Streamlit](https://img.youtube.com/vi/aRFjkMZeKhc/maxresdefault.jpg)](https://www.youtube.com/watch?v=aRFjkMZeKhc "Click to play")

Click the image above or [here](https://www.youtube.com/watch?v=aRFjkMZeKhc) to watch the video on YouTube.

---

## ๐Ÿ”ฎ **Future Enhancements**

Planned improvements and new features include:

- **Integration of advanced ML models** (e.g., LSTM, Prophet) for better prediction accuracy.
- **Multi-stock analysis** to compare performance across different stocks.
- **Sector-based insights** to understand trends within specific industries.
- **User accounts and history tracking** for tailored predictions and personalized experiences.

---

## ๐Ÿ”ง **Environment Setup**

The SP500Forecaster app is built and tested using the following software environment:

- **Operating System**: Ubuntu 22.04.5 LTS (Jammy)
- **Python Version**: Python 3.10.12

Ensure your environment matches or exceeds these versions for optimal performance.

---

## ๐Ÿ“‹ **Important Notes**

- **Data Requirements**: Stocks with less than two years of historical data will not be processed by the model.
- **Using the Stock Predictor**:
1. Select a stock ticker from the dropdown menu.
2. Choose the desired prediction range using the slider.
3. Click the **Run Prediction** button to generate results.

---

## ๐Ÿค **Open Pull Requests**

If you find any bug, feel free to contact me by opening a pull request on GitHub or via email at **[email protected]**.

---

## โš ๏ธ **Disclaimer**

**This app is designed to demonstrate my skills in data modeling and analytics, showcasing how data-driven insights can assist in building my portfolio as a data analyst. It is not intended to provide financial advice or investment guidance. The predictions are for illustrative purposes only and should not be relied upon for making financial decisions.**