示例#1
0
        public double GetIndex(DateTime targetDate)
        {
            MA ma_10 = new MA(10);
            MA ma_long = new MA(50);

            DateTime pivot = GetNearestDate(targetDate);

            SetData(ma_10, pivot, 10);
            SetData(ma_long, pivot, 50);

            List<double> ma_10_diff = MathUtil.GetDiffData(ma_10.GetData());
            List<double> ma_long_diff = MathUtil.GetDiffData(ma_long.GetData());

            double vol_10 = MathUtil.GetYearVol(ma_10_diff);
            double vol_long = MathUtil.GetYearVol(ma_long_diff);

            double rawValue = vol_long / (vol_10 + 0.0000005);

            if (double.IsNaN(rawValue))
            {
                rawValue = 1.0;
                return rawValue;
            }

            return MathUtil.CapAndFloor(rawValue);
        }