Risk Measures

Standard Risk Metrics

PerformanceAnalytics.specificrisk — Function
specificrisk(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number},Rf::Number=0)

The spicific risk is calculated as the standard deviation of the residuals from a factor regression.

\[SpecificRisk = std(\epsilon_t) = std((r_{a,t} -r_f) - \alpha - \beta\times(r_{b,t}-r_f))\]

source
specificrisk(Ra::AssetReturn,Rb::AssetReturn,Rf::Number=0)

The spicific risk is calculated as the standard deviation of the residuals from a factor regression.

source
PerformanceAnalytics.systematicrisk — Function
systematicrisk(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number},Rf::Number=0)

Is the systematic risk of the return. It is calculated by multipling the factor loading from a linear factor model of the return against the benchmark return by the standard deviation of the benchmark return.

\[SystematicRisk = \beta_{r_a,r_b}\times std(R_b)\]

source
systematicrisk(Ra::AssetReturn,Rb::AssetReturn,Rf::Number=0)

Calculated by multipling the factor loading from a linear factor model of the return against the benchmark return by the standard deviation of the benchmark return.

source
PerformanceAnalytics.totalrisk — Function
totalrisk(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number},Rf::Number=0)

Total risk is defined as a combination of systematic and specific risk.

\[TotalRisk = \sqrt{SystematicRisk^2+SpecificRisk^2}\]

source
totalrisk(Ra::AssetReturn,Rb::AssetReturn,Rf::Number=0)

Total risk is defined as a combination of systematic and specific risk.

source

Drawdown Metrics

PerformanceAnalytics.drawdown — Function
drawdown(x::AbstractArray{<:Number})

Is the drawdown of each return from the last peak. Is the same length as the return series provided.

source
drawdown(x::AssetReturn)

Is the drawdown of each return from the last peak.

source
PerformanceAnalytics.maxdrawdown — Function
maxdrawdown(x::AbstractArray{<:Number})

Calculates the maximum drawdow for a return series.

source
maxdrawdown(x::AssetReturn)

Calculates the maximum drawdow for a return series.

source
PerformanceAnalytics.avgdrawdown — Function
avgdrawdown(x::AbstractArray{<:Number})

Returns the average drowdown for a return series.

source
avgdrawdown(x::AssetReturn)

Returns the average drowdown for a return series.

source
PerformanceAnalytics.drawdown_table — Function
drawdown_table(x::AbstractArray{<:Number},dates::AbstractArray{<:TimeType})

Returns a matrix of drawdowns sorted by depth. The second column returns the depth of the drawdown. The 3rd, 4th, and 5th columns return the start, deepest point, and final date of the drawdown. The last column returns the length of the drawdown from the start to the end.

source
drawdown_table(x::AssetReturn)

Returns a matrix of drawdowns sorted by depth. The second column returns the depth of the drawdown. The 3rd, 4th, and 5th columns return the start, deepest point, and final date of the drawdown. The last column returns the length of the drawdown from the start to the end.

source
PerformanceAnalytics.painindex — Function
painindex(R::AbstractArray{<:Number})

Mean value of drawdowns over entire period.

\[PainIndex = \sum_{t=1}^n \frac{|D_t|}{n}\text{ where }D_t\text{ is the drawdown at time t since the last peak}\]

source
painindex(R::AssetReturn)

Calculates the Pain Index.

source

Downside Risk Metrics

PerformanceAnalytics.downsidedeviation — Function
downsidedeviation(R::AbstractArray{<:Number},MAR::Number = 0)

Calculates the downside deviation of a return series. MAR = Minimum Acceptable Returns

\[DownsideDeviation = \sqrt{\sum_{t=1}^n{\frac{min[(r_t-MAR),0]^2}{n}}}\]

source
downsidedeviation(R::AssetReturn,MAR::Number = 0)

Calculates the downside deviation of a return series. MAR = Minimum Acceptable Returns

source
PerformanceAnalytics.semideviation — Function
semideviation((R::AbstractArray{<:Number})

Calculates the semi deviation of a return series. This is equal to the downside deviation where the MAR is set to the arithmetic mean of the return series.

\[SemiDeviation = \sqrt{\sum_{t=1}^n{\frac{min[(r_t-\overline{r}),0]^2}{n}}}\]

source
semideviation(R::AssetReturn)

Calculates the semi deviation of a Asset Return.

source
PerformanceAnalytics.semivariance — Function
semivariance(R::AbstractArray{<:Number})

Calculates the semi variance of a return series. This is equal to the square of the semi deviation.

\[SemiVariance = SemiDeviation^2 = \sum_{t=1}^n{\frac{min[(r_t-\overline{r}),0]^2}{n}}\]

source
semivariance(R::AbstractArray{<:Number})

Calculates the semi variance of a AssetReturn.

source

VaR & ES

PerformanceAnalytics.valueatrisk — Function
valueatrisk(R::AbstractArray{<:Number},p::Number,method::AbstractString="gaussian")

Calculates the Value at Risk (VaR) for a return series and a probility level p

Methods:

  • gaussian (Default)
  • historical
  • cornish_fisher

Gaussian:

\[VaR_p = = \overline{r} + \sigma*\Phi^{-1}(p)\]

source
valueatrisk(R::AssetReturn,p::Number,method::AbstractString="gaussian")

Calculates the Value at Risk (VaR) for a return series and a probility level p

Methods:

  • gaussian (Default)
  • historical
  • cornish_fisher
source
PerformanceAnalytics.expectedshortfall — Function
expectedshortfall(R::AbstractArray{<:Number},p::Number,method::AbstractString="gaussian")

Calculates the Expected Shortfall for a return series and a probility level p

Methods:

  • gaussian (Default)
  • historical
  • cornish_fisher

Gaussian:

\[ExpectedShortfall_p = \overline{r} + \sigma*\frac{\phi(\Phi^{-1}(p))}{1-p} \text{ where }\Phi^{-1}\text{ is the inverse of the normal CDF (quantile) and }\phi\text{ is the pdf or the standard normal}\]

source
expectedshortfall(R::AssetReturn,p::Number,method::AbstractString="gaussian")

Calculates the Expected Shortfall for a return series and a probility level p

Methods:

  • gaussian (Default)
  • historical
  • cornish_fisher
source

Other

PerformanceAnalytics.trackingerror — Function
trackingerror(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number},scale::Number=1)

Measures how well a return tracks its benchmark.

\[TrackingError(r_a,r_b) = \sqrt{\sum_{t=1}^n\frac{(r_{a,t} -r_{b,t})^2}{n}}\]

source
trackingerror(Ra::AssetReturn,Rb::AssetReturn)

Measures how well a return tracks its benchmark.

source