Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

Real QuantLib::Bond::accruedAmount ( Date  d = Date()  )  const [inherited]

accrued amount at a given date

The default bond settlement is used if no date is given.

Definition at line 199 of file bond.cpp.

Referenced by QuantLib::Bond::cleanPrice(), and QuantLib::Bond::yield().

                                                  {
        if (settlement == Date())
            settlement = settlementDate();

        for (Size i = 0; i<cashflows_.size(); ++i) {
            // the first coupon paying after d is the one we're after
            if (!cashflows_[i]->hasOccurred(settlement)) {
                boost::shared_ptr<Coupon> coupon =
                    boost::dynamic_pointer_cast<Coupon>(cashflows_[i]);
                if (coupon)
                    return coupon->accruedAmount(settlement);
                else
                    return 0.0;
            }
        }
        return 0.0;
    }


Generated by  Doxygen 1.6.0   Back to index