IndexPulse: A Stock Index Visualization, Portfolio Simulation & Price Prediction App

Hi Streamlit community :waving_hand:

I’m Hai, a Data Analyst based in Seattle with a hobby interest in financial analytics. I love exploring how data science tools can make complex investment concepts more accessible. I built IndexPulse as a personal project to bring together three things I find fascinating: global market visualization, modern portfolio theory, and machine learning forecasting, all in one interactive app.

:rocket: Try it live: https://indexpulse.streamlit.app/

:laptop: Source code: GitHub - namhaivu173/Stock_Index_App: IndexPulse: Stock Index App via Streamlit · GitHub


What the app does

IndexPulse focuses on major stock indices around the world, the kind of broad market benchmarks that institutional investors like pension funds and mutual funds use to gauge global equity performance. The app has three main pillars:

1. Stock Index Dashboard: Closing prices and trading volumes for 40+ major indices scraped from Yahoo Finance, organized by region (Americas, Europe, Asia-Pacific, and more). Users can filter by date range, select indices to compare, and explore correlations through a heatmap of daily returns.

2. Efficient Frontier & Portfolio Simulation: The app simulates thousands of random portfolios composed of different subsets of indices, then plots the classic Efficient Frontier curve showing the risk-return trade-off. It highlights three special portfolios (Minimum Risk, Maximum Return, and Maximum Sharpe Ratio) and draws the Capital Market Line anchored to the live 10-year US Treasury yield. Value at Risk (VaR) is calculated parametrically for any chosen portfolio, holding period, and confidence level.

A few things I handled carefully here:

  • Forex/currency indices (USD Index, AUD/GBP/EUR/JPY strength indices) are excluded from the simulation since they measure currency strength rather than equity performance

  • An IQR-based filter automatically removes indices with extreme annualized returns, typically local-currency indices affected by severe currency devaluation (think Argentine Peso or Russian Ruble) that produce returns in the hundreds of thousands of percent when converted to USD

3. Price Prediction with MLP Regressor: Users can pick any index, set a lookback window, and train a neural network (scikit-learn’s MLPRegressor with a(20,20)hidden layer architecture) to predict future closing prices. The app reports RMSE, MAPE, R², and Adjusted R² on the test set, and plots both the test-period predictions and a 5-day forward forecast.


Tech stack

  • streamlit for the app framework

  • yfinance for live market data

  • plotly for interactive charts

  • scipy + numpy for the portfolio optimization (SLSQP) and VaR

  • scikit-learn for the MLP model

  • pandas for all the data wrangling


What I learned building this

This project pushed me well beyond dashboarding basics and into territory I hadn’t explored much before.

  • On the finance side: I came in thinking Value at Risk was straightforward, but correctly implementing parametric VaR required genuinely understanding the math rather than just applying a formula. You need to scale returns and variance to the chosen holding period, then use the inverse normal CDF to find the worst-case portfolio value. I also learned the hard way that not all “indices” are created equal. Trade-weighted currency strength indices like the USD Index have a completely different interpretation from equity indices, and naively mixing them into a portfolio simulation produces nonsense. That discovery led me to build both a hard exclusion list and a dynamic IQR-based outlier filter, which ended up being a more robust solution than I originally planned.
  • On the machine learning side: Getting the MLP to produce sensible forecasts meant thinking carefully about feature engineering (using lagged prices as inputs), proper train/test splitting without leakage, and choosing metrics that actually reflect real-world performance. Adjusted R² was a good reminder that R² alone can be misleading. Adding more lookback features always improves R² mechanically, so penalizing model complexity matters.
  • On Streamlit itself: Managing state across tabs with st.session_state was a new pattern for me, and it turned out to be essential, especially for gracefully handling Yahoo Finance rate limit errors without crashing the whole app. Caching with @st.cache_data also taught me to think carefully about what should and shouldn’t be recomputed on every rerun.

More broadly, I found that the messiest problems were never the ones I anticipated. They were data quality issues like currencies making nominal returns look astronomical, or live API rate limits hitting users at the worst time. Building defensively around real-world data is its own skill.


Who it’s for

The app is aimed at risk-averse investors, such as pension funds and mutual funds, or anyone with a long-term horizon who cares about risk-adjusted returns. But it’s also just a fun sandbox for anyone curious about how the Efficient Frontier actually looks when you throw 40 real-world indices at it.

I’d love any feedback, especially on the simulation methodology or model improvements. Happy to answer questions in the thread and please feel free to connect with me on LinkedIn!