Inspiration

Modern portfolio management often relies on backwards-looking statistical metrics like Value at Risk (VaR), which frequently underestimate systemic, macroeconomic anomalies. I was inspired to build the Quantitative Portfolio Risk Analytics Engine to give retail investors and institutional analysts the same institutional-grade macro stress-testing capabilities used on Wall Street.

When market crashes happen, correlation structures break down, and assets don't always move the way normal distributions predict. I built this engine to provide an immediate, empirical window into how a current asset configuration would survive the exact economic dynamics of past financial disasters.

What it does

The application is a web-based, real-time portfolio stress-testing dashboard. The user uploads a simple CSV file containing asset tickers and share quantities. The engine immediately:

Calculates live portfolio values, position weightings, and baseline statistics.

Dynamically pulls decades of underlying asset price history.

Simulates immediate, historical macroeconomic shock scenarios (e.g., the 2000 Dot-Com crash, 2008 GFC, 2020 COVID crash).

Accounts for structural asset age—treating equities that weren't yet publicly traded during historical windows as cash reserves (0% return impact) to prevent mathematical skew.

Provides clear visual feedback through allocation charts, clean timeline components, interactive expander metrics, and a comparative performance drawdown breakdown.

How we (I) built it

I designed the project with a split frontend/backend modular architecture perfectly suited for rapid data science iteration:

Frontend (Streamlit): I built a clean, dark-themed responsive UI, utilizing Streamlit metrics, dynamic column structures, expanding card matrices, and native rendering for data visualizations.

Backend Analytical Pipeline (yfinance & pandas): I wrote a data pipeline that programmatically fetches adjusted closing prices back to 1950. The backend maps out exact peak-to-trough date intervals for major historical crises, isolates asset drops, and performs a weighted dot-product calculation across the uploaded allocation strategy.

Data Visualization (matplotlib & seaborn): I custom-tailored layout palettes to generate intuitive asset-allocation pie charts and conditional bar plots where losses are clearly signaled by negative thresholds.

Challenges we (I) ran into

One of the largest hurdles I faced was handling asset survivorship and history limits. For example, if a user uploads a new ETF or recently listed stock (like SPCX) alongside a legacy stock (like LMT), the backend fails to find price points for the newer asset during the 2000 Dot-Com or 2008 Financial Crisis windows.

Initially, this threw out-of-bounds index errors or returned skewed NaN metrics. I resolved this by building a fail-safe fallback check within the simulation loop. If an asset did not possess valid historical data for a specific window, it gracefully decays to a cash asset (0% return impact) for that period. This ensures the rest of the portfolio is still accurately stress-tested relative to its actual weighting.

Accomplishments that we're (I am) proud of

Flawless Asynchronous Handling: Structuring the application so that structural gaps in stock data don't break the tool, processing multi-asset tickers in seconds.

Intuitive UX Design: Creating an expandable dashboard layout that takes raw user data and transforms it cleanly into clear metrics (Projected Loss vs Projected Gain) alongside exact macroeconomic context fields.

Accurate Macro Isolation: Mapping true peak-to-trough dates for events rather than generalized yearly chunks, preserving the exact severity of the market drawdowns.

On top of this, I never learned Python until this Summer for my class Algorithms for Machine Learning. I used what I have learned in that class to build this project.

What we (I) learned

I deeply explored the mechanics of financial data parsing and the realities of quantitative modeling. I learned how essential it is to isolate the true peak-to-trough intervals of market corrections rather than using calendar years, as doing so dramatically changes drawdown calculations. I also gained practical experience in designing robust error handling for historical financial data, which is notoriously full of gaps, corporate actions, and tracking variances.

What's next for Quantitative Portfolio Risk Analytics Engine

Synthetic History for Pre-IPO Assets: I plan to implement a predictive machine learning model to generate synthetic proxy histories for new assets based on sector-wide index correlations during legacy crises.

Forward-Looking Macro Simulations: Integrating predictive stress-testing based on custom user inputs, such as "Simulate a 150bps Fed Rate hike combined with oil spiking to $120/barrel."

Monte Carlo Enhancements: Supplementing the historical simulations with multi-path Monte Carlo simulations using historical covariance matrices to provide a broader probability band of drawdowns.

Built With

Share this project:

Updates

Submission history