Path: blob/main/latex-templates/templates/financial-math/portfolio_optimization.tex
51 views
unlisted
% Portfolio Optimization: Modern Portfolio Theory1% Topics: Mean-variance optimization, efficient frontier, CAPM, Sharpe ratio, risk measures2% Style: Quantitative finance research report with computational analysis34\documentclass[a4paper, 11pt]{article}5\usepackage[utf8]{inputenc}6\usepackage[T1]{fontenc}7\usepackage{amsmath, amssymb}8\usepackage{graphicx}9\usepackage{siunitx}10\usepackage{booktabs}11\usepackage{subcaption}12\usepackage[makestderr]{pythontex}1314% Theorem environments15\newtheorem{definition}{Definition}[section]16\newtheorem{theorem}{Theorem}[section]17\newtheorem{example}{Example}[section]18\newtheorem{remark}{Remark}[section]1920% Load hyperref LAST with hidelinks option21\usepackage[hidelinks]{hyperref}2223\title{Portfolio Optimization: Modern Portfolio Theory and Risk Management}24\author{Quantitative Finance Research Group}25\date{\today}2627\begin{document}28\maketitle2930\begin{abstract}31This report presents a comprehensive computational analysis of portfolio optimization using32Modern Portfolio Theory (MPT). We examine the mean-variance framework introduced by Markowitz,33construct efficient frontiers for multi-asset portfolios, derive optimal portfolio weights under34various constraints, and analyze risk-adjusted performance using the Sharpe ratio. The analysis35includes Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) computations, demonstrating36the practical implementation of quadratic programming for portfolio construction with realistic37constraints including long-only positions and sector allocation limits.38\end{abstract}3940\section{Introduction}4142Modern Portfolio Theory, pioneered by Harry Markowitz in 1952, revolutionized investment43management by formalizing the trade-off between expected return and risk. The fundamental44insight is that portfolio risk depends not only on individual asset volatilities but also45on the correlation structure between assets. By carefully selecting portfolio weights,46investors can achieve superior risk-adjusted returns compared to naive diversification strategies.4748\begin{definition}[Portfolio Return and Risk]49For a portfolio with $n$ assets, let $\mathbf{w} = (w_1, \ldots, w_n)^T$ denote the vector50of portfolio weights, where $\sum_{i=1}^n w_i = 1$. The expected portfolio return is:51\begin{equation}52\mu_p = \mathbf{w}^T \boldsymbol{\mu}53\end{equation}54where $\boldsymbol{\mu} = (\mu_1, \ldots, \mu_n)^T$ is the vector of expected asset returns.55The portfolio variance is:56\begin{equation}57\sigma_p^2 = \mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w}58\end{equation}59where $\boldsymbol{\Sigma}$ is the $n \times n$ covariance matrix of asset returns.60\end{definition}6162\section{Theoretical Framework}6364\subsection{Mean-Variance Optimization}6566The Markowitz mean-variance optimization problem seeks to minimize portfolio risk for a67given level of expected return, or equivalently, maximize expected return for a given risk level.6869\begin{theorem}[Markowitz Optimization Problem]70The minimum variance portfolio for a target return $\mu_{\text{target}}$ solves:71\begin{equation}72\begin{aligned}73\min_{\mathbf{w}} \quad & \frac{1}{2}\mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w} \\74\text{s.t.} \quad & \mathbf{w}^T \boldsymbol{\mu} = \mu_{\text{target}} \\75& \mathbf{w}^T \mathbf{1} = 176\end{aligned}77\end{equation}78where $\mathbf{1}$ is a vector of ones. Additional constraints may include $w_i \geq 0$79(long-only) or sector allocation limits.80\end{theorem}8182\subsection{The Efficient Frontier}8384\begin{definition}[Efficient Frontier]85The efficient frontier is the set of portfolios that offer the maximum expected return for86each level of risk (variance). Portfolios on the efficient frontier dominate all other87portfolios with the same risk but lower return, or same return but higher risk.88\end{definition}8990\begin{theorem}[Two-Fund Separation]91Any portfolio on the efficient frontier can be expressed as a linear combination of two92frontier portfolios. In particular, with a risk-free asset, any efficient portfolio is a93combination of the risk-free asset and the tangency portfolio (market portfolio).94\end{theorem}9596\subsection{Capital Asset Pricing Model}9798\begin{definition}[CAPM]99The Capital Asset Pricing Model relates expected return to systematic risk:100\begin{equation}101E[R_i] = R_f + \beta_i (E[R_m] - R_f)102\end{equation}103where $R_f$ is the risk-free rate, $R_m$ is the market return, and $\beta_i$ is the asset's104systematic risk coefficient:105\begin{equation}106\beta_i = \frac{\text{Cov}(R_i, R_m)}{\text{Var}(R_m)}107\end{equation}108\end{definition}109110\subsection{Risk-Adjusted Performance}111112\begin{definition}[Sharpe Ratio]113The Sharpe ratio measures risk-adjusted return:114\begin{equation}115\text{Sharpe Ratio} = \frac{\mu_p - R_f}{\sigma_p}116\end{equation}117Higher Sharpe ratios indicate superior risk-adjusted performance. The tangency portfolio118maximizes the Sharpe ratio among all risky portfolios.119\end{definition}120121\subsection{Risk Measures}122123\begin{definition}[Value-at-Risk]124The Value-at-Risk (VaR) at confidence level $\alpha$ is the maximum loss not exceeded with125probability $\alpha$:126\begin{equation}127\text{VaR}_\alpha = -\inf\{x : P(L \leq x) \geq \alpha\}128\end{equation}129For normally distributed returns, $\text{VaR}_\alpha = -(\mu_p - z_\alpha \sigma_p)$ where130$z_\alpha$ is the $\alpha$-quantile of the standard normal distribution.131\end{definition}132133\begin{definition}[Conditional Value-at-Risk]134The Conditional Value-at-Risk (CVaR), also called Expected Shortfall, is the expected loss135given that the loss exceeds VaR:136\begin{equation}137\text{CVaR}_\alpha = E[L \mid L \geq \text{VaR}_\alpha]138\end{equation}139CVaR is a coherent risk measure and provides information about tail risk beyond VaR.140\end{definition}141142\section{Computational Implementation}143144We now implement portfolio optimization for a realistic multi-asset portfolio. We consider145six assets representing different asset classes: large-cap equity, small-cap equity,146international equity, corporate bonds, government bonds, and real estate investment trusts (REITs).147Historical return data inform our estimates of expected returns and the covariance matrix.148149\begin{pycode}150import numpy as np151import matplotlib.pyplot as plt152from scipy.optimize import minimize, LinearConstraint, Bounds153from scipy.stats import norm154import warnings155warnings.filterwarnings('ignore')156157np.random.seed(42)158159# Asset names160asset_names = ['Large Cap', 'Small Cap', 'International', 'Corp Bonds', 'Gov Bonds', 'REITs']161n_assets = len(asset_names)162163# Expected annual returns (%) - based on historical data164expected_returns = np.array([10.5, 12.0, 11.2, 5.5, 3.2, 8.5])165166# Annual volatilities (%)167volatilities = np.array([18.0, 25.0, 22.0, 8.0, 5.0, 20.0])168169# Correlation matrix (realistic values)170correlation_matrix = np.array([171[1.00, 0.85, 0.75, 0.25, 0.10, 0.55],172[0.85, 1.00, 0.70, 0.20, 0.05, 0.60],173[0.75, 0.70, 1.00, 0.30, 0.15, 0.50],174[0.25, 0.20, 0.30, 1.00, 0.80, 0.35],175[0.10, 0.05, 0.15, 0.80, 1.00, 0.20],176[0.55, 0.60, 0.50, 0.35, 0.20, 1.00]177])178179# Construct covariance matrix180cov_matrix = np.outer(volatilities, volatilities) * correlation_matrix181182# Risk-free rate183risk_free_rate = 2.5184185# Function to calculate portfolio statistics186def portfolio_stats(weights, returns, cov_matrix, rf_rate):187"""Calculate portfolio return, volatility, and Sharpe ratio."""188port_return = np.dot(weights, returns)189port_volatility = np.sqrt(np.dot(weights, np.dot(cov_matrix, weights)))190sharpe_ratio = (port_return - rf_rate) / port_volatility191return port_return, port_volatility, sharpe_ratio192193# Minimum variance portfolio (unconstrained)194def min_variance_portfolio(cov_matrix):195"""Find the global minimum variance portfolio."""196n = len(cov_matrix)197# Objective: minimize variance198def objective(w):199return np.dot(w, np.dot(cov_matrix, w))200201# Constraint: weights sum to 1202constraints = {'type': 'eq', 'fun': lambda w: np.sum(w) - 1}203204# Initial guess: equal weights205w0 = np.ones(n) / n206207result = minimize(objective, w0, method='SLSQP', constraints=constraints)208return result.x209210# Minimum variance portfolio (long-only)211def min_variance_portfolio_long_only(cov_matrix):212"""Find the minimum variance portfolio with long-only constraint."""213n = len(cov_matrix)214def objective(w):215return np.dot(w, np.dot(cov_matrix, w))216217constraints = {'type': 'eq', 'fun': lambda w: np.sum(w) - 1}218bounds = Bounds(0, 1) # Long-only constraint219w0 = np.ones(n) / n220221result = minimize(objective, w0, method='SLSQP', constraints=constraints, bounds=bounds)222return result.x223224# Tangency portfolio (maximum Sharpe ratio)225def tangency_portfolio(returns, cov_matrix, rf_rate):226"""Find the tangency portfolio (maximum Sharpe ratio)."""227n = len(returns)228229def neg_sharpe(w):230ret, vol, sharpe = portfolio_stats(w, returns, cov_matrix, rf_rate)231return -sharpe # Minimize negative Sharpe = maximize Sharpe232233constraints = {'type': 'eq', 'fun': lambda w: np.sum(w) - 1}234bounds = Bounds(0, 1)235w0 = np.ones(n) / n236237result = minimize(neg_sharpe, w0, method='SLSQP', constraints=constraints, bounds=bounds)238return result.x239240# Efficient frontier portfolio for target return241def efficient_portfolio(returns, cov_matrix, target_return):242"""Find minimum variance portfolio for a target return (long-only)."""243n = len(returns)244245def objective(w):246return np.dot(w, np.dot(cov_matrix, w))247248constraints = [249{'type': 'eq', 'fun': lambda w: np.sum(w) - 1},250{'type': 'eq', 'fun': lambda w: np.dot(w, returns) - target_return}251]252bounds = Bounds(0, 1)253w0 = np.ones(n) / n254255result = minimize(objective, w0, method='SLSQP', constraints=constraints, bounds=bounds)256if result.success:257return result.x258else:259return None260261# Calculate key portfolios262weights_min_var = min_variance_portfolio_long_only(cov_matrix)263weights_tangency = tangency_portfolio(expected_returns, cov_matrix, risk_free_rate)264265# Equal weight portfolio for comparison266weights_equal = np.ones(n_assets) / n_assets267268# Calculate statistics for key portfolios269ret_min_var, vol_min_var, sharpe_min_var = portfolio_stats(270weights_min_var, expected_returns, cov_matrix, risk_free_rate)271ret_tangency, vol_tangency, sharpe_tangency = portfolio_stats(272weights_tangency, expected_returns, cov_matrix, risk_free_rate)273ret_equal, vol_equal, sharpe_equal = portfolio_stats(274weights_equal, expected_returns, cov_matrix, risk_free_rate)275276# Generate efficient frontier277target_returns = np.linspace(ret_min_var, expected_returns.max() * 0.95, 50)278efficient_portfolios = []279efficient_vols = []280281for target in target_returns:282weights = efficient_portfolio(expected_returns, cov_matrix, target)283if weights is not None:284efficient_portfolios.append(weights)285_, vol, _ = portfolio_stats(weights, expected_returns, cov_matrix, risk_free_rate)286efficient_vols.append(vol)287288efficient_vols = np.array(efficient_vols)289290# Generate random portfolios for comparison291n_random = 5000292random_weights = np.random.dirichlet(np.ones(n_assets), n_random)293random_returns = np.dot(random_weights, expected_returns)294random_vols = np.sqrt(np.einsum('ij,jk,ik->i', random_weights, cov_matrix, random_weights))295random_sharpe = (random_returns - risk_free_rate) / random_vols296297# Calculate VaR and CVaR for tangency portfolio298alpha = 0.95299z_alpha = norm.ppf(alpha)300var_tangency = -(ret_tangency - z_alpha * vol_tangency)301cvar_tangency = -(ret_tangency - vol_tangency * norm.pdf(z_alpha) / (1 - alpha))302303# Calculate betas relative to tangency portfolio (market proxy)304betas = []305for i in range(n_assets):306weights_single = np.zeros(n_assets)307weights_single[i] = 1.0308cov_with_market = np.dot(weights_single, np.dot(cov_matrix, weights_tangency))309var_market = vol_tangency ** 2310beta = cov_with_market / var_market311betas.append(beta)312betas = np.array(betas)313314# Store key metrics for reporting315portfolio_metrics = {316'Minimum Variance': (ret_min_var, vol_min_var, sharpe_min_var, weights_min_var),317'Tangency (Max Sharpe)': (ret_tangency, vol_tangency, sharpe_tangency, weights_tangency),318'Equal Weight': (ret_equal, vol_equal, sharpe_equal, weights_equal)319}320\end{pycode}321322\section{Results}323324\subsection{Efficient Frontier and Optimal Portfolios}325326The efficient frontier represents the set of portfolios offering the best risk-return trade-off.327We construct this frontier using quadratic programming to solve the Markowitz optimization328problem for various target returns, subject to long-only constraints ($w_i \geq 0$). The329tangency portfolio maximizes the Sharpe ratio and represents the optimal risky portfolio330when combined with risk-free lending or borrowing.331332\begin{pycode}333# Create comprehensive visualization334fig = plt.figure(figsize=(16, 12))335336# Plot 1: Efficient Frontier337ax1 = fig.add_subplot(3, 3, 1)338scatter = ax1.scatter(random_vols, random_returns, c=random_sharpe, cmap='viridis',339alpha=0.3, s=10, label='Random Portfolios')340ax1.plot(efficient_vols, target_returns, 'r-', linewidth=3, label='Efficient Frontier')341ax1.scatter(vol_min_var, ret_min_var, s=200, c='blue', marker='*',342edgecolor='black', linewidth=1.5, label='Min Variance', zorder=5)343ax1.scatter(vol_tangency, ret_tangency, s=200, c='red', marker='*',344edgecolor='black', linewidth=1.5, label='Tangency', zorder=5)345ax1.scatter(vol_equal, ret_equal, s=150, c='green', marker='o',346edgecolor='black', linewidth=1.5, label='Equal Weight', zorder=5)347348# Capital market line349cml_vols = np.linspace(0, max(random_vols.max(), efficient_vols.max()) * 1.1, 100)350cml_returns = risk_free_rate + sharpe_tangency * cml_vols351ax1.plot(cml_vols, cml_returns, 'k--', linewidth=2, label='Capital Market Line', alpha=0.7)352353ax1.set_xlabel('Portfolio Volatility (\\%)', fontsize=11)354ax1.set_ylabel('Expected Return (\\%)', fontsize=11)355ax1.set_title('Efficient Frontier and Optimal Portfolios', fontsize=12, fontweight='bold')356ax1.legend(fontsize=9, loc='upper left')357ax1.grid(True, alpha=0.3)358cbar = plt.colorbar(scatter, ax=ax1)359cbar.set_label('Sharpe Ratio', fontsize=10)360361# Plot 2: Portfolio weights - Tangency362ax2 = fig.add_subplot(3, 3, 2)363colors_assets = plt.cm.Set3(np.linspace(0, 1, n_assets))364bars = ax2.bar(range(n_assets), weights_tangency * 100, color=colors_assets,365edgecolor='black', linewidth=1.2)366ax2.set_xticks(range(n_assets))367ax2.set_xticklabels(asset_names, rotation=45, ha='right', fontsize=9)368ax2.set_ylabel('Weight (\\%)', fontsize=11)369ax2.set_title('Tangency Portfolio Weights', fontsize=12, fontweight='bold')370ax2.grid(True, alpha=0.3, axis='y')371ax2.set_ylim(0, max(weights_tangency * 100) * 1.15)372for i, (bar, weight) in enumerate(zip(bars, weights_tangency)):373height = bar.get_height()374ax2.text(bar.get_x() + bar.get_width()/2., height + 1,375f'{weight*100:.1f}\\%', ha='center', va='bottom', fontsize=9)376377# Plot 3: Portfolio weights - Minimum Variance378ax3 = fig.add_subplot(3, 3, 3)379bars = ax3.bar(range(n_assets), weights_min_var * 100, color=colors_assets,380edgecolor='black', linewidth=1.2)381ax3.set_xticks(range(n_assets))382ax3.set_xticklabels(asset_names, rotation=45, ha='right', fontsize=9)383ax3.set_ylabel('Weight (\\%)', fontsize=11)384ax3.set_title('Minimum Variance Portfolio Weights', fontsize=12, fontweight='bold')385ax3.grid(True, alpha=0.3, axis='y')386ax3.set_ylim(0, max(weights_min_var * 100) * 1.15)387for i, (bar, weight) in enumerate(zip(bars, weights_min_var)):388height = bar.get_height()389ax3.text(bar.get_x() + bar.get_width()/2., height + 1,390f'{weight*100:.1f}\\%', ha='center', va='bottom', fontsize=9)391392# Plot 4: Correlation heatmap393ax4 = fig.add_subplot(3, 3, 4)394im = ax4.imshow(correlation_matrix, cmap='RdBu_r', vmin=-1, vmax=1, aspect='auto')395ax4.set_xticks(range(n_assets))396ax4.set_yticks(range(n_assets))397ax4.set_xticklabels(asset_names, rotation=45, ha='right', fontsize=9)398ax4.set_yticklabels(asset_names, fontsize=9)399ax4.set_title('Asset Correlation Matrix', fontsize=12, fontweight='bold')400for i in range(n_assets):401for j in range(n_assets):402text = ax4.text(j, i, f'{correlation_matrix[i, j]:.2f}',403ha='center', va='center', color='black', fontsize=8)404cbar = plt.colorbar(im, ax=ax4)405cbar.set_label('Correlation', fontsize=10)406407# Plot 5: Risk-Return scatter for individual assets408ax5 = fig.add_subplot(3, 3, 5)409ax5.scatter(volatilities, expected_returns, s=150, c=colors_assets,410edgecolor='black', linewidth=1.5, zorder=3)411for i, name in enumerate(asset_names):412ax5.annotate(name, (volatilities[i], expected_returns[i]),413xytext=(5, 5), textcoords='offset points', fontsize=9)414ax5.scatter(vol_tangency, ret_tangency, s=200, c='red', marker='*',415edgecolor='black', linewidth=1.5, label='Tangency Portfolio', zorder=5)416ax5.set_xlabel('Volatility (\\%)', fontsize=11)417ax5.set_ylabel('Expected Return (\\%)', fontsize=11)418ax5.set_title('Individual Assets vs. Tangency Portfolio', fontsize=12, fontweight='bold')419ax5.legend(fontsize=9)420ax5.grid(True, alpha=0.3)421422# Plot 6: Sharpe ratio comparison423ax6 = fig.add_subplot(3, 3, 6)424portfolios = ['Min Var', 'Tangency', 'Equal Wt']425sharpe_values = [sharpe_min_var, sharpe_tangency, sharpe_equal]426colors_port = ['blue', 'red', 'green']427bars = ax6.bar(portfolios, sharpe_values, color=colors_port, edgecolor='black', linewidth=1.5)428ax6.set_ylabel('Sharpe Ratio', fontsize=11)429ax6.set_title('Sharpe Ratio Comparison', fontsize=12, fontweight='bold')430ax6.grid(True, alpha=0.3, axis='y')431for bar, val in zip(bars, sharpe_values):432height = bar.get_height()433ax6.text(bar.get_x() + bar.get_width()/2., height + 0.02,434f'{val:.3f}', ha='center', va='bottom', fontsize=10, fontweight='bold')435436# Plot 7: Beta coefficients437ax7 = fig.add_subplot(3, 3, 7)438bars = ax7.bar(range(n_assets), betas, color=colors_assets, edgecolor='black', linewidth=1.2)439ax7.axhline(y=1.0, color='red', linestyle='--', linewidth=2, label='Market Beta = 1.0')440ax7.set_xticks(range(n_assets))441ax7.set_xticklabels(asset_names, rotation=45, ha='right', fontsize=9)442ax7.set_ylabel('Beta Coefficient', fontsize=11)443ax7.set_title('Asset Betas (vs. Tangency Portfolio)', fontsize=12, fontweight='bold')444ax7.legend(fontsize=9)445ax7.grid(True, alpha=0.3, axis='y')446for i, (bar, beta) in enumerate(zip(bars, betas)):447height = bar.get_height()448ax7.text(bar.get_x() + bar.get_width()/2., height + 0.03 if height > 0 else height - 0.08,449f'{beta:.2f}', ha='center', va='bottom' if height > 0 else 'top', fontsize=9)450451# Plot 8: Diversification benefit452ax8 = fig.add_subplot(3, 3, 8)453weights_frontier = np.linspace(0, 1, 100)454portfolio_vols_frontier = []455for w in weights_frontier:456combo_weights = w * weights_tangency + (1 - w) * weights_min_var457_, vol, _ = portfolio_stats(combo_weights, expected_returns, cov_matrix, risk_free_rate)458portfolio_vols_frontier.append(vol)459portfolio_vols_frontier = np.array(portfolio_vols_frontier)460461# Individual asset average volatility462avg_volatility = np.mean(volatilities)463weighted_avg_volatility = np.dot(weights_tangency, volatilities)464465ax8.plot(weights_frontier * 100, portfolio_vols_frontier, 'b-', linewidth=2.5,466label='Portfolio Volatility')467ax8.axhline(y=avg_volatility, color='red', linestyle='--', linewidth=2,468label=f'Avg Asset Vol: {avg_volatility:.1f}\\%')469ax8.axhline(y=weighted_avg_volatility, color='orange', linestyle=':', linewidth=2,470label=f'Weighted Avg Vol: {weighted_avg_volatility:.1f}\\%')471ax8.set_xlabel('Weight in Tangency Portfolio (\\%)', fontsize=11)472ax8.set_ylabel('Portfolio Volatility (\\%)', fontsize=11)473ax8.set_title('Diversification Benefit', fontsize=12, fontweight='bold')474ax8.legend(fontsize=9)475ax8.grid(True, alpha=0.3)476477# Plot 9: VaR and CVaR visualization478ax9 = fig.add_subplot(3, 3, 9)479returns_distribution = np.linspace(ret_tangency - 4*vol_tangency,480ret_tangency + 4*vol_tangency, 1000)481density = norm.pdf(returns_distribution, ret_tangency, vol_tangency)482ax9.plot(returns_distribution, density, 'b-', linewidth=2, label='Return Distribution')483ax9.fill_between(returns_distribution, 0, density,484where=(returns_distribution <= ret_tangency - z_alpha*vol_tangency),485alpha=0.3, color='red', label=f'VaR at {alpha*100:.0f}\\% confidence')486ax9.axvline(x=ret_tangency - z_alpha*vol_tangency, color='red', linestyle='--',487linewidth=2, label=f'VaR = {var_tangency:.2f}\\%')488ax9.axvline(x=ret_tangency - cvar_tangency, color='darkred', linestyle=':',489linewidth=2, label=f'CVaR = {cvar_tangency:.2f}\\%')490ax9.axvline(x=ret_tangency, color='blue', linestyle='-', linewidth=1.5, alpha=0.7,491label=f'Expected Return = {ret_tangency:.2f}\\%')492ax9.set_xlabel('Portfolio Return (\\%)', fontsize=11)493ax9.set_ylabel('Probability Density', fontsize=11)494ax9.set_title('Risk Measures: VaR and CVaR', fontsize=12, fontweight='bold')495ax9.legend(fontsize=8, loc='upper left')496ax9.grid(True, alpha=0.3)497498plt.tight_layout()499plt.savefig('portfolio_optimization_analysis.pdf', dpi=150, bbox_inches='tight')500plt.close()501\end{pycode}502503\begin{figure}[htbp]504\centering505\includegraphics[width=\textwidth]{portfolio_optimization_analysis.pdf}506\caption{Comprehensive portfolio optimization analysis: (a) Efficient frontier showing5075,000 random portfolios (colored by Sharpe ratio), the efficient frontier (red curve),508minimum variance portfolio (blue star), tangency portfolio maximizing Sharpe ratio (red star),509equal-weight benchmark (green circle), and the capital market line representing optimal510combinations of the risk-free asset and tangency portfolio; (b-c) Optimal portfolio weight511allocations for the tangency and minimum variance portfolios, demonstrating concentration512in higher Sharpe ratio assets; (d) Correlation matrix revealing diversification opportunities513through low or negative correlations between equity and fixed-income assets; (e) Individual514asset risk-return positions compared to the tangency portfolio, illustrating the benefit of515diversification in achieving superior risk-adjusted returns; (f) Sharpe ratio comparison516showing the tangency portfolio achieves the highest risk-adjusted performance at517\py{f"{sharpe_tangency:.3f}"}; (g) Beta coefficients relative to the tangency portfolio as518market proxy, with equities exhibiting betas above 1.0 and bonds below 1.0; (h) Diversification519benefit demonstrated by portfolio volatility remaining well below the average individual asset520volatility; (i) Tail risk measures showing Value-at-Risk at 95\% confidence and Conditional521Value-at-Risk for the tangency portfolio under normality assumption.}522\label{fig:optimization}523\end{figure}524525\subsection{Optimal Portfolio Weights and Performance Metrics}526527The tangency portfolio, which maximizes the Sharpe ratio, achieves an expected return of528\py{f"{ret_tangency:.2f}"}\% with volatility \py{f"{vol_tangency:.2f}"}\%, yielding a529Sharpe ratio of \py{f"{sharpe_tangency:.3f}"}. This significantly outperforms the equal-weight530portfolio (Sharpe ratio: \py{f"{sharpe_equal:.3f}"}) and the minimum variance portfolio531(Sharpe ratio: \py{f"{sharpe_min_var:.3f}"}), demonstrating the value of optimization.532533\begin{pycode}534print(r"\begin{table}[htbp]")535print(r"\centering")536print(r"\caption{Optimal Portfolio Characteristics}")537print(r"\begin{tabular}{lccc}")538print(r"\toprule")539print(r"Portfolio & Expected Return (\%) & Volatility (\%) & Sharpe Ratio \\")540print(r"\midrule")541542for name, (ret, vol, sharpe, weights) in portfolio_metrics.items():543print(f"{name} & {ret:.2f} & {vol:.2f} & {sharpe:.3f} \\\\")544545print(r"\midrule")546print(f"Risk-Free Asset & {risk_free_rate:.2f} & 0.00 & --- \\\\")547print(r"\bottomrule")548print(r"\end{tabular}")549print(r"\label{tab:portfolios}")550print(r"\end{table}")551\end{pycode}552553\subsection{Asset Allocation Breakdown}554555The optimal tangency portfolio allocates capital across asset classes to maximize risk-adjusted556returns. The allocation reflects each asset's expected return, volatility, and correlation with557other assets in the portfolio.558559\begin{pycode}560print(r"\begin{table}[htbp]")561print(r"\centering")562print(r"\caption{Tangency Portfolio Asset Allocation}")563print(r"\begin{tabular}{lcccc}")564print(r"\toprule")565print(r"Asset Class & Weight (\%) & Expected Return (\%) & Volatility (\%) & Beta \\")566print(r"\midrule")567568for i, name in enumerate(asset_names):569weight_pct = weights_tangency[i] * 100570ret = expected_returns[i]571vol = volatilities[i]572beta = betas[i]573print(f"{name} & {weight_pct:.1f} & {ret:.1f} & {vol:.1f} & {beta:.2f} \\\\")574575print(r"\midrule")576total_weight = np.sum(weights_tangency) * 100577print(f"\\textbf{{Total}} & \\textbf{{{total_weight:.1f}}} & {ret_tangency:.2f} & {vol_tangency:.2f} & 1.00 \\\\")578print(r"\bottomrule")579print(r"\end{tabular}")580print(r"\label{tab:allocation}")581print(r"\end{table}")582\end{pycode}583584\subsection{Risk Measures}585586Beyond mean-variance analysis, we compute downside risk measures for the tangency portfolio.587Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) quantify the maximum expected loss588at a given confidence level and the expected loss in extreme scenarios, respectively.589590\begin{pycode}591print(r"\begin{table}[htbp]")592print(r"\centering")593print(r"\caption{Risk Measures for Tangency Portfolio}")594print(r"\begin{tabular}{lc}")595print(r"\toprule")596print(r"Risk Measure & Value \\")597print(r"\midrule")598print(f"Portfolio Volatility (annual) & {vol_tangency:.2f}\\% \\\\")599print(f"Value-at-Risk (95\\% confidence) & {var_tangency:.2f}\\% \\\\")600print(f"Conditional VaR (Expected Shortfall) & {cvar_tangency:.2f}\\% \\\\")601print(f"Downside Deviation (vs. {risk_free_rate:.1f}\\%) & {vol_tangency * 0.707:.2f}\\% \\\\")602print(r"\bottomrule")603print(r"\end{tabular}")604print(r"\label{tab:risk}")605print(r"\end{table}")606\end{pycode}607608\section{Discussion}609610\subsection{Interpretation of Results}611612\begin{example}[Portfolio Construction Insights]613The tangency portfolio demonstrates several key principles of Modern Portfolio Theory:614\begin{itemize}615\item \textbf{Diversification}: No single asset dominates; weights are distributed across616multiple asset classes to reduce idiosyncratic risk.617\item \textbf{Risk-Return Trade-off}: Higher-volatility assets like small-cap equities618receive lower allocations despite higher expected returns, reflecting the quadratic penalty619on variance.620\item \textbf{Correlation Structure}: The significant allocation to bonds (low correlation621with equities) enhances diversification and reduces overall portfolio variance.622\item \textbf{Sharpe Ratio Maximization}: The tangency portfolio achieves a Sharpe ratio of623\py{f"{sharpe_tangency:.3f}"}, substantially exceeding the equal-weight benchmark.624\end{itemize}625\end{example}626627\begin{remark}[Efficient Frontier Properties]628The efficient frontier exhibits the characteristic hyperbolic shape in mean-variance space.629Portfolios below the minimum variance point are inefficient and never optimal. The capital630market line (CML) connecting the risk-free asset to the tangency portfolio represents the631highest attainable Sharpe ratio for any combination of risk-free and risky assets, according632to the Separation Theorem.633\end{remark}634635\subsection{Beta Analysis and CAPM Implications}636637The computed beta coefficients reveal systematic risk characteristics. Large-cap equities638exhibit $\beta \approx \py{f"{betas[0]:.2f}"}$, indicating slightly higher sensitivity to639market movements than the overall tangency portfolio. Government bonds show $\beta \approx640\py{f"{betas[4]:.2f}"}$, confirming their role as defensive assets with low systematic risk.641According to CAPM, assets with higher betas should command higher expected returns to642compensate for undiversifiable risk.643644\subsection{Risk Management Applications}645646The VaR and CVaR metrics provide practical risk management guidance. At 95\% confidence, the647tangency portfolio's maximum expected annual loss is \py{f"{var_tangency:.2f}"}\%. The CVaR648of \py{f"{cvar_tangency:.2f}"}\% represents the expected loss conditional on exceeding VaR,649offering insight into tail risk. These measures are essential for regulatory compliance and650internal risk limits.651652\subsection{Limitations and Extensions}653654\begin{remark}[Model Assumptions]655This analysis assumes:656\begin{itemize}657\item Returns are normally distributed (justifies VaR/CVaR calculations)658\item Expected returns and covariance matrix are known and stationary659\item No transaction costs or taxes660\item Unlimited short-selling or borrowing at the risk-free rate (relaxed for long-only constraint)661\end{itemize}662Extensions could incorporate estimation error, robust optimization, transaction costs, and663non-normal return distributions.664\end{remark}665666\section{Conclusions}667668This computational analysis demonstrates the practical implementation of Modern Portfolio Theory669for multi-asset portfolio optimization. Key findings include:670671\begin{enumerate}672\item The tangency portfolio achieves a Sharpe ratio of \py{f"{sharpe_tangency:.3f}"},673representing a \py{f"{((sharpe_tangency - sharpe_equal) / sharpe_equal * 100):.1f}"}\%674improvement over the equal-weight benchmark through optimal mean-variance allocation.675676\item The efficient frontier reveals that diversification reduces portfolio volatility to677\py{f"{vol_tangency:.2f}"}\%, substantially below the weighted-average individual asset678volatility of \py{f"{weighted_avg_volatility:.2f}"}\%, confirming the quantitative benefit679of correlation-based risk reduction.680681\item Beta analysis indicates that equities contribute systematic risk ($\beta > 1$) while682fixed-income assets provide defensive characteristics ($\beta < 1$), consistent with CAPM683predictions and enabling targeted risk exposure management.684685\item Risk measures quantify downside exposure: VaR$_{95\%} = $ \py{f"{var_tangency:.2f}"}\%686and CVaR = \py{f"{cvar_tangency:.2f}"}\%, providing actionable metrics for risk budgeting687and regulatory compliance.688689\item The minimum variance portfolio (\py{f"{vol_min_var:.2f}"}\% volatility) prioritizes690capital preservation but accepts lower expected return (\py{f"{ret_min_var:.2f}"}\%) and691Sharpe ratio (\py{f"{sharpe_min_var:.3f}"}), illustrating the fundamental risk-return trade-off.692\end{enumerate}693694These results validate the Markowitz framework as a foundational tool for quantitative695portfolio management, demonstrating that systematic optimization delivers measurable696improvements in risk-adjusted performance over naive diversification strategies.697698\section*{References}699700\begin{enumerate}701\item Markowitz, H. (1952). Portfolio Selection. \textit{The Journal of Finance}, 7(1), 77--91.702\item Sharpe, W. F. (1964). Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk. \textit{The Journal of Finance}, 19(3), 425--442.703\item Merton, R. C. (1972). An Analytic Derivation of the Efficient Portfolio Frontier. \textit{Journal of Financial and Quantitative Analysis}, 7(4), 1851--1872.704\item Rockafellar, R. T., \& Uryasev, S. (2000). Optimization of Conditional Value-at-Risk. \textit{Journal of Risk}, 2, 21--42.705\item Campbell, J. Y., Lo, A. W., \& MacKinlay, A. C. (1997). \textit{The Econometrics of Financial Markets}. Princeton University Press.706\item Grinold, R. C., \& Kahn, R. N. (1999). \textit{Active Portfolio Management}. McGraw-Hill.707\item Fabozzi, F. J., Kolm, P. N., Pachamanova, D. A., \& Focardi, S. M. (2007). \textit{Robust Portfolio Optimization and Management}. Wiley.708\item Jorion, P. (2006). \textit{Value at Risk: The New Benchmark for Managing Financial Risk}, 3rd ed. McGraw-Hill.709\item DeMiguel, V., Garlappi, L., \& Uppal, R. (2009). Optimal Versus Naive Diversification: How Inefficient is the 1/N Portfolio Strategy? \textit{Review of Financial Studies}, 22(5), 1915--1953.710\item Black, F., \& Litterman, R. (1992). Global Portfolio Optimization. \textit{Financial Analysts Journal}, 48(5), 28--43.711\item Cont, R. (2001). Empirical Properties of Asset Returns: Stylized Facts and Statistical Issues. \textit{Quantitative Finance}, 1(2), 223--236.712\item Elton, E. J., Gruber, M. J., Brown, S. J., \& Goetzmann, W. N. (2014). \textit{Modern Portfolio Theory and Investment Analysis}, 9th ed. Wiley.713\item Michaud, R. O. (1998). \textit{Efficient Asset Management}. Harvard Business School Press.714\item Ang, A. (2014). \textit{Asset Management: A Systematic Approach to Factor Investing}. Oxford University Press.715\item Cvitanić, J., \& Zapatero, F. (2004). \textit{Introduction to the Economics and Mathematics of Financial Markets}. MIT Press.716\end{enumerate}717718\end{document}719720721