sigmaquant.performance.risk.upside_risk#

sigmaquant.performance.risk.upside_risk(returns, frequency, m=0.0, annualize=True)#

Compute upside risk (upside semi-deviation).

Upside risk is defined as the square root of the mean squared positive deviations of returns above a threshold level m. Optionally, the estimator can be annualized using the square-root- of-time rule.

Parameters:
  • returns – Time series of periodic returns.

  • frequency – Frequency of the input data.

  • m – Threshold return. Only deviations above this level contribute to the upside risk.

  • annualize – If True, scale the semi-deviation to annual frequency using the square-root-of-time rule implied by frequency.

Returns:

Upside risk (upside semi-deviation). If annualize=True the value is scaled to annual frequency.

Return type:

float

Notes

  • NaN values are ignored.

Let \(r_t\) denote the periodic returns and \(m\) a threshold level.

The upside risk (upside semi-deviation) is defined as:

\[s_u = \sqrt{ \frac{1}{T} \sum_{t=1}^{T} \max(r_t - m, 0)^2 }\]

If annualize=True the estimator is scaled as:

\[s_{u,ann} = s_u \sqrt{N}\]

where \(N\) is the number of periods per year implied by frequency.