Semicovariance

The Semicovariance measures how the assets move together below a return of zero, each return above it counting as zero, for an investor who minds only losses (Estrada, 2008). Markowitz (1959) proposed the semivariance as the measure of downside risk; Estrada made it usable in mean-variance optimizers as a symmetric matrix.

The formula for the Semicovariance is as follows:

\[\Sigma_{i,j} = \frac{\sum_{t=1}^{T} \min\left(r_{i,t}, 0\right) \cdot \min\left(r_{j,t}, 0\right)}{T}\]

Where \(r_{i , t}\) is the return of asset i in period t of the T periods. Assets that gain when others lose have small semicovariances with them. The semivariance of a portfolio depends on which periods it loses in, which change with the weights, so the matrix is the heuristic approximation of Estrada (2008) rather than the exact downside risk of every portfolio.

Its parameters can be set, and it can be shown as a correlation matrix. The covariance matrix holds the variance of every asset and the covariance of every pair, the risk input of the mean-variance analysis of Markowitz (1952). With N assets it holds N (N + 1) / 2 numbers to estimate, and when N is not small compared to the number of periods T, the sample estimate is noisy and ill-conditioned: its smallest eigenvalues come out too small, and an optimizer that inverts it puts large weights on the combinations of assets that only look safe in the sample. The estimators differ in how they deal with this: by shrinking towards a structured target, by cleaning the eigenvalues, by weighting recent periods, by counting only large moves or by resisting outliers. Every estimate is annualized with the number of periods in a year.

Also known as: downside covariance, semivariance matrix.

In the Finance Toolkit this is get_covariance_estimate with method="semicovariance", the same function as Covariance Estimate.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_covariance_estimate:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_covariance_estimate(method="semicovariance")

Which returns:

References

  • Paper Estrada, J. (2008). “Mean-Semivariance Optimization: A Heuristic Approach.” Journal of Applied Finance, 18(1), 57-72.
  • Paper Markowitz, H. (1959). “Portfolio Selection: Efficient Diversification of Investments.” John Wiley & Sons, New York.
  • Library Referenced against PyPortfolioOpt’s semicovariance (Semicovariance)
Share