Skip to content

Latest commit

Β 

History

History
134 lines (76 loc) Β· 2.63 KB

File metadata and controls

134 lines (76 loc) Β· 2.63 KB

πŸ“Š Portfolio Risk Simulation Dashboard

A Streamlit-based financial risk analysis tool that performs Monte Carlo simulations on stock portfolios to estimate risk metrics such as Value at Risk (VaR) and Expected Shortfall (ES).

This dashboard allows users to build a portfolio manually or upload an Excel file, simulate market scenarios using historical data, and generate a professional PDF risk report.

πŸš€ Features πŸ“ˆ Portfolio Creation

Upload portfolio via Excel file

Manually select stocks from Nifty 50

Specify stock quantities

πŸ“Š Risk Simulation

Monte Carlo simulation using historical log returns

Configurable number of simulations

Adjustable days to expiry

πŸ“‰ Risk Metrics

Value at Risk (VaR) – 99%

Expected Shortfall (ES)

Hedged VaR

Hedged Expected Shortfall

πŸ“Š Visualization

Loss distribution histogram

Interactive Streamlit dashboard

πŸ“„ Professional PDF Report

Automatically generates a report containing:

Portfolio holdings

Current portfolio value

Risk metrics summary

Loss distribution chart

Risk interpretation

🧠 Methodology

The simulation process follows these steps:

Download historical price data using yfinance.

Compute log returns for portfolio assets and market index.

Estimate mean returns and covariance matrix.

Generate multivariate normal simulations.

Calculate simulated portfolio values.

Estimate risk metrics:

Value at Risk (VaR)

The loss threshold that will not be exceeded with 99% confidence.

Expected Shortfall (ES)

The average loss beyond the VaR level, representing tail risk.

🧰 Tech Stack Tool Purpose Python Core programming language Streamlit Web dashboard NumPy Numerical simulations Pandas Data manipulation yfinance Market data retrieval Matplotlib Visualization ReportLab PDF report generation πŸ“¦ Installation

Clone the repository:

git clone https://github.com/yourusername/portfolio-risk-simulation.git cd portfolio-risk-simulation

Install dependencies:

pip install -r requirements.txt ▢️ Run the App streamlit run MonteRisk.py

Then open the Streamlit URL shown in your terminal.

πŸ“‚ Example Portfolio Excel Format

Your Excel file must contain columns similar to:

Stock Quantity RELIANCE 10 INFY 20 HDFCBANK 5

The system automatically converts them to NSE tickers.

πŸ“Š Example Output

The dashboard provides:

Portfolio value

Loss distribution histogram

VaR & Expected Shortfall

Hedged risk metrics

Downloadable PDF risk report

⚠️ Disclaimer

This project is intended for educational and research purposes only. It should not be used as financial advice or as a substitute for professional risk management systems.

πŸ‘¨β€πŸ’» Author

Developed by Purnank Gogarkar