Ticker StatisticsIndividual asset analysis
Expected Return Calculation (μ)
Expected returns are calculated using the Compound Annual Growth Rate (CAGR) methodology over historical data:
$$\mu_i = \left(\frac{P_{\text{end}}}{P_{\text{start}}}\right)^{\frac{252}{n}} - 1$$
where $P_{\text{end}}$ is the final adjusted price, $P_{\text{start}}$ is the initial adjusted price, $n$ is the number of trading days, and $252$ represents the typical number of trading days per year.
For daily returns series, this is equivalent to:
$$\mu_i = \left(\prod_{t=1}^{n} (1 + r_{i,t})\right)^{\frac{252}{n}} - 1$$
where $r_{i,t} = \frac{P_{i,t} - P_{i,t-1}}{P_{i,t-1}}$ are daily returns.
CAGR vs Arithmetic Mean:
$$\text{Arithmetic Mean: } \bar{r} = \frac{1}{n}\sum_{t=1}^{n} r_t \quad \text{vs} \quad \text{Geometric Mean: } \left(\prod_{t=1}^{n} (1 + r_t)\right)^{\frac{1}{n}} - 1$$
Why We Use CAGR Instead of Arithmetic Mean:
- Time Horizon Mismatch: We use 10+ years of daily data but present annual results - CAGR better represents what buy-and-hold investors actually experienced
- Compounding vs Averaging: Arithmetic mean doesn't reflect actual investor experience. Example: Two years of +60%, -31% returns have 14.5% arithmetic mean but only ~5% CAGR ($100 → $160 → $110.4). CAGR shows what investors actually earned.
Risk Metrics: Standard Deviation vs Downside Deviation
Portfolio optimization requires measuring asset risk. Two approaches are available:
Standard Deviation (Volatility):
$$\sigma_i = \sqrt{\frac{1}{n-1}\sum_{t=1}^{n}(r_{i,t} - \bar{r}_i)^2} \times \sqrt{252}$$
Measures total variability around the mean return. Annualized by multiplying daily standard deviation by $\sqrt{252}$.
Downside Deviation (Semi-Deviation):
$$\sigma_{d,i} = \sqrt{\frac{1}{n_d}\sum_{r_{i,t}<0}r_{i,t}^2} \times \sqrt{252}$$
Measures only negative return variability, where $n_d$ is the number of negative return periods. Focuses on actual downside risk rather than total volatility.
Practical Interpretation:
- 10% Standard Deviation: Portfolio typically deviates ±10% from its average return (both gains and losses)
- 10% Downside Deviation: When portfolio experiences losses, typical magnitude is ~10% annually
- Key Difference: Downside deviation ignores upside volatility and only measures "how bad losses get"
When to Use Each Metric:
- Use Standard Deviation if: You view all volatility (both gains and losses) as risk and want traditional symmetric risk treatment
- Use Downside Deviation if: You only consider losses as "risk" and don't mind upside volatility from large gains. This deviates from traditional MPT.
- Portfolio Impact: Downside-focused optimization tends to prefer assets with positive skewness (infrequent large returns outweigh infrequent large losses)
Covariance Matrix Construction
The covariance matrix $\boldsymbol{\Sigma}$ captures correlations between assets and varies by risk metric:
Standard Covariance Matrix:
$$\boldsymbol{\Sigma}_{ij} = \frac{1}{n-1}\sum_{t=1}^{n}(r_{i,t} - \bar{r}_i)(r_{j,t} - \bar{r}_j) \times 252$$
Downside Covariance Matrix:
$$\boldsymbol{\Sigma}_{d,ij} = \frac{1}{n}\sum_{t=1}^{n}\min(r_{i,t}, 0) \cdot \min(r_{j,t}, 0) \times 252$$
Uses only simultaneous negative returns, capturing downside co-movement patterns. Both matrices are annualized by multiplying by 252.
Correlation Matrices:
$$\rho_{ij} = \frac{\boldsymbol{\Sigma}_{ij}}{\sigma_i \sigma_j} \quad \text{and} \quad \rho_{d,ij} = \frac{\boldsymbol{\Sigma}_{d,ij}}{\sigma_{d,i} \sigma_{d,j}}$$
Standard correlation uses all returns, while downside correlation focuses on co-movement during negative return periods only.
Portfolio OptimizationMathematical framework for constructing optimal portfolios through mean-variance optimization and efficient frontier analysis.
Portfolio Return
The expected return of a portfolio is the weighted average of individual asset expected returns:
$$R_p = \sum_{i=1}^{n} w_i \mu_i = \mathbf{w}^T \boldsymbol{\mu}$$
where $\mathbf{w} = [w_1, w_2, ..., w_n]^T$ are portfolio weights and $\boldsymbol{\mu} = [\mu_1, \mu_2, ..., \mu_n]^T$ are expected returns calculated using CAGR.
* The optimizer uses the linear relationship $\mathbf{w}^T\boldsymbol{\mu}$ when solving the mean-variance problem. After an optimal portfolio is found, the application displays the portfolio’s expected return as the actual CAGR of the composite return stream, not the linear projection.
The displayed value is computed from the realized daily composite returns $r_{p,t} = \sum_{i=1}^{n} w_i r_{i,t}$:
$$R_p^{\text{display}} = \left(\prod_{t=1}^{n} (1 + r_{p,t})\right)^{\frac{252}{n}} - 1$$
This ensures the reported valur matches the compounded performance you would have experienced holding the optimized weights over the full sample.
Portfolio Variance
Portfolio variance accounts for individual variances and pairwise covariances:
$$\sigma_p^2 = \sum_{i=1}^{n} \sum_{j=1}^{n} w_i w_j \sigma_{ij} = \mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w}$$
where $\boldsymbol{\Sigma}$ is the $n \times n$ covariance matrix (standard or downside) and $\sigma_{ij} = \text{Cov}(R_i, R_j)$.
Portfolio Risk (Volatility)
Portfolio risk is measured as the standard deviation (volatility):
$$\sigma_p = \sqrt{\mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w}}$$
The specific risk interpretation depends on the chosen metric: total volatility (standard) or downside volatility (downside deviation).
Optimization Problem
For each target return $\mu^*$, we solve the constrained optimization using numerical methods:
$$\begin{align}
\min_{\mathbf{w}} \quad & \mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w} \\
\text{subject to} \quad & \mathbf{w}^T \boldsymbol{\mu} = \mu^* \\
& \mathbf{w}^T \mathbf{1} = 1 \\
& 0 \leq w_i \leq 1 \quad \forall i
\end{align}$$
The covariance matrix $\boldsymbol{\Sigma}$ represents either standard or downside covariance depending on the selected risk metric. The bounds constraint $0 \leq w_i \leq 1$ enforces long-only portfolios (no short selling).
Numerical Solution Method
We use Sequential Least Squares Programming (SLSQP) via scipy.optimize.minimize:
$$\min_{\mathbf{w}} \quad \mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w}$$
This numerical optimization uses Sequential Quadratic Programming (SQP) with gradient-based methods to handle the inequality constraints (bounds) that prevent the use of analytical Lagrangian solutions.
Efficient Frontier Construction
The efficient frontier is constructed by solving the optimization problem for multiple target returns*:
$$\mu^* \in [\mu_{\min}, \mu_{\max}] \text{ where } \mu_{\min} = \min(\boldsymbol{\mu}), \mu_{\max} = \max(\boldsymbol{\mu})$$
Target Return Selection Process:
The target returns $\mu^*$ are selected at equally spaced intervals across the feasible range:
$$\mu^*_i = \mu_{\min} + \frac{i-1}{n-1} \cdot (\mu_{\max} - \mu_{\min}), \quad i = 1, 2, ..., n$$
where $n$ is the number of portfolios to generate (default: 10). This creates a uniform distribution of target returns from the minimum possible return (single-asset portfolio of lowest-return asset) to the maximum possible return (single-asset portfolio of highest-return asset).
Frontier Points:
Each point $(\sigma_p, R_p)$ on the frontier represents the minimum achievable risk for that return level. The resulting curve shows the trade-off between expected return and risk.
* Based on historical data; future performance may differ significantly.
Implementation Details
- Constraints: Long-only portfolios (no short selling allowed)
- Method: Numerical optimization instead of analytical solution
- Sharpe Ratio: Simplified version without risk-free rate
- Bounds: Portfolio weights constrained to [0, 1] interval
These modifications make the optimization more practical for real-world portfolio construction while maintaining the core risk minimization principle.
Academic Foundation
This implementation is based on Modern Portfolio Theory developed by Harry Markowitz (1952), for which he received the Nobel Prize in Economic Sciences.
Reference: Markowitz, H. (1952). Portfolio Selection. The Journal of Finance, 7(1), 77-91.
Additional Reading:
• The Legacy of Modern Portfolio Theory - Fabozzi, F.J., Gupta, F., & Markowitz, H.M.