A professional-grade portfolio risk analysis platform that helps investors understand their investment risk using advanced Monte Carlo simulations, statistical modeling, and real-time market data.
-
4 Simulation Methods
- Monte Carlo Simulation
- Historical Simulation
- Bootstrap Simulation
- Stress Testing
-
Real-time Market Data π
- Live NSE/BSE stock prices
- 1-year historical data
- Automatic data alignment & cleaning
-
Professional Risk Metrics π
- Value at Risk (VaR) calculation
- Expected Shortfall (ES)
- Maximum Loss/Gain analysis
- Statistical summaries
-
Interactive Dashboard π¨
- Drag-and-drop portfolio builder
- Real-time portfolio summary
- Dynamic loss distribution charts
- Portfolio composition breakdown
-
Professional PDF Reports π
- Embedded loss distribution charts
- Financial explanations & insights
- Risk recommendations
- Compliance-ready disclaimers
-
Educational Content π
- VaR/ES explanations
- Chart interpretation guides
- Risk management recommendations
| Component | Technology |
|---|---|
| Frontend | Streamlit |
| Backend | Python, NumPy, Pandas |
| Visualization | Plotly, Matplotlib |
| Data | yfinance |
| PDF Generation | ReportLab |
| Simulations | SciPy, NumPy |
- Python 3.9+
- pip package manager
- Clone the repository
git clone https://github.com/YOUR_USERNAME/quantfolio-simulation-hub.git
cd quantfolio-simulation-hub- Create virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Run the application
streamlit run app.py- Open in browser
http://localhost:8501
-
Upload Portfolio
- Click "Upload Excel" or "Build Portfolio"
- Add stock symbols and quantities
- File format: Stock, Quantity columns
-
Configure Simulation
- Choose simulation method (Monte Carlo, Historical, Bootstrap, Stress)
- Set number of iterations (1,000 - 50,000)
- Select confidence level (90% - 99%)
-
Run Simulation
- Click "π Run Simulation"
- Wait for calculations to complete
-
Analyze Results
- View risk metrics (VaR, ES)
- Explore loss distribution chart
- Read educational explanations
- Download PDF report or CSV data
The maximum amount you could lose on a single day with a given confidence level (e.g., 95%).
Example: VaR of βΉ50,000 at 95% confidence means:
- 95% of days, you won't lose more than βΉ50,000
- 5% of days, you might lose more than βΉ50,000
The average loss on days when the loss exceeds the VaR threshold. Represents the worst-case scenario losses.
Generates thousands of random market scenarios based on historical volatility and correlation to estimate potential portfolio outcomes.
quantfolio-simulation-hub/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ README.md # This file
β
βββ simulations/
β βββ monte_carlo.py # Monte Carlo implementation
β βββ historical.py # Historical simulation
β βββ bootstrap.py # Bootstrap resampling
β βββ stress_test.py # Stress test simulation
β
βββ utils/
β βββ data_fetcher.py # yfinance data integration
β βββ pdf_generator.py # PDF report generation
β βββ explanations.py # Financial education content
β βββ styling.py # CSS styling
β βββ ...
β
βββ ui/
βββ portfolio_builder.py # Portfolio input interface
βββ modern_components.py # Streamlit components
βββ charts.py # Visualization
- β Intelligent data cleaning: Handles missing values using forward/backward fill
- β Stock alignment: Validates portfolio stocks against downloaded data
- β Error handling: Comprehensive error messages for users
- β Performance optimization: 10K simulations run in <5 seconds
- β Professional output: PDFs with embedded charts and explanations
This project demonstrates:
-
Financial Computing
- Monte Carlo simulations
- Statistical risk modeling
- Time-series analysis
-
Data Engineering
- Real-time data fetching
- Data cleaning & alignment
- Missing value handling
-
Software Design
- Modular architecture
- Error handling
- Code organization
-
Product Development
- UI/UX design
- Professional reporting
- User education
- Portfolio optimization suggestions
- Tax-loss harvesting recommendations
- Correlation analysis between stocks
- Multi-currency support
- Mobile app version
- API for integration
- Historical report tracking
- Risk alerts & notifications
- Data is fetched in real-time from Yahoo Finance (yfinance)
- Simulations are based on 1-year historical data
- Past performance does not guarantee future results
- See disclaimer in PDF reports for important legal information
This tool is for educational and analytical purposes only. It is not a substitute for professional financial advice. Past performance does not guarantee future results. Consult with a qualified financial advisor before making investment decisions.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.
[Your Name]
- GitHub: @purnankgogarkar
- LinkedIn: Purnank Gogarkar
- Email: purnank18@gmail.com
Feel free to open an issue or reach out directly!
Built with β€οΈ for financial literacy
Quantfolio Simulation Hub Β© 2024