public static double CalcProb(IEnumerable<double> movements_, ProbabilityCalcType type_) { if (movements_ == null) return 0d; int countUps = 0; int countDowns = 0; int total = 0; foreach (var val in movements_) { total += 1; if (val > 0d) countUps += 1; if (val < 0d) countDowns += 1; } if (total == 0) return 0d; switch (type_) { case ProbabilityCalcType.UpsOverNumberMinusPt5: return (Convert.ToDouble(countUps)/Convert.ToDouble(total)) - 0.5d; case ProbabilityCalcType.UpsMinusDownsOverNumber: return Convert.ToDouble(countUps-countDowns) / Convert.ToDouble(total); default: throw new Exception(string.Format("Method '{0}' not implemented", type_)); } }
public static double GetMaxValue(ProbabilityCalcType type_) { switch (type_) { case ProbabilityCalcType.UpsOverNumberMinusPt5: return 0.5d; case ProbabilityCalcType.UpsMinusDownsOverNumber: return 1d; default: throw new Exception(); } }
public static string Explain(ProbabilityCalcType type_) { return null; }