Пример #1
0
        private void AddParRateForTaibor(DateTime startDate, ParRateElf parRateInfo)
        {
            (DateTime endDate, double days, double daysAct) = GetEndDate(startDate, parRateInfo);
            double zero = 0; //# 零息利率

            #region 取零息利率
            zero = RateAx.零息利率_T_R(parRateInfo.Rate, daysAct);
            #endregion 取零息利率
            this.ParRateList.Add(new ParRateElfEx(parRateInfo, this.TradeDate, endDate, days, daysAct, zero));
        }
Пример #2
0
        public (double, double, double, double, double) GetYield_T(double t)
        {
            //# 零息利率, 遠期利率, 折現因子, 驗證零息利率, Swap
            var interpolate = MathNet.Numerics.Interpolate.Linear(this.ParRateList.Select(p => p.DaysAct), this.ParRateList.Select(p => p.Zero));
            //# 從此天+90為遠期利率
            double t2    = t + 90 / 365d;
            double zero2 = interpolate.Interpolate(t2);
            double zero  = interpolate.Interpolate(t);

            double FR      = RateAx.遠期利率e(zero, t, zero2, t2); //# 算上一期到加90天的利率
            double DF      = RateAx.折現因子_T_Z(zero, t);
            double newZero = RateAx.零息利率_T_折現因子(DF, t);

            var    interpolate2 = MathNet.Numerics.Interpolate.Linear(this.ParRateList.Select(p => p.DaysAct), this.ParRateList.Select(p => p.Rate));
            double rate         = interpolate2.Interpolate(t);

            return(zero, FR, DF, newZero, rate);
        }
Пример #3
0
        private void AddParRateForInterbank(DateTime startDate, ParRateElf parRateInfo)
        {
            //# 一定是ON或TN, 央行沒有報TN, 所以會用ON的利率帶進來
            (DateTime endDate, double days, double daysAct) = GetEndDate(startDate, parRateInfo);
            double zero = 0; //# 零息利率

            #region 取零息利率
            if (parRateInfo.Unit == EnumTenorUnit.Day && parRateInfo.Tenor == 2) //# TN
            {
                ParRateElfEx ON = ParRateList.SingleOrDefault(p => p.Tenor == 1 && p.Unit == EnumTenorUnit.Day);
                if (ON == null)
                {
                    throw new Exception("沒有O/N無法計算T/N的零息利率");
                }
                double s = days - ON.Days;
                zero = RateAx.TN零息利率(ON.DF, parRateInfo.Rate, days, s);
            }
            else
            {
                zero = RateAx.零息利率_T_R(parRateInfo.Rate, daysAct);
            }
            #endregion 取零息利率
            this.ParRateList.Add(new ParRateElfEx(parRateInfo, this.TradeDate, endDate, days, daysAct, zero));
        }