Lean
$LEAN_TAG$
|
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... | |
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.
|
static |
Drawdown maximum percentage.
equityOverTime | |
rounding |
Definition at line 39 of file Statistics.cs.
|
static |
Annual compounded returns statistic based on the final-starting capital and years.
startingCapital | Algorithm starting capital |
finalCapital | Algorithm final capital |
years | Years trading |
Definition at line 68 of file Statistics.cs.
|
static |
Annualized return statistic calculated as an average of daily trading performance multiplied by the number of trading days per year.
performance | Dictionary collection of double performance values |
tradingDaysPerYear | Trading days per year for the assets in portfolio |
May be unaccurate for forex algorithms with more trading days in a year
Definition at line 87 of file Statistics.cs.
|
static |
Annualized variance statistic calculation using the daily performance variance and trading days per year.
performance | |
tradingDaysPerYear |
Invokes the variance extension in the MathNet Statistics class
Definition at line 99 of file Statistics.cs.
|
static |
Annualized standard deviation
performance | Collection of double values for daily performance |
tradingDaysPerYear | Number 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.
Definition at line 115 of file Statistics.cs.
|
static |
Annualized variance statistic calculation using the daily performance variance and trading days per year.
performance | |
tradingDaysPerYear | |
minimumAcceptableReturn | Minimum acceptable return |
Invokes the variance extension in the MathNet Statistics class
Definition at line 128 of file Statistics.cs.
|
static |
Annualized downside standard deviation
performance | Collection of double values for daily performance |
tradingDaysPerYear | Number of trading days for the assets in portfolio to get annualize standard deviation. |
minimumAcceptableReturn | Minimum acceptable return |
Definition at line 140 of file Statistics.cs.
|
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
algoPerformance | Double collection of algorithm daily performance values |
benchmarkPerformance | Double collection of benchmark daily performance values |
tradingDaysPerYear | Number of trading days per year |
Definition at line 153 of file Statistics.cs.
|
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
averagePerformance | Average daily performance |
standardDeviation | Standard deviation of the daily performance |
riskFreeRate | The risk free rate |
Definition at line 178 of file Statistics.cs.
|
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
averagePerformance | Average daily performance |
standardDeviation | Standard deviation of the daily performance |
riskFreeRate | The risk free rate |
Definition at line 191 of file Statistics.cs.
|
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
algoPerformance | Collection of double values for the algorithm daily performance |
riskFreeRate | The risk free rate |
tradingDaysPerYear | Trading days per year for the assets in portfolio |
Definition at line 204 of file Statistics.cs.
|
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
algoPerformance | Collection of double values for the algorithm daily performance |
riskFreeRate | The risk free rate |
tradingDaysPerYear | Trading days per year for the assets in portfolio |
minimumAcceptableReturn | Minimum acceptable return for Sortino ratio calculation |
Definition at line 218 of file Statistics.cs.
|
static |
Helper method to calculate the probabilistic sharpe ratio
listPerformance | The list of algorithm performance values |
benchmarkSharpeRatio | The benchmark sharpe ratio to use |
Definition at line 229 of file Statistics.cs.
|
static |
Calculates the observed sharpe ratio
listPerformance | The performance samples to use |
Definition at line 258 of file Statistics.cs.
|
static |
Calculate the drawdown between a high and current value
current | Current value |
high | Latest maximum |
roundingDecimals | Digits to round the result too |
Definition at line 273 of file Statistics.cs.