A comprehensive portfolio analysis tool that generates detailed PDF reports with technical indicators, risk metrics, and market analysis.
- Historical price data for portfolio securities
- Benchmark index data (S&P 500)
- Risk-free rate data from FRED
- Market indicators tracking:
- Fed Funds Rate
- 10-Year Treasury Yield
- CPI and Core CPI
- Unemployment Rate
- GDP Growth
- ISM Manufacturing
- Consumer Confidence
- Retail Sales
- Housing Starts
- S&P 500 P/E Ratio
- VIX Index
- Total portfolio value
- Portfolio weights
- Daily returns
- Portfolio beta
- Sharpe ratio
- Sortino ratio
- Risk-adjusted returns
- Portfolio concentration metrics
- Historical performance tracking
- Value at Risk (VaR):
- Historical VaR
- Parametric VaR
- Conditional VaR (Expected Shortfall)
- Monte Carlo simulation:
- Future value projections
- Risk scenarios
- Confidence intervals
- Kelly Criterion calculations
- Stop loss analysis:
- ATR-based stops
- Trailing stops
- Position-size-weighted stops
- Volatility metrics
- Drawdown analysis
- Correlation matrix
- Correlation heatmaps
- Rolling correlations
- Correlation stability metrics
- High-volatility period correlations
- Cross-asset correlations
- Dividend metrics:
- Dividend yield
- Dividend growth
- Annual dividend income
- Position-level income
- Portfolio-level yield
- Income projections
- Payout ratio analysis
- Revenue exposure by region
- Geographic concentration (HHI)
- Country/region allocation
- Geographic diversification metrics
- Sector allocation
- Sector concentration
- Sector performance contribution
- Sector rotation analysis
- Moving Averages:
- Simple Moving Averages (10, 20, 50, 100, 200 days)
- Exponential Moving Averages (12, 26, 50, 200 days)
- Moving average crossovers
- Trend strength indicators
- MACD (Moving Average Convergence Divergence):
- MACD line
- Signal line
- MACD histogram
- Trend signals
- RSI (Relative Strength Index)
- Ichimoku Cloud Analysis:
- Tenkan-sen (Conversion Line)
- Kijun-sen (Base Line)
- Senkou Span A & B (Leading Spans)
- Chikou Span (Lagging Span)
- Cloud color analysis
- Trend strength indicators
- Free Cash Flow Analysis:
- FCF metrics
- FCF margin
- FCF growth
- FCF yield
- Valuation Ratios:
- P/E ratio
- P/B ratio
- EV/EBITDA
- Financial Statement Analysis:
- Balance sheet metrics
- Income statement analysis
- Cash flow statement analysis
- PDF Report Generation:
- Portfolio holdings summary
- Performance metrics
- Risk analysis
- Technical analysis
- Income analysis
- Geographic exposure
- Market indicators
- Data Visualization:
- Correlation heatmaps
- Monte Carlo simulation paths
- Sector allocation pie charts
- Performance charts
- Technical indicator charts
- Comprehensive error handling
- Production-level logging
- Diagnostic information
- Error recovery mechanisms
- Environment variable management
- API key configuration
- Portfolio configuration
- Customizable parameters
- Flexible date ranges
- Clone the repository:
git clone https://github.com/yourusername/portfolio-analysis-tool.git
- Install required dependencies:
pip install pandas numpy matplotlib seaborn reportlab fredapi yfinance pandas_datareader
- Add your FRED API key to
api_key.env
- Configure your portfolio in
plots/portfolio_config.py
Run the main script to generate a comprehensive PDF report:
python main.py
Edit plots/portfolio_config.py
to specify your portfolio holdings in the format ticker: number_of_shares
Example portfolio:
portfolio = {
'IGV': 21.00,
'TSM': 5.00,
'AVGO': 8.35,
'GOOGL': 12.52,
'NVDA': 14.27,
The tool generates a detailed PDF report including:
- Current holdings and valuations
- Performance metrics
- Risk analysis
- Interest rates
- Economic indicators
- Market sentiment metrics
- Yield analysis
- Income projections
- Growth metrics
- Regional exposure
- Concentration analysis
- Value at Risk (VaR)
- Expected Shortfall
- Beta analysis
- Asset correlation matrix
- Heatmap visualization
- Future value projections
- Risk scenarios
- Technical indicators
- Fundamental metrics
- Risk assessment
pandas
: Data manipulation and analysisnumpy
: Numerical computationsmatplotlib
: Data visualizationseaborn
: Statistical visualizationsreportlab
: PDF generationfredapi
: Federal Reserve economic datayfinance
: Market data retrievalpandas_datareader
: Additional data sources
MIT License
Copyright (c) 2024 [Yunxiao Song]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Email: yunxiaoson98@gmail.com
This tool is for informational purposes only and should not be considered as financial advice. Always conduct your own research and due diligence before making investment decisions.