Lean  $LEAN_TAG$
QuantConnect.Statistics.Statistics Class Reference

Calculate all the statistics required from the backtest, based on the equity curve and the profit loss statement. More...

Static Public Member Functions

static decimal DrawdownPercent (SortedDictionary< DateTime, decimal > equityOverTime, int rounding=2)
 Drawdown maximum percentage. More...
 
static decimal CompoundingAnnualPerformance (decimal startingCapital, decimal finalCapital, decimal years)
 Annual compounded returns statistic based on the final-starting capital and years. More...
 
static double AnnualPerformance (List< double > performance, double tradingDaysPerYear)
 Annualized return statistic calculated as an average of daily trading performance multiplied by the number of trading days per year. More...
 
static double AnnualVariance (List< double > performance, double tradingDaysPerYear)
 Annualized variance statistic calculation using the daily performance variance and trading days per year. More...
 
static double AnnualStandardDeviation (List< double > performance, double tradingDaysPerYear)
 Annualized standard deviation More...
 
static double AnnualDownsideVariance (List< double > performance, double tradingDaysPerYear, double minimumAcceptableReturn=0)
 Annualized variance statistic calculation using the daily performance variance and trading days per year. More...
 
static double AnnualDownsideStandardDeviation (List< double > performance, double tradingDaysPerYear, double minimumAcceptableReturn=0)
 Annualized downside standard deviation More...
 
static double TrackingError (List< double > algoPerformance, List< double > benchmarkPerformance, double tradingDaysPerYear)
 Tracking error volatility (TEV) statistic - a measure of how closely a portfolio follows the index to which it is benchmarked More...
 
static double SharpeRatio (double averagePerformance, double standardDeviation, double riskFreeRate)
 Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk. More...
 
static decimal SharpeRatio (decimal averagePerformance, decimal standardDeviation, decimal riskFreeRate)
 Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk. More...
 
static double SharpeRatio (List< double > algoPerformance, double riskFreeRate, double tradingDaysPerYear)
 Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk. More...
 
static double SortinoRatio (List< double > algoPerformance, double riskFreeRate, double tradingDaysPerYear, double minimumAcceptableReturn=0)
 Sortino ratio with respect to risk free rate: measures excess of return per unit of downside risk. More...
 
static double ProbabilisticSharpeRatio (List< double > listPerformance, double benchmarkSharpeRatio)
 Helper method to calculate the probabilistic sharpe ratio More...
 
static double ObservedSharpeRatio (List< double > listPerformance)
 Calculates the observed sharpe ratio More...
 
static decimal DrawdownPercent (decimal current, decimal high, int roundingDecimals=2)
 Calculate the drawdown between a high and current value More...
 

Detailed Description

Calculate all the statistics required from the backtest, based on the equity curve and the profit loss statement.

This is a particularly ugly class and one of the first ones written. It should be thrown out and re-written.

Definition at line 31 of file Statistics.cs.

Member Function Documentation

◆ DrawdownPercent() [1/2]

static decimal QuantConnect.Statistics.Statistics.DrawdownPercent ( SortedDictionary< DateTime, decimal >  equityOverTime,
int  rounding = 2 
)
static

Drawdown maximum percentage.

Parameters
equityOverTime
rounding
Returns

Definition at line 39 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompoundingAnnualPerformance()

static decimal QuantConnect.Statistics.Statistics.CompoundingAnnualPerformance ( decimal  startingCapital,
decimal  finalCapital,
decimal  years 
)
static

Annual compounded returns statistic based on the final-starting capital and years.

Parameters
startingCapitalAlgorithm starting capital
finalCapitalAlgorithm final capital
yearsYears trading
Returns
Decimal fraction for annual compounding performance

Definition at line 68 of file Statistics.cs.

Here is the caller graph for this function:

◆ AnnualPerformance()

static double QuantConnect.Statistics.Statistics.AnnualPerformance ( List< double >  performance,
double  tradingDaysPerYear 
)
static

Annualized return statistic calculated as an average of daily trading performance multiplied by the number of trading days per year.

Parameters
performanceDictionary collection of double performance values
tradingDaysPerYearTrading days per year for the assets in portfolio

May be unaccurate for forex algorithms with more trading days in a year

Returns
Double annual performance percentage

Definition at line 87 of file Statistics.cs.

Here is the caller graph for this function:

◆ AnnualVariance()

static double QuantConnect.Statistics.Statistics.AnnualVariance ( List< double >  performance,
double  tradingDaysPerYear 
)
static

Annualized variance statistic calculation using the daily performance variance and trading days per year.

Parameters
performance
tradingDaysPerYear

Invokes the variance extension in the MathNet Statistics class

Returns
Annual variance value

Definition at line 99 of file Statistics.cs.

Here is the caller graph for this function:

◆ AnnualStandardDeviation()

static double QuantConnect.Statistics.Statistics.AnnualStandardDeviation ( List< double >  performance,
double  tradingDaysPerYear 
)
static

Annualized standard deviation

Parameters
performanceCollection of double values for daily performance
tradingDaysPerYearNumber of trading days for the assets in portfolio to get annualize standard deviation.

Invokes the variance extension in the MathNet Statistics class. Feasibly the trading days per year can be fetched from the dictionary of performance which includes the date-times to get the range; if is more than 1 year data.

