Loading repository data…
Loading repository data…
reece-7 / repository
rGraph is an interactive Python and Streamlit app for portfolio risk analysis with many features.
Interactive Portfolio Risk Analyzer is a Python-based portfolio analysis application that allows users to evaluate custom portfolios using historical market data, Monte Carlo simulations, risk metrics, portfolio optimization, rebalancing analysis, transaction costs, and benchmark sensitivity.
The project started as a quantitative finance notebook project and was later refactored into a reusable Python package with an interactive Streamlit interface.
Try the app online:
https://rgraph-portfolio.streamlit.app
The application allows users to input a custom portfolio and analyze it through several financial and risk-management tools.
Users can customize:
The application calculates:
The project includes two Monte Carlo approaches:
The simulations estimate:
The project includes:
The application compares:
It also estimates the impact of transaction costs and calculates cost drag under different cost assumptions.
The project analyzes the portfolio relative to a selected benchmark using:
The project is built with:
Project_Montecarlo/
├── app.py
├── run_analysis.py
├── requirements.txt
├── README.md
├── data/
├── images/
├── notebooks/
├── outputs/
└── src/
├── __init__.py
├── data_loader.py
├── risk_metrics.py
├── monte_carlo.py
├── portfolio_optimization.py
├── rebalancing.py
├── market_sensitivity.py
└── portfolio_analyzer.py
app.py: interactive Streamlit applicationrun_analysis.py: command-line version of the analysissrc/: reusable Python modulesnotebooks/: research and development notebooksoutputs/: generated CSV resultsimages/: saved visualizationsClone the repository:
git clone https://github.com/reece-7/rgraph-portfolio-risk-analyzer.git
cd rgraph-portfolio-risk-analyzer
Create a virtual environment:
python -m venv .venv
Activate the virtual environment on Windows:
.venv\Scripts\activate
Install the required packages:
pip install -r requirements.txt
Launch the Streamlit application:
streamlit run app.py
The application will open locally in the browser, usually at:
http://localhost:8501
The project also includes a non-interactive script:
python run_analysis.py
This automatically runs a default portfolio analysis and saves the results in:
outputs/final_analysis/
The default portfolio used in the project is:
| Asset | Weight |
|---|---|
| SPY | 40% |
| QQQ | 30% |
| TLT | 20% |
| GLD | 10% |
This represents a diversified portfolio with exposure to:
Users can replace these tickers and weights directly in the Streamlit interface.
The project generates several outputs, including:
CSV outputs are saved in the outputs/ folder.
The project follows a quantitative portfolio analysis workflow:
User inputs
↓
Historical price download
↓
Daily return calculation
↓
Portfolio performance analysis
↓
Risk metrics
↓
Monte Carlo simulation
↓
Portfolio optimization
↓
Rebalancing analysis
↓
Benchmark sensitivity
↓
Interactive results and downloadable outputs
The analysis is based on historical market data downloaded using yfinance.
This project is designed for educational and analytical purposes.
The results should not be interpreted as financial advice. Monte Carlo simulations and historical risk metrics are based on past data and assumptions, and they do not guarantee future performance.
Possible future improvements include:
Ouyang Sun