https://lekssz-stocks-compare-app-7wnbw9.streamlit.app/
Compare short-horizon stock forecasts (7 & 30 days) using ARIMA, Prophet, and a lightweight LSTM against simple naïve baselines. The app fetches daily prices from Yahoo Finance, plots all model forecasts on one chart, and scores models on a recent holdout window with RMSE/MAE.
Why? Quick, practical benchmarking of classic time‑series models vs a tiny neural net on real market data.
- 🔎 Tickers: choose multiple large‑caps (AAPL, MSFT, TSLA, …)
- ⏳ Horizons: 7‑ and 30‑day forecasts
- 📈 Overlay: history + all model forecasts in one Plotly chart
- 📊 Scores: RMSE & MAE on the last N trading days (default 60)
- 🧪 Baselines: Naive‑last and Naive‑drift for sanity checks
- 💾 Downloads: combined scores + per‑ticker winners as CSV
- 🧰 Graceful deps: ARIMA/Prophet/LSTM auto‑disable if not installed
- Load: Daily adjusted close via
yfinance(last 5 years by default). - Split: Train / Test (last N days = test).
- Forecast:
- ARIMA (
pmdarimaorstatsmodels) → nextHbusiness days - Prophet → directly on the exact test dates
- LSTM (small TF model) → next
Hbusiness days - Naive (last / drift) on exact test dates
- ARIMA (
- Align: Coerce outputs to test dates and drop NaNs.
- Score: RMSE/MAE on the overlapping dates.
- Visualize: Multi‑model overlay + tables + CSV export.
Use Python 3.10. (Avoid 3.12/3.13 to skip compiling heavy wheels like pandas/scipy.)
From the project folder:
./.venv310/bin/python -m streamlit run app.py
```bash
python3.10 -m venv .venv
./.venv/bin/python
python -m pip install --upgrade pip
pip install -r requirements_full.txt
python -m streamlit run app.py# From the project root
.\.venv310\Scripts\python.exe -m streamlit run app.py
First-time setup (create venv, install deps, run)
# From the project root
py -3.10 -m venv .venv
.\.venv\Scripts\Activate.ps1 # (PowerShell)
# If you get a policy error, see the note below.
python -m pip install --upgrade pip
pip install -r requirements_full.txt
python -m streamlit run app.py
Notes
If your venv is named .venv310, replace .venv accordingly.
If activation fails with an execution policy error:
```powershell
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Then try .\.venv\Scripts\Activate.ps1 again.
---
## 📦 Requirements
### `requirements.txt`
```txt
streamlit>=1.36
yfinance>=0.2.40
pandas>=1.5,<2.2
numpy==1.26.4
plotly>=5.22
scikit-learn>=1.2,<1.5
statsmodels>=0.14
pmdarima==2.0.4
prophet==1.1.5
cmdstanpy<1.2
tensorflow-cpu>=2.13,<2.16
Prophet may download CmdStan on first run (a few minutes and ~1–2 GB). You can start with ARIMA + LSTM and enable Prophet later.
If you just want ARIMA + baselines:
streamlit>=1.50
yfinance>=0.2.66
pandas<2.2
numpy==1.26.4
plotly>=6.3.0
scikit-learn>=1.7.2
pmdarima==2.0.4
statsmodels>=0.14.5- Choose Tickers, Horizon (7 or 30), and Test window (default 60).
- Toggle models (ARIMA/Prophet/LSTM). Unavailable libs show as disabled.
- Click Run.
- Review per‑ticker scores table and the multi‑model plot.
- Scroll down for Combined Results, Winners, and Download buttons.
Add a theme by creating .streamlit/config.toml:
[theme]
base = "light"
primaryColor = "#2D6CDF"
secondaryBackgroundColor = "#F6F8FB"
textColor = "#0F172A"You can also set a Plotly white template + consistent model colors in streamlit_app.py.
.
├─ app.py
├─ requirements.txt
└─ .streamlit/
└─ config.toml # optional theme
- ARIMA: often strong for short horizons; uses
auto_arimawhere available. - Prophet: smooth trends + uncertainty bands; forecasts on exact test dates.
- LSTM: tiny, single‑series; scaled with
MinMaxScaler, inverse‑transformed for metrics. - Baselines: always include for context; sometimes they beat fancy models.
| Symptom / Error | Likely cause | Fix |
|---|---|---|
No module named streamlit / command not found: streamlit |
Virtualenv not active or wrong interpreter | Activate venv, then pip install -r requirements_full.txt. Verify with which python and pip show streamlit (site‑packages should be inside .venv). Use python -m streamlit run ... to be sure it runs from the venv. |
metadata-generation-failed building pandas/scipy |
Using Python 3.12/3.13 (no prebuilt wheels) | Use Python 3.11, recreate venv, reinstall requirements. |
| Prophet slow / hangs on first run | CmdStan toolchain download/compile | Let it finish once; or start with ARIMA/LSTM and enable Prophet later. |
index is not a valid DatetimeIndex or PeriodIndex |
Non‑datetime index passed into a model | Always run the provided _normalize_ds_y before modeling; the app already enforces this. |
Input contains NaN during scoring |
Forecasts didn’t align to test dates or missing points | This app aligns forecasts to test dates and drops NaNs. If you added custom code, ensure you inner‑join on dates and dropna(['yhat','y']). |
| Charts not showing | Browser caching / app not rerun | Click Rerun in Streamlit and refresh the browser. Check console for exceptions. |
| ARIMA/Prophet/LSTM options greyed out | Library not installed in current env | Check the sidebar hints; install missing libs or toggle off the model. |
- Horizon: 7 or 30 days (UI control).
- Test window: default 60 trading days (UI control).
- LSTM: lookback/epochs/batch adjustable (sidebar).
- Data period: loader pulls last 5y by default; adjust in
load_series(...)if needed.
- Single split (no walk‑forward CV).
- Univariate LSTM (no exogenous vars).
- No hyper‑parameter search.
- Doesn’t handle stock‑specific events (splits/earnings) beyond
auto_adjust=Trueprices.
Ideas to extend: walk‑forward CV with re‑training, add ETS/Theta/XGBoost baselines, confidence intervals for LSTM via MC‑dropout, feature engineering (returns, vol, macro indicators).
Built by GBEMILEKE MICAH
Libraries: Streamlit, yfinance, pmdarima, Prophet, TensorFlow, scikit‑learn, Plotly
Released under the MIT License — see LICENSE for details.
##Screenshots

