/// <summary> /// Gets the beta of a performance time line compared to another. /// </summary> /// <param name="performanceValues">The performance values.</param> /// <param name="comparePerformanceValues">The relation performance values.</param> /// <returns></returns> public double?GetBeta(IEnumerable <double> performanceValues, IEnumerable <double> comparePerformanceValues) { var varianceOfComparePerformance = StatisticFunctions.GetVariance(comparePerformanceValues); if (varianceOfComparePerformance == 0) { return(null); } var covariance = StatisticFunctions.GetCoVariance(performanceValues, comparePerformanceValues); return(covariance / varianceOfComparePerformance); }
/// <summary> /// Gets the risk per annum of a performance time line. /// </summary> /// <param name="performanceValues">The performance values.</param> /// <param name="valuesPerYear">The values per year.</param> /// <returns></returns> public static double?GetRiskPerAnnum(IEnumerable <double> performanceValues, double valuesPerYear) { if (performanceValues == null) { return(null); } if (performanceValues.Count() < Constants.MIN_PERFORMANCE_VALUES) { return(null); } if (valuesPerYear < 0) { return(null); } var standardDeviation = StatisticFunctions.GetStandardDeviation(performanceValues); var squareRootOfValuesPerYear = Math.Sqrt(valuesPerYear); return(standardDeviation * squareRootOfValuesPerYear); }
/// <summary> /// Gets the tracking error of a performance time line compared to another. /// </summary> /// <param name="performanceValues">The performance values.</param> /// <param name="comparePerformanceValues">The compare performance values.</param> /// <param name="valuesPerYear">The values per year.</param> /// <returns></returns> public static double?GetTrackingError(IEnumerable <double> performanceValues, IEnumerable <double> comparePerformanceValues, double valuesPerYear) { if (performanceValues == null || comparePerformanceValues == null || valuesPerYear < 0 || !performanceValues.Any() || !comparePerformanceValues.Any()) { return(null); } var diffValues = new List <double>(); var count = Math.Min(performanceValues.Count(), comparePerformanceValues.Count()); for (var i = 0; i < count; i++) { diffValues.Add(performanceValues.ElementAt(i) - comparePerformanceValues.ElementAt(i)); } var diffStandardDeviation = StatisticFunctions.GetStandardDeviation(diffValues); return(diffStandardDeviation * Math.Sqrt(valuesPerYear)); }
/// <summary> /// Gets the correlation between two performance time lines. /// </summary> /// <param name="performanceValues">The performance values.</param> /// <param name="comparePerformanceValues">The performance values to compare to.</param> /// <returns></returns> public static double?GetCorrelation(IEnumerable <double> performanceValues, IEnumerable <double> comparePerformanceValues) { return(StatisticFunctions.GetCorrelation(performanceValues, comparePerformanceValues)); }