QLNet.InterestRate.discountFactor C# (CSharp) Метод

discountFactor() публичный Метод

public discountFactor ( Date d1, Date d2 ) : double
d1 Date
d2 Date
Результат double
        public double discountFactor(Date d1, Date d2)
        {
            return discountFactor(d1, d2, null, null);
        }

Same methods

InterestRate::discountFactor ( Date d1, Date d2, Date refStart ) : double
InterestRate::discountFactor ( Date d1, Date d2, Date refStart, Date refEnd ) : double
InterestRate::discountFactor ( double t ) : double

Usage Example

        public static double simpleDuration(List <CashFlow> cashflows, InterestRate y, Date settlementDate)
        {
            if (cashflows.Count == 0)
            {
                return(0.0);
            }

            double     P = 0, dPdy = 0;
            DayCounter dc = y.dayCounter();

            foreach (CashFlow cf in cashflows.Where(cf => !cf.hasOccurred(settlementDate)))
            {
                double t = dc.yearFraction(settlementDate, cf.date());
                double c = cf.amount();
                double B = y.discountFactor(t);
                P    += c * B;
                dPdy += t * c * B;
            }


            // no cashflows
            if (P == 0.0)
            {
                return(0.0);
            }
            return(dPdy / P);
        }
All Usage Examples Of QLNet.InterestRate::discountFactor