Class RiskMetrics

java.lang.Object
com.quantfinlib.risk.RiskMetrics

public final class RiskMetrics extends Object
Core quantitative risk metrics. Return-based metrics take simple periodic returns (e.g. daily); VaR/CVaR are reported as positive loss fractions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    annualizedVolatility(double[] returns, int periodsPerYear)
     
    static double
    beta(double[] assetReturns, double[] benchmarkReturns)
    Beta of an asset versus a benchmark (equal-length return series).
    static double
    conditionalVar(double[] returns, double confidence)
    Conditional VaR / Expected Shortfall: mean loss beyond the VaR threshold.
    static double
    correlation(double[] a, double[] b)
     
    static double
    downsideDeviation(double[] returns, double mar)
    Per-period downside deviation below the minimum acceptable return.
    static double
    expectedShortfall(double[] returns, double confidence)
    static double
    historicalVar(double[] returns, double confidence)
    Historical Value at Risk at the given confidence level (e.g. 0.95).
    static double
    maxDrawdown(double[] equity)
    Maximum peak-to-trough drawdown of an equity curve, as a positive fraction.
    static double
    parametricVar(double[] returns, double confidence)
    Parametric (Gaussian) VaR at the given confidence level.
    static double
    sharpeRatio(double[] returns, double riskFreeRate, int periodsPerYear)
    Annualized Sharpe ratio; riskFreeRate is annual.
    static double
    sortinoRatio(double[] returns, double riskFreeRate, int periodsPerYear)
    Annualized Sortino ratio using downside deviation below the periodic MAR.
    static double
    volatility(double[] returns)
    Per-period sample volatility.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • volatility

      public static double volatility(double[] returns)
      Per-period sample volatility.
    • annualizedVolatility

      public static double annualizedVolatility(double[] returns, int periodsPerYear)
    • historicalVar

      public static double historicalVar(double[] returns, double confidence)
      Historical Value at Risk at the given confidence level (e.g. 0.95). Returned as a positive loss fraction; 0 if the quantile is a gain.
    • parametricVar

      public static double parametricVar(double[] returns, double confidence)
      Parametric (Gaussian) VaR at the given confidence level.
    • conditionalVar

      public static double conditionalVar(double[] returns, double confidence)
      Conditional VaR / Expected Shortfall: mean loss beyond the VaR threshold.
    • expectedShortfall

      public static double expectedShortfall(double[] returns, double confidence)
    • sharpeRatio

      public static double sharpeRatio(double[] returns, double riskFreeRate, int periodsPerYear)
      Annualized Sharpe ratio; riskFreeRate is annual.
    • sortinoRatio

      public static double sortinoRatio(double[] returns, double riskFreeRate, int periodsPerYear)
      Annualized Sortino ratio using downside deviation below the periodic MAR.
    • downsideDeviation

      public static double downsideDeviation(double[] returns, double mar)
      Per-period downside deviation below the minimum acceptable return.
    • maxDrawdown

      public static double maxDrawdown(double[] equity)
      Maximum peak-to-trough drawdown of an equity curve, as a positive fraction.
    • beta

      public static double beta(double[] assetReturns, double[] benchmarkReturns)
      Beta of an asset versus a benchmark (equal-length return series).
    • correlation

      public static double correlation(double[] a, double[] b)