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
rfdivided 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 thatStatsBase.kurtosisreturns. So the coefficient of the square is $(g_{2} + 2) / 4$.
Returns
v::Number: The variance factor.
Related
References
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
- Drop the
NaNentries ofx. - Take
T, the number of entries that remain. WhenT < 3, the Sharpe ratio and the factor areNaN. Two observations always have a skewness of zero and a kurtosis of one, so they give no data about the shape of the distribution. - Take
m, the sample mean ofx, clamped to the least and the greatest entry, ands, the corrected sample standard deviation aboutm. The clamp moves nothing in exact arithmetic. On a constant series it makessexactly zero. Whensis not positive, the Sharpe ratio and the factor areNaN. - Divide the excess
m - rfbys, to getsr. - Read the sample skewness and the sample excess kurtosis of
xaboutm. Give them withsrtosharpe_ratio_variance_factor, to getv. Whenvis not positive, it isNaN.
Arguments
x: Periodic return series.rf: Risk-free rate.
Returns
(T, sr, v): The number of entries ofxthat are notNaN, the sample Sharpe ratio per period, and its variance factor.
Related
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).