# QuantLib_CashFlows man page

CashFlows — cashflow-analysis functions

## Synopsis

`#include <ql/cashflows/cashflows.hpp>`

### Static Public Member Functions

**Date functions**

staticDate startDate(constLeg&leg)

staticDate maturityDate(constLeg&leg)

static boolisExpired(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

**CashFlow functions**

static Leg::const_reverse_iteratorpreviousCashFlow(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

the last cashflow paying before or at the given date

static Leg::const_iteratornextCashFlow(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

the first cashflow paying after the given date

staticDate previousCashFlowDate(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticDate nextCashFlowDate(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticReal previousCashFlowAmount(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticReal nextCashFlowAmount(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

**Coupon inspectors**

staticRate previousCouponRate(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticRate nextCouponRate(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticReal nominal(constLeg&leg, bool includeSettlementDateFlows,DatesettlDate=Date())

staticDate accrualStartDate(constLeg&leg, bool includeSettlementDateFlows,DatesettlDate=Date())

staticDate accrualEndDate(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticDate referencePeriodStart(constLeg&leg, bool includeSettlementDateFlows,DatesettlDate=Date())

staticDate referencePeriodEnd(constLeg&leg, bool includeSettlementDateFlows,DatesettlDate=Date())

staticTime accrualPeriod(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticBigInteger accrualDays(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticTime accruedPeriod(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticBigInteger accruedDays(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

staticReal accruedAmount(constLeg&leg, bool includeSettlementDateFlows,DatesettlementDate=Date())

**YieldTermStructure functions**

staticReal npv(constLeg&leg, constYieldTermStructure&discountCurve, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

NPV of the cash flows.

staticReal bps(constLeg&leg, constYieldTermStructure&discountCurve, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Basis-point sensitivity of the cash flows.

static voidnpvbps(constLeg&leg, constYieldTermStructure&discountCurve, bool includeSettlementDateFlows,DatesettlementDate,DatenpvDate,Real&npv,Real&bps)

NPV and BPS of the cash flows.

staticRate atmRate(constLeg&leg, constYieldTermStructure&discountCurve, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date(),Real npv=Null<Real>())

At-the-money rate of the cash flows.

**Yield (a.k.a. Internal Rate of Return, i.e. IRR) functions**

staticReal npv(constLeg&leg, constInterestRate&yield, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

NPV of the cash flows.

staticReal npv(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

staticReal bps(constLeg&leg, constInterestRate&yield, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Basis-point sensitivity of the cash flows.

staticReal bps(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

staticRate yield(constLeg&leg,Real npv, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date(),Realaccuracy=1.0e-10, Size maxIterations=100, Rate guess=0.05)

Implied internal rate of return.

staticTime duration(constLeg&leg, constInterestRate&yield, Duration::Type type, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Cash-flow duration.

staticTime duration(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, Duration::Type type, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

staticReal convexity(constLeg&leg, constInterestRate&yield, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Cash-flow convexity.

staticReal convexity(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

staticReal basisPointValue(constLeg&leg, constInterestRate&yield, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Basis-point value.

staticReal basisPointValue(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

staticReal yieldValueBasisPoint(constLeg&leg, constInterestRate&yield, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

Yield value of a basis point.

staticReal yieldValueBasisPoint(constLeg&leg,Rate yield, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

**Z-spread functions**

staticReal npv(constLeg&leg, const boost::shared_ptr<YieldTermStructure> &discount,Spread zSpread, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date())

NPV of the cash flows.

staticSpread zSpread(constLeg&leg,Real npv, const boost::shared_ptr<YieldTermStructure> &, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date(),Realaccuracy=1.0e-10, Size maxIterations=100, Rate guess=0.0)

implied Z-spread.

staticSpread zSpread(constLeg&leg, const boost::shared_ptr<YieldTermStructure> &d,Real npv, constDayCounter&dayCounter,Compoundingcompounding,Frequencyfrequency, bool includeSettlementDateFlows,DatesettlementDate=Date(),DatenpvDate=Date(),Realaccuracy=1.0e-10, Size maxIterations=100, Rate guess=0.0)

deprecated implied Z-spread.

## Detailed Description

cashflow-analysis functions

## Member Function Documentation

### static Real npv (const Leg & leg, const YieldTermStructure & discountCurve, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

NPV of the cash flows. The NPV is the sum of the cash flows, each discounted according to the given term structure.

### static Real bps (const Leg & leg, const YieldTermStructure & discountCurve, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Basis-point sensitivity of the cash flows. The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given term structure.

### static void npvbps (const Leg & leg, const YieldTermStructure & discountCurve, bool includeSettlementDateFlows, Date settlementDate, Date npvDate, Real & npv, Real & bps) [static]

NPV and BPS of the cash flows. The NPV and BPS of the cash flows calculated together for performance reason

### static Rate atmRate (const Leg & leg, const YieldTermStructure & discountCurve, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date(), Real npv = Null< Real >()) [static]

At-the-money rate of the cash flows. The result is the fixed rate for which a fixed rate cash flow vector, equivalent to the input vector, has the required NPV according to the given term structure. If the required NPV is not given, the input cash flow vector's NPV is used instead.

### static Real npv (const Leg & leg, const InterestRate & yield, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

NPV of the cash flows. The IRR is the interest rate at which the NPV of the cash flows equals the dirty price.

The NPV is the sum of the cash flows, each discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter.

### static Real bps (const Leg & leg, const InterestRate & yield, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Basis-point sensitivity of the cash flows. The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter.

### static Rate yield (const Leg & leg, Real npv, const DayCounter & dayCounter, Compounding compounding, Frequency frequency, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date(), Real accuracy = 1.0e-10, Size maxIterations = 100, Rate guess = 0.05) [static]

Implied internal rate of return. The function verifies the theoretical existance of an IRR and numerically establishes the IRR to the desired precision.

### static Time duration (const Leg & leg, const InterestRate & yield, Duration::Type type, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Cash-flow duration. The simple duration of a string of cash flows is defined as [ D_{mathrm{simple}} = ac{sum t_i c_i B(t_i)}{sum c_i B(t_i)} ] where $ c_i $ is the amount of the $ i $-th cash flow, $ t_i $ is its payment time, and $ B(t_i) $ is the corresponding discount according to the passed yield.

The modified duration is defined as [ D_{mathrm{modified}} = -ac{1}{P} ac{partial P}{partial y} ] where $ P $ is the present value of the cash flows according to the given IRR $ y $.

The Macaulay duration is defined for a compounded IRR as [ D_{mathrm{Macaulay}} = left( 1 + ac{y}{N} right) D_{mathrm{modified}} ] where $ y $ is the IRR and $ N $ is the number of cash flows per year.

### static Real convexity (const Leg & leg, const InterestRate & yield, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Cash-flow convexity. The convexity of a string of cash flows is defined as [ C = ac{1}{P} ac{partial^2 P}{partial y^2} ] where $ P $ is the present value of the cash flows according to the given IRR $ y $.

### static Real basisPointValue (const Leg & leg, const InterestRate & yield, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Basis-point value. Obtained by setting dy = 0.0001 in the 2nd-order Taylor series expansion.

### static Real yieldValueBasisPoint (const Leg & leg, const InterestRate & yield, bool includeSettlementDateFlows, Date settlementDate = Date(), Date npvDate = Date()) [static]

Yield value of a basis point. The yield value of a one basis point change in price is the derivative of the yield with respect to the price multiplied by 0.01

## Author

Generated automatically by Doxygen for QuantLib from the source code.

## Referenced By

npv(3) and npvbps(3) are aliases of QuantLib_CashFlows(3).