impliedRate() публичный статический Метод

public static impliedRate ( double compound, Date d1, Date d2, DayCounter resultDC, Compounding comp ) : InterestRate
compound double
d1 Date
d2 Date
resultDC DayCounter
comp Compounding
Результат InterestRate
Пример #1
0
        /*! Simple yield calculation based on underlying spot and
         * forward values, taking into account underlying income.
         * When \f$ t>0 \f$, call with:
         * underlyingSpotValue=spotValue(t),
         * forwardValue=strikePrice, to get current yield. For a
         * repo, if \f$ t=0 \f$, impliedYield should reproduce the
         * spot repo rate. For FRA's, this should reproduce the
         * relevant zero rate at the FRA's maturityDate_;
         */
        public InterestRate impliedYield(double underlyingSpotValue, double forwardValue, Date settlementDate,
                                         Compounding compoundingConvention, DayCounter dayCounter)
        {
            double tenor             = dayCounter.yearFraction(settlementDate, maturityDate_);
            double compoundingFactor = forwardValue / (underlyingSpotValue - spotIncome(incomeDiscountCurve_));

            return(InterestRate.impliedRate(compoundingFactor, dayCounter, compoundingConvention, Frequency.Annual, tenor));
        }
Пример #2
0
        /*! The resulting interest rate has the same day-counting rule
         *  used by the term structure. The same rule should be used
         *  for calculating the passed time t.
         */
        public InterestRate zeroRate(double t, Compounding comp, Frequency freq = Frequency.Annual, bool extrapolate = false)
        {
            if (t.IsEqual(0.0))
            {
                t = dt;
            }
            double compound = 1.0 / discount(t, extrapolate);

            return(InterestRate.impliedRate(compound, dayCounter(), comp, freq, t));
        }
Пример #3
0
        public InterestRate zeroRate(double t, Compounding comp, Frequency freq, bool extrapolate)
        {
            if (t == 0)
            {
                t = 0.0001;
            }
            double compound = 1 / discount(t, extrapolate);

            return(InterestRate.impliedRate(compound, t, dayCounter(), comp, freq));
        }
Пример #4
0
        //    These methods return the implied zero-yield rate for a
        //    given date or time.  In the former case, the time is
        //    calculated as a fraction of year from the reference date.

        /*! The resulting interest rate has the required daycounting
         *  rule.
         */
        public InterestRate zeroRate(Date d, DayCounter dayCounter, Compounding comp, Frequency freq = Frequency.Annual,
                                     bool extrapolate = false)
        {
            if (d == referenceDate())
            {
                double compound = 1.0 / discount(dt, extrapolate);
                // t has been calculated with a possibly different daycounter
                // but the difference should not matter for very small times
                return(InterestRate.impliedRate(compound, dayCounter, comp, freq, dt));
            }
            double compound1 = 1.0 / discount(d, extrapolate);

            return(InterestRate.impliedRate(compound1, dayCounter, comp, freq, referenceDate(), d));
        }
Пример #5
0
 public InterestRate zeroRate(Date d, DayCounter dayCounter, Compounding comp, Frequency freq, bool extrapolate)
 {
     if (d == referenceDate())
     {
         double t        = 0.0001;
         double compound = 1 / discount(t, extrapolate);
         return(InterestRate.impliedRate(compound, t, dayCounter, comp, freq));
     }
     else
     {
         double compound = 1 / discount(d, extrapolate);
         return(InterestRate.impliedRate(compound, referenceDate(), d, dayCounter, comp, freq));
     }
 }
Пример #6
0
        public InterestRate forwardRate(double t1, double t2, Compounding comp, Frequency freq, bool extrapolate)
        {
            if (t2 == t1)
            {
                t2 = t1 + 0.0001;
            }
            if (!(t2 > t1))
            {
                throw new ArgumentException("t2 (" + t2 + ") < t1 (" + t2 + ")");
            }
            double compound = discount(t1, extrapolate) / discount(t2, extrapolate);

            return(InterestRate.impliedRate(compound, t2 - t1, dayCounter(), comp, freq));
        }
Пример #7
0
        //    These methods returns the forward interest rate between two dates
        //    or times.  In the former case, times are calculated as fractions
        //    of year from the reference date.
        //
        //    If both dates (times) are equal the instantaneous forward rate is
        //    returned.

        /*! The resulting interest rate has the required day-counting
         *  rule.
         */
        public InterestRate forwardRate(Date d1, Date d2, DayCounter dayCounter, Compounding comp,
                                        Frequency freq = Frequency.Annual, bool extrapolate = false)
        {
            if (d1 == d2)
            {
                checkRange(d1, extrapolate);
                double t1       = Math.Max(timeFromReference(d1) - dt / 2.0, 0.0);
                double t2       = t1 + dt;
                double compound = discount(t1, true) / discount(t2, true);
                // times have been calculated with a possibly different daycounter
                // but the difference should not matter for very small times
                return(InterestRate.impliedRate(compound, dayCounter, comp, freq, dt));
            }
            Utils.QL_REQUIRE(d1 < d2, () => d1 + " later than " + d2);
            double compound1 = discount(d1, extrapolate) / discount(d2, extrapolate);

            return(InterestRate.impliedRate(compound1, dayCounter, comp, freq, d1, d2));
        }
Пример #8
0
        /*! The resulting interest rate has the same day-counting rule
         *  used by the term structure. The same rule should be used
         *  for calculating the passed times t1 and t2.
         */
        public InterestRate forwardRate(double t1, double t2, Compounding comp, Frequency freq = Frequency.Annual,
                                        bool extrapolate = false)
        {
            double compound;

            if (t2.IsEqual(t1))
            {
                checkRange(t1, extrapolate);
                t1       = Math.Max(t1 - dt / 2.0, 0.0);
                t2       = t1 + dt;
                compound = discount(t1, true) / discount(t2, true);
            }
            else
            {
                Utils.QL_REQUIRE(t2 > t1, () => "t2 (" + t2 + ") < t1 (" + t2 + ")");
                compound = discount(t1, extrapolate) / discount(t2, extrapolate);
            }
            return(InterestRate.impliedRate(compound, dayCounter(), comp, freq, t2 - t1));
        }
Пример #9
0
 public InterestRate forwardRate(Date d1, Date d2, DayCounter resultDayCounter, Compounding comp, Frequency freq, bool extrapolate)
 {
     if (d1 == d2)
     {
         double t1       = timeFromReference(d1);
         double t2       = t1 + 0.0001;
         double compound = discount(t1, extrapolate) / discount(t2, extrapolate);
         return(InterestRate.impliedRate(compound, t2 - t1, resultDayCounter, comp, freq));
     }
     else
     {
         if (!(d1 < d2))
         {
             throw new ArgumentException(d1 + " later than " + d2);
         }
         double compound = discount(d1, extrapolate) / discount(d2, extrapolate);
         return(InterestRate.impliedRate(compound, d1, d2, resultDayCounter, comp, freq));
     }
 }