27#ifndef quantlib_cashflows_hpp
28#define quantlib_cashflows_hpp
30#include <ql/cashflows/duration.hpp>
31#include <ql/cashflow.hpp>
32#include <ql/interestrate.hpp>
33#include <ql/shared_ptr.hpp>
37 class YieldTermStructure;
50 bool includeSettlementDateFlows,
80 bool includeSettlementDateFlows,
87 static Leg::const_reverse_iterator
89 bool includeSettlementDateFlows,
92 static Leg::const_iterator
94 bool includeSettlementDateFlows,
98 bool includeSettlementDateFlows,
102 bool includeSettlementDateFlows,
106 bool includeSettlementDateFlows,
110 bool includeSettlementDateFlows,
118 bool includeSettlementDateFlows,
122 bool includeSettlementDateFlows,
127 bool includeSettlementDateFlows,
131 bool includeSettlementDateFlows,
135 bool includeSettlementDateFlows,
139 bool includeSettlementDateFlows,
143 bool includeSettlementDateFlows,
147 bool includeSettlementDateFlows,
151 bool includeSettlementDateFlows,
155 bool includeSettlementDateFlows,
159 bool includeSettlementDateFlows,
163 bool includeSettlementDateFlows,
175 bool includeSettlementDateFlows,
186 bool includeSettlementDateFlows,
194 static std::pair<Real, Real>
npvbps(
const Leg& leg,
196 bool includeSettlementDateFlows,
207 bool includeSettlementDateFlows,
221 bool includeSettlementDateFlows,
240 bool includeSettlementDateFlows,
248 bool includeSettlementDateFlows,
261 bool includeSettlementDateFlows,
269 bool includeSettlementDateFlows,
282 bool includeSettlementDateFlows,
285 Real accuracy = 1.0e-10,
286 Size maxIterations = 100,
289 template <
typename Solver>
296 bool includeSettlementDateFlows,
299 Real accuracy = 1.0e-10,
301 IrrFinder objFunction(leg,
npv, dayCounter, compounding,
302 frequency, includeSettlementDateFlows,
303 settlementDate, npvDate);
304 return solver.solve(objFunction, accuracy, guess, guess/10.0);
334 bool includeSettlementDateFlows,
343 bool includeSettlementDateFlows,
357 bool includeSettlementDateFlows,
365 bool includeSettlementDateFlows,
375 bool includeSettlementDateFlows,
383 bool includeSettlementDateFlows,
394 bool includeSettlementDateFlows,
402 bool includeSettlementDateFlows,
420 const ext::shared_ptr<YieldTermStructure>& discount,
425 bool includeSettlementDateFlows,
431 const ext::shared_ptr<YieldTermStructure>&,
435 bool includeSettlementDateFlows,
438 Real accuracy = 1.0e-10,
439 Size maxIterations = 100,
443 const ext::shared_ptr<YieldTermStructure>& d,
448 bool includeSettlementDateFlows,
451 Real accuracy = 1.0e-10,
452 Size maxIterations = 100,
454 return zSpread(leg,
npv, d, dayCounter, compounding, frequency,
455 includeSettlementDateFlows, settlementDate, npvDate,
456 accuracy, maxIterations, guess);
Real derivative(Rate y) const
Real operator()(Rate y) const
bool includeSettlementDateFlows_
cashflow-analysis functions
static Date::serial_type accruedDays(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Real previousCashFlowAmount(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Rate previousCouponRate(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
CashFlows(const CashFlows &)=delete
static Rate nextCouponRate(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Date referencePeriodStart(const Leg &leg, bool includeSettlementDateFlows, Date settlDate=Date())
static Real nextCashFlowAmount(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Real yieldValueBasisPoint(const Leg &leg, const InterestRate &yield, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Yield value of a basis point.
static Real accruedAmount(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Real basisPointValue(const Leg &leg, const InterestRate &yield, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Basis-point value.
static Leg::const_iterator nextCashFlow(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
the first cashflow paying after the given date
static Spread zSpread(const Leg &leg, Real npv, const ext::shared_ptr< YieldTermStructure > &, 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.0)
implied Z-spread.
static Real npv(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
NPV of the cash flows.
static Date accrualEndDate(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Date accrualStartDate(const Leg &leg, bool includeSettlementDateFlows, Date settlDate=Date())
static Leg::const_reverse_iterator previousCashFlow(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
the last cashflow paying before or at the given date
static Date nextCashFlowDate(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
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)
Implied internal rate of return.
static Time accrualPeriod(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Date::serial_type accrualDays(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Date maturityDate(const Leg &leg)
static Time duration(const Leg &leg, const InterestRate &yield, Duration::Type type, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Cash-flow duration.
CashFlows & operator=(CashFlows &&)=delete
static Date startDate(const Leg &leg)
static Real nominal(const Leg &leg, bool includeSettlementDateFlows, Date settlDate=Date())
CashFlows & operator=(const CashFlows &)=delete
static Date previousCashFlowDate(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Rate yield(const Solver &solver, 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, Rate guess=0.05)
static Rate atmRate(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date(), Real npv=Null< Real >())
At-the-money rate of the cash flows.
static bool isExpired(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Real bps(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Basis-point sensitivity of the cash flows.
static Spread zSpread(const Leg &leg, const ext::shared_ptr< YieldTermStructure > &d, 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.0)
deprecated implied Z-spread.
CashFlows(CashFlows &&)=delete
static std::pair< Real, Real > npvbps(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
NPV and BPS of the cash flows.
static Date referencePeriodEnd(const Leg &leg, bool includeSettlementDateFlows, Date settlDate=Date())
static Time accruedPeriod(const Leg &leg, bool includeSettlementDateFlows, Date settlementDate=Date())
static Real convexity(const Leg &leg, const InterestRate &yield, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Cash-flow convexity.
std::int_fast32_t serial_type
serial number type
Concrete interest rate class.
template class providing a null value for a given type.
Interest-rate term structure.
Frequency
Frequency of events.
Real Time
continuous quantity with 1-year units
Real Spread
spreads on interest rates
std::size_t Size
size of a container
Compounding
Interest rate coumpounding rule.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.