Returns
Value for annual standard deviation

Definition at line 115 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AnnualDownsideVariance()

static double QuantConnect.Statistics.Statistics.AnnualDownsideVariance ( List< double >  performance,
double  tradingDaysPerYear,
double  minimumAcceptableReturn = 0 
)
static

Annualized variance statistic calculation using the daily performance variance and trading days per year.

Parameters
performance
tradingDaysPerYear
minimumAcceptableReturnMinimum acceptable return

Invokes the variance extension in the MathNet Statistics class

Returns
Annual variance value

Definition at line 128 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AnnualDownsideStandardDeviation()

static double QuantConnect.Statistics.Statistics.AnnualDownsideStandardDeviation ( List< double >  performance,
double  tradingDaysPerYear,
double  minimumAcceptableReturn = 0 
)
static

Annualized downside standard deviation

Parameters
performanceCollection of double values for daily performance
tradingDaysPerYearNumber of trading days for the assets in portfolio to get annualize standard deviation.
minimumAcceptableReturnMinimum acceptable return
Returns
Value for annual downside standard deviation

Definition at line 140 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrackingError()

static double QuantConnect.Statistics.Statistics.TrackingError ( List< double >  algoPerformance,
List< double >  benchmarkPerformance,
double  tradingDaysPerYear 
)
static

Tracking error volatility (TEV) statistic - a measure of how closely a portfolio follows the index to which it is benchmarked

If algo = benchmark, TEV = 0

Parameters
algoPerformanceDouble collection of algorithm daily performance values
benchmarkPerformanceDouble collection of benchmark daily performance values
tradingDaysPerYearNumber of trading days per year
Returns
Value for tracking error

Definition at line 153 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SharpeRatio() [1/3]

static double QuantConnect.Statistics.Statistics.SharpeRatio ( double  averagePerformance,
double  standardDeviation,
double  riskFreeRate 
)
static

Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk.

With risk defined as the algorithm's volatility

Parameters
averagePerformanceAverage daily performance
standardDeviationStandard deviation of the daily performance
riskFreeRateThe risk free rate
Returns
Value for sharpe ratio

Definition at line 178 of file Statistics.cs.

Here is the caller graph for this function:

◆ SharpeRatio() [2/3]

static decimal QuantConnect.Statistics.Statistics.SharpeRatio ( decimal  averagePerformance,
decimal  standardDeviation,
decimal  riskFreeRate 
)
static

Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk.

With risk defined as the algorithm's volatility

Parameters
averagePerformanceAverage daily performance
standardDeviationStandard deviation of the daily performance
riskFreeRateThe risk free rate
Returns
Value for sharpe ratio

Definition at line 191 of file Statistics.cs.

Here is the call graph for this function:

◆ SharpeRatio() [3/3]

static double QuantConnect.Statistics.Statistics.SharpeRatio ( List< double >  algoPerformance,
double  riskFreeRate,
double  tradingDaysPerYear 
)
static

Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk.

With risk defined as the algorithm's volatility

Parameters
algoPerformanceCollection of double values for the algorithm daily performance
riskFreeRateThe risk free rate
tradingDaysPerYearTrading days per year for the assets in portfolio
Returns
Value for sharpe ratio

Definition at line 204 of file Statistics.cs.

Here is the call graph for this function:

◆ SortinoRatio()

static double QuantConnect.Statistics.Statistics.SortinoRatio ( List< double >  algoPerformance,
double  riskFreeRate,
double  tradingDaysPerYear,
double  minimumAcceptableReturn = 0 
)
static

Sortino ratio with respect to risk free rate: measures excess of return per unit of downside risk.

With risk defined as the algorithm's volatility

Parameters
algoPerformanceCollection of double values for the algorithm daily performance
riskFreeRateThe risk free rate
tradingDaysPerYearTrading days per year for the assets in portfolio
minimumAcceptableReturnMinimum acceptable return for Sortino ratio calculation
Returns
Value for Sortino ratio

Definition at line 218 of file Statistics.cs.

Here is the call graph for this function:

◆ ProbabilisticSharpeRatio()

static double QuantConnect.Statistics.Statistics.ProbabilisticSharpeRatio ( List< double >  listPerformance,
double  benchmarkSharpeRatio 
)
static

Helper method to calculate the probabilistic sharpe ratio

Parameters
listPerformanceThe list of algorithm performance values
benchmarkSharpeRatioThe benchmark sharpe ratio to use
Returns
Probabilistic Sharpe Ratio

Definition at line 229 of file Statistics.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ObservedSharpeRatio()

static double QuantConnect.Statistics.Statistics.ObservedSharpeRatio ( List< double >  listPerformance)
static

Calculates the observed sharpe ratio

Parameters
listPerformanceThe performance samples to use
Returns
The observed sharpe ratio

Definition at line 258 of file Statistics.cs.

Here is the caller graph for this function:

◆ DrawdownPercent() [2/2]

static decimal QuantConnect.Statistics.Statistics.DrawdownPercent ( decimal  current,
decimal  high,
int  roundingDecimals = 2 
)
static

Calculate the drawdown between a high and current value

Parameters
currentCurrent value
highLatest maximum
roundingDecimalsDigits to round the result too
Returns
Drawdown percentage

Definition at line 273 of file Statistics.cs.


The documentation for this class was generated from the following file: