Exemple #1
0
        /// <summary>
        /// Calculate
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public virtual double CalculateCompoundRatio(int?option = 0)
        {
            var input  = Values.FirstOrDefault();
            var output = Values.LastOrDefault();

            if (input == null || output == null)
            {
                return(0.0);
            }

            var score = new CAGR
            {
                Values = Values
            };

            var excessGain = score.Calculate() - InterestRate;
            var days       = output.Time.Subtract(input.Time).Duration().Days + 1;
            var deviation  = Values.Select(o => o.Value).StandardDeviation() * Math.Sqrt(days);

            if (deviation == 0)
            {
                return(0.0);
            }

            return(excessGain / deviation);
        }