Sharpe ratio inference: private API

PortfolioOptimisers.sharpe_ratio_variance_factor — Function
sharpe_ratio_variance_factor(sr::Number, g1::Number, g2::Number)

Return the factor by which the skewness and the kurtosis of a return series scale the asymptotic variance of its Sharpe ratio.

The factor is the asymptotic variance of the sample Sharpe ratio for independent returns of any distribution, Equation 2 of [288]. Equation 8 of [289] restates it, and Section 2.5 of [289] divides it by $T - 1$ for the variance of the sample Sharpe ratio. performance_summary reads it for the standard error of the Sharpe ratio, and sharpe_ratio_moments reads it for the Probabilistic Sharpe Ratio.

Mathematical definition

\[\begin{align} v &= 1 - \hat{\gamma}_{3} \widehat{\mathrm{SR}} + \dfrac{\hat{\gamma}_{4} - 1}{4} \widehat{\mathrm{SR}}^{2}\,. \end{align}\]

Where:

  • $v$: Variance factor of the Sharpe ratio.
  • $\widehat{\mathrm{SR}}$: Sample Sharpe ratio per period of $\boldsymbol{x}$, the excess of its sample mean over the risk-free rate rf divided by its corrected sample standard deviation.
  • $\hat{\gamma}_{3}$: Sample skewness of $\boldsymbol{x}$, its third central moment divided by the cube of its biased sample standard deviation.
  • $\hat{\gamma}_{4}$: Sample kurtosis of $\boldsymbol{x}$, its fourth central moment divided by the square of its biased sample variance. It is $3$ for a normal distribution.

The factor is $1 + \widehat{\mathrm{SR}}^{2} / 2$ for a normal distribution. The kurtosis of a distribution is at least the square of its skewness plus one, so $v \geq (1 - \hat{\gamma}_{3} \widehat{\mathrm{SR}} / 2)^{2} \geq 0$. The factor is zero only for a distribution on two points.

Arguments

  • sr: Sample Sharpe ratio per period.
  • g1: Sample skewness.
  • g2: Sample excess kurtosis $\hat{\gamma}_{4} - 3$, the moment that StatsBase.kurtosis returns. So the coefficient of the square is $(g_{2} + 2) / 4$.

Returns

  • v::Number: The variance factor.

Related

References

  • [288] E. Mertens. Comments on variance of the IID estimator in Lo (2002). Working paper, University of Basel (2002). Section 1, Equation 2.
  • [289] D. H. Bailey and M. Lopez de Prado. The Sharpe ratio efficient frontier. Journal of Risk 15, 3–44 (2012). Equation 8 and Section 2.5.
source
PortfolioOptimisers.sharpe_ratio_moments — Function
sharpe_ratio_moments(x::VecNum, rf::Number)

Return the number of observations, the sample Sharpe ratio and its variance factor for a return series without its NaN entries.

probabilistic_sharpe_ratio and minimum_track_record_length read the three numbers. The closed forms are those of the # Mathematical definition of probabilistic_sharpe_ratio and of sharpe_ratio_variance_factor.

Algorithm

  1. Drop the NaN entries of x.
  2. Take T, the number of entries that remain. When T < 3, the Sharpe ratio and the factor are NaN. Two observations always have a skewness of zero and a kurtosis of one, so they give no data about the shape of the distribution.
  3. Take m, the sample mean of x, clamped to the least and the greatest entry, and s, the corrected sample standard deviation about m. The clamp moves nothing in exact arithmetic. On a constant series it makes s exactly zero. When s is not positive, the Sharpe ratio and the factor are NaN.
  4. Divide the excess m - rf by s, to get sr.
  5. Read the sample skewness and the sample excess kurtosis of x about m. Give them with sr to sharpe_ratio_variance_factor, to get v. When v is not positive, it is NaN.

Arguments

  • x: Periodic return series.
  • rf: Risk-free rate.

Returns

  • (T, sr, v): The number of entries of x that are not NaN, the sample Sharpe ratio per period, and its variance factor.

Related

source

References

[288]
E. Mertens. Comments on Variance of the IID Estimator in Lo (2002) (University of Basel, Department of Finance, 2002).
[289]
D. H. Bailey and M. Lopez de Prado. The Sharpe ratio efficient frontier. Journal of Risk 15, 3–44 (2012).