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

void QuantLib::Bond::addRedemptionsToCashflows ( const std::vector< Real > &  redemptions = std::vector<Real>()) [protected, inherited]

This method can be called by derived classes in order to build redemption payments from the existing cash flows. It must be called after setting up the cashflows_ vector and will fill the notionalSchedule_, notionals_, and redemptions_ data members.

If given, the elements of the redemptions vector will multiply the amount of the redemption cash flow. The elements will be taken in base 100, i.e., a redemption equal to 100 does not modify the amount.

The cashflows_ vector must contain at least one coupon and must be sorted by date.

Definition at line 296 of file bond.cpp.

References QuantLib::Bond::calculateNotionalsFromCashflows().

Referenced by QuantLib::AmortizingFixedRateBond::AmortizingFixedRateBond(), QuantLib::Bond::Bond(), and QuantLib::FixedRateBond::FixedRateBond().

        // First, we gather the notional information from the cashflows
        // Then, we create the redemptions based on the notional
        // information and we add them to the cashflows vector after
        // the coupons.
        for (Size i=1; i<notionalSchedule_.size(); ++i) {
            Real R = i < redemptions.size() ? redemptions[i] :
                     !redemptions.empty()   ? redemptions.back() :
            Real amount = (R/100.0)*(notionals_[i-1]-notionals_[i]);
            boost::shared_ptr<CashFlow> payment;
            if (i < notionalSchedule_.size()-1)
                payment.reset(new AmortizingPayment(amount,
                payment.reset(new Redemption(amount, notionalSchedule_[i]));
        // stable_sort now moves the redemptions to the right places
        // while ensuring that they follow coupons with the same date.
        std::stable_sort(cashflows_.begin(), cashflows_.end(),
                         earlier_than<boost::shared_ptr<CashFlow> >());

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index