19 using System.Collections.Generic;
20 using System.Globalization;
33 private double _tradingDaysPerYear;
64 _tradingDaysPerYear = Convert.ToDouble(tradingDaysPerYear, CultureInfo.InvariantCulture);
80 if (performance.ValueCount == 0)
85 var sixMonthsAgo = performance.LastKey().AddDays(-180);
86 var trailingPerformance = performance.Where(series => series.Key >= sixMonthsAgo && series.Key.DayOfWeek != DayOfWeek.Saturday && series.Key.DayOfWeek != DayOfWeek.Sunday)
90 var annualStandardDeviation = trailingPerformance.Count < 7 ? 0 :
GetAnnualStandardDeviation(trailingPerformance, _tradingDaysPerYear);
91 if (annualStandardDeviation <= 0)
96 var annualPerformance = Statistics.Statistics.AnnualPerformance(trailingPerformance, _tradingDaysPerYear);
97 var liveResultValue = Statistics.Statistics.SharpeRatio(annualPerformance, annualStandardDeviation, 0.0);
99 return liveResultValue.ToString(
"F2");
110 return Statistics.Statistics.AnnualStandardDeviation(trailingPerformance, tradingDaysPerYear);