Exemplo n.º 1
0
        public double GetSpotRate(double t)
        {
            if (Trait == YieldCurveTrait.SpotCurve)
            {
                return(_curveXInYears.GetValue(t) + Spread.GetValue(t));
            }

            var df = GetDf(t);

            return(Compound.CalcRateFromDf(df, t));
        }
Exemplo n.º 2
0
        public double GetForwardRate(double t0, double dt, Compound compound = Compound.Simple, IDayCount dayCount = null)
        {
            if (dt <= 0.0)
            {
                return(_curveXInYears.GetValue(t0) + Spread.GetValue(t0));
            }

            if (t0.IsAlmostZero() && dt.IsAlmostZero())
            {
                return(GetForwardRate(0, 0.0001, compound, dayCount));
            }
            var df = GetDf(t0 + dt) / GetDf(t0);

            return(compound.CalcRateFromDf(df, dt));
        }
Exemplo n.º 3
0
        public double ZeroRate(Date startDate, Date endDate, Compound compound = Compound.Continuous)
        {
            var df = GetDf(startDate, endDate);

            return(compound.CalcRateFromDf(df, DayCount.CalcDayCountFraction(startDate, endDate)));
        }