QLNet.FixedRateCoupon.accruedAmount C# (CSharp) Метод

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

public accruedAmount ( Date d ) : double
d Date
Результат double
        public override double accruedAmount(Date d)
        {
            if (d <= accrualStartDate_ || d > paymentDate_)
                return 0;
            else
                return nominal() * (rate_.compoundFactor(accrualStartDate_, Date.Min(d, accrualEndDate_),
                                                         refPeriodStart_, refPeriodEnd_) - 1.0);
        }

Usage Example

Пример #1
0
        /// <summary>
        /// CDS quoted as running-spread only
        /// </summary>
        /// <param name="side">Whether the protection is bought or sold.</param>
        /// <param name="notional">Notional value</param>
        /// <param name="spread">Running spread in fractional units.</param>
        /// <param name="schedule">Coupon schedule.</param>
        /// <param name="convention">Business-day convention for payment-date adjustment.</param>
        /// <param name="dayCounter">Day-count convention for accrual.</param>
        /// <param name="settlesAccrual">Whether or not the accrued coupon is due in the event of a default.</param>
        /// <param name="paysAtDefaultTime">If set to true, any payments triggered by a default event are
        /// due at default time. If set to false, they are due at the end of the accrual period.</param>
        /// <param name="protectionStart">The first date where a default event will trigger the contract.</param>
        /// <param name="claim"></param>
        /// <param name="lastPeriodDayCounter">Day-count convention for accrual in last period</param>
        /// <param name="rebatesAccrual">The protection seller pays the accrued scheduled current coupon at the start
        /// of the contract. The rebate date is not provided but computed to be two days after protection start.</param>
        public CreditDefaultSwap(Protection.Side side,
                                 double notional,
                                 double spread,
                                 Schedule schedule,
                                 BusinessDayConvention convention,
                                 DayCounter dayCounter,
                                 bool settlesAccrual             = true,
                                 bool paysAtDefaultTime          = true,
                                 Date protectionStart            = null,
                                 Claim claim                     = null,
                                 DayCounter lastPeriodDayCounter = null,
                                 bool rebatesAccrual             = true)
        {
            side_              = side;
            notional_          = notional;
            upfront_           = null;
            runningSpread_     = spread;
            settlesAccrual_    = settlesAccrual;
            paysAtDefaultTime_ = paysAtDefaultTime;
            claim_             = claim;
            protectionStart_   = protectionStart ?? schedule[0];

            Utils.QL_REQUIRE(protectionStart_ <= schedule[0] ||
                             schedule.rule() == DateGeneration.Rule.CDS ||
                             schedule.rule() == DateGeneration.Rule.CDS2015
                             , () => "protection can not start after accrual");

            leg_ = new FixedRateLeg(schedule)
                   .withLastPeriodDayCounter(lastPeriodDayCounter)
                   .withCouponRates(spread, dayCounter)
                   .withNotionals(notional)
                   .withPaymentAdjustment(convention);

            Date effectiveUpfrontDate = schedule.calendar().advance(protectionStart_, 2, TimeUnit.Days, convention);

            // '2' is used above since the protection start is assumed to be on trade_date + 1
            if (rebatesAccrual)
            {
                FixedRateCoupon firstCoupon = leg_[0] as FixedRateCoupon;

                Date rebateDate = effectiveUpfrontDate;
                accrualRebate_ = new SimpleCashFlow(firstCoupon.accruedAmount(protectionStart_), rebateDate);
            }

            upfrontPayment_ = new SimpleCashFlow(0.0, effectiveUpfrontDate);

            if (claim_ == null)
            {
                claim_ = new FaceValueClaim();
            }

            claim_.registerWith(update);
            maturity_ = schedule.dates().Last();
        }
All Usage Examples Of QLNet.FixedRateCoupon::accruedAmount