How cristianleoo/montecarlo-portfolio-management works
File structure
• Top-level:
• app.py → Streamlit entry point (UI layer)
• config.py → global configuration (constants, API keys, default parameters)
• setup.py, requirements.txt, LICENSE, .gitignore
• package “portfolio_management/”:
• data/ → DataLoader (fetching historical prices from external market data API)
• monte_carlo/ → simulation engine (runs Monte Carlo trials)
• portfolio/ → domain objects (Portfolio) and optimizer (Sharpe‐maximizer, balanced)
• utils/ → helper routines (e.g. date validation, formatting)
• tests/: unit tests for each module
• screenshots/: sample UIs for reference
Inspect README for insights
• Describes UI workflow: ticker selection → weight input or dollar amounts → optional optimization → set simulation parameters → run Monte Carlo → interactive Plotly charts.
• Technology stack: Python 3.7+, Streamlit, Plotly, pandas/numpy.
Main components & relationships
a. Components:
• Streamlit UI (app.py)
• Configuration (config.py)
• DataLoader service
• Portfolio domain + Optimizer
• Monte Carlo Simulation engine
• Utilities
• External Market Data API
• Plotly rendering library
b. Interactions:
1. User interacts with Streamlit UI.
2. UI reads config, passes user inputs to DataLoader and Portfolio modules.
3. DataLoader fetches historical prices from external API.
4. Portfolio module builds a portfolio object; optionally calls Optimizer.
5. Simulation engine runs trials on portfolio object.
6. Results are returned to UI, formatted by utils, visualized via Plotly.
c. Architectural patterns:
• Layered architecture (UI → service/domain → data → external API)
• Separation of concerns: data access, business logic, presentation
d. Key technologies:
• Streamlit (UI layer)
• pandas & numpy (data manipulation)
• Plotly (visualization)
• Python package structure for modularity