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 (Conditional Loss-Period RMS):
$$\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:
$$d_{i,t} = \min(r_{i,t}, 0)$$
$$\boldsymbol{\Sigma}_{d,ij} = \text{Cov}(d_i, d_j) \times 252$$
Positive returns are clipped to zero before covariance is calculated, emphasizing 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} = \text{Corr}(d_i, d_j)$$
Standard correlation uses all returns, while downside correlation is calculated from the centered, zero-clipped return series. This downside matrix is an optimization proxy for clipped-loss dispersion; it is intentionally not the same formula as the reported loss-period downside severity.
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}$ for its target-return constraint. Results preserve that value as Optimization Return.
The application separately reports Portfolio CAGR from the weighted daily composite series $r_{p,t} = \sum_{i=1}^{n} w_i r_{i,t}$:
$$R_p^{\text{CAGR}} = \left(\prod_{t=1}^{n} (1 + r_{p,t})\right)^{\frac{252}{n}} - 1$$
These values may differ because a weighted average of asset CAGRs is not the CAGR of the weighted return series. Both are shown with their basis instead of overwriting one with the other.
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$ standard covariance matrix or the centered covariance matrix of zero-clipped returns.
Portfolio Optimization Risk
The quadratic risk objective is:
$$\sigma_p = \sqrt{\mathbf{w}^T \boldsymbol{\Sigma} \mathbf{w}}$$
With standard covariance this equals annualized portfolio volatility. In downside mode it is centered zero-clipped covariance risk: the dispersion proxy minimized by the solver. Direct loss-period downside severity is reported separately from the realized portfolio series.
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 covariance or centered covariance of zero-clipped returns, depending on the selected optimization risk. 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_{\text{GMV}}, \mu_{\max}] \text{ where } \mu_{\text{GMV}} = \mathbf{w}_{\text{GMV}}^T\boldsymbol{\mu}, \mu_{\max} = \max(\boldsymbol{\mu})$$
Target Return Selection Process:
The chart frontier starts at the global minimum-variance portfolio and extends to the highest individual asset expected return. The displayed table portfolios are sampled across the asset-return 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 displayed portfolios (default: 10), $\mu_{\min} = \min(\boldsymbol{\mu})$, and $\mu_{\max} = \max(\boldsymbol{\mu})$. This creates a uniform distribution of table rows from the lowest-return asset to the highest-return asset, while the plotted efficient frontier uses 50 points from the global minimum-variance portfolio to the 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
- Ratios: Arithmetic excess-return Sharpe and target-consistent Sortino, with undefined zero-denominator cases shown as unavailable
- Selection: The highlighted ratio portfolio is the best of the sampled frontier points, not a separate continuous ratio optimization
- 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.