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

public nominal ( ) : double
Результат double
        protected void calculateNotionalsFromCashflows()
        {
            notionalSchedule_.Clear();
            notionals_.Clear();

            Date lastPaymentDate = new Date();

            //notionalSchedule_.Add((Coupon)(cashflows_[0])accrualStartDate());
            for (int i = 0; i < cashflows_.Count; ++i)
            {
                Coupon coupon = cashflows_[i] as Coupon;
                if (coupon == null)
                {
                    continue;
                }
                if (i == 0)
                {
                    notionalSchedule_.Add(coupon.accrualStartDate());
                }
                double notional = coupon.nominal();
                // we add the notional only if it is the first one...
                if (notionals_.empty())
                {
                    notionals_.Add(coupon.nominal());
                    lastPaymentDate = coupon.date();
                }
                else if (!Utils.close(notional, notionals_.Last()))
                {
                    // ...or if it has changed.
                    if (!(notional < notionals_.Last()))
                    {
                        throw new ApplicationException("increasing coupon notionals");
                    }
                    notionals_.Add(coupon.nominal());
                    // in this case, we also add the last valid date for
                    // the previous one...
                    notionalSchedule_.Add(lastPaymentDate);
                    // ...and store the candidate for this one.
                    lastPaymentDate = coupon.date();
                }
                else
                {
                    // otherwise, we just extend the valid range of dates
                    // for the current notional.
                    lastPaymentDate = coupon.date();
                }
            }
            if (notionals_.empty())
            {
                throw new ApplicationException("no coupons provided");
            }
            notionals_.Add(0.0);
            notionalSchedule_.Add(lastPaymentDate);
        }
Пример #2
0
        //! NPV and BPS of the cash flows.
        // The NPV and BPS of the cash flows calculated together for performance reason
        public static void npvbps(Leg leg, YieldTermStructure discountCurve, bool includeSettlementDateFlows,
                                  Date settlementDate, Date npvDate, out double npv, out double bps)
        {
            npv = bps = 0.0;
            if (leg.empty())
            {
                bps = 0.0;
                return;
            }

            for (int i = 0; i < leg.Count; ++i)
            {
                CashFlow cf = leg[i];
                if (!cf.hasOccurred(settlementDate, includeSettlementDateFlows) &&
                    !cf.tradingExCoupon(settlementDate))
                {
                    Coupon cp = leg[i] as Coupon;
                    double df = discountCurve.discount(cf.date());
                    npv += cf.amount() * df;
                    if (cp != null)
                    {
                        bps += cp.nominal() * cp.accrualPeriod() * df;
                    }
                }
            }
            double d = discountCurve.discount(npvDate);

            npv /= d;
            bps  = Const.BASIS_POINT * bps / d;
        }
Пример #3
0
            public void visit(Coupon c)
            {
                double bps = c.nominal() *
                             c.accrualPeriod() *
                             discountCurve_.discount(c.date());

                bps_ += bps;
            }
        private static double couponRate(List <CashFlow> leg, CashFlow cf)
        {
            if (cf == null)
            {
                return(0.0);
            }

            Date       paymentDate      = cf.date();
            bool       firstCouponFound = false;
            double     nominal          = 0;
            double     accrualPeriod    = 0;
            DayCounter dc     = null;
            double     result = 0.0;

            foreach (CashFlow x in leg.Where(x => x.date() == paymentDate))
            {
                Coupon cp = x as Coupon;
                if (cp != null)
                {
                    if (firstCouponFound)
                    {
                        if (!(nominal == cp.nominal() && accrualPeriod == cp.accrualPeriod() && dc == cp.dayCounter()))
                        {
                            throw new ApplicationException("cannot aggregate two different coupons on " + paymentDate);
                        }
                    }
                    else
                    {
                        firstCouponFound = true;
                        nominal          = cp.nominal();
                        accrualPeriod    = cp.accrualPeriod();
                        dc = cp.dayCounter();
                    }
                    result += cp.rate();
                }
            }

            if (!firstCouponFound)
            {
                throw new ApplicationException("next cashflow (" + paymentDate + ") is not a coupon");
            }
            return(result);
        }
        public double accruedAmount(Date settlement)
        {
            if (settlement == null)
            {
                settlement = settlementDate();
            }

            CashFlow cf = CashFlows.nextCashFlow(cashflows_, false, settlement);

            if (cf == cashflows_.Last())
            {
                return(0.0);
            }

            Date       paymentDate      = cf.date();
            bool       firstCouponFound = false;
            double     nominal          = 0;
            double     accrualPeriod    = 0;
            DayCounter dc     = null;
            double     result = 0.0;

            foreach (CashFlow x in cashflows_.FindAll(x => x.date() == paymentDate && x.GetType().IsSubclassOf(typeof(Coupon))))
            {
                Coupon cp = (Coupon)x;
                if (firstCouponFound)
                {
                    if (!(nominal == cp.nominal() && accrualPeriod == cp.accrualPeriod() && dc == cp.dayCounter()))
                    {
                        throw new ApplicationException("cannot aggregate accrued amount of two different coupons on " + paymentDate);
                    }
                }
                else
                {
                    firstCouponFound = true;
                    nominal          = cp.nominal();
                    accrualPeriod    = cp.accrualPeriod();
                    dc = cp.dayCounter();
                }
                result += cp.accruedAmount(settlement);
            }
            return(result / notional(settlement) * 100.0);
        }
Пример #6
0
        private static double aggregateRate(Leg leg, CashFlow cf)
        {
            if (cf == null)
            {
                return(0.0);
            }

            Date       paymentDate      = cf.date();
            bool       firstCouponFound = false;
            double     nominal          = 0.0;
            double     accrualPeriod    = 0.0;
            DayCounter dc     = null;
            double     result = 0.0;

            foreach (CashFlow x in leg.Where(x => x.date() == paymentDate))
            {
                Coupon cp = x as Coupon;
                if (cp != null)
                {
                    if (firstCouponFound)
                    {
                        Utils.QL_REQUIRE(nominal.IsEqual(cp.nominal()) &&
                                         accrualPeriod.IsEqual(cp.accrualPeriod()) &&
                                         dc == cp.dayCounter(), () =>
                                         "cannot aggregate two different coupons on "
                                         + paymentDate);
                    }
                    else
                    {
                        firstCouponFound = true;
                        nominal          = cp.nominal();
                        accrualPeriod    = cp.accrualPeriod();
                        dc = cp.dayCounter();
                    }
                    result += cp.rate();
                }
            }

            Utils.QL_REQUIRE(firstCouponFound, () => "no coupon paid at cashflow date " + paymentDate);
            return(result);
        }
Пример #7
0
        public static double nominal(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null)
        {
            CashFlow cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate);

            if (cf == null)
            {
                return(0.0);
            }

            Date paymentDate = cf.date();

            foreach (CashFlow x in leg.Where(x => x.date() == paymentDate))
            {
                Coupon cp = x as Coupon;
                if (cp != null)
                {
                    return(cp.nominal());
                }
            }
            return(0.0);
        }
Пример #8
0
 public void visit(Coupon c) 
 {
    double bps = c.nominal() *
                   c.accrualPeriod() *
                   discountCurve_.discount(c.date());
    bps_ += bps;
 }
 public void visit(Coupon c)
 {
     result_ += c.accrualPeriod() * c.nominal() * termStructure_.discount(c.date());
 }
 public void visit(Coupon c) {
     result_ += c.accrualPeriod() * c.nominal() * termStructure_.discount(c.date());
 }