34 : r_(
r), dc_(
std::move(dc)), comp_(comp), freqMakesSense_(false) {
39 "frequency not allowed for this interest rate");
46 QL_REQUIRE(
t>=0.0,
"negative time (" <<
t <<
") not allowed");
54 return std::exp(
r_*
t);
66 QL_FAIL(
"unknown compounding convention");
76 QL_REQUIRE(compound>0.0,
"positive compound factor required");
80 QL_REQUIRE(
t>=0.0,
"non negative time (" <<
t <<
") required");
83 QL_REQUIRE(
t>0.0,
"positive time (" <<
t <<
") required");
86 r = (compound - 1.0)/
t;
89 r = (std::pow(compound, 1.0/(
Real(freq)*
t))-1.0)*
Real(freq);
92 r = std::log(compound)/
t;
95 if (
t<=1.0/
Real(freq))
96 r = (compound - 1.0)/
t;
98 r = (std::pow(compound, 1.0/(
Real(freq)*
t))-1.0)*
Real(freq);
101 if (
t>1.0/
Real(freq))
102 r = (compound - 1.0)/
t;
104 r = (std::pow(compound, 1.0/(
Real(freq)*
t))-1.0)*
Real(freq);
107 QL_FAIL(
"unknown compounding convention ("
117 return out <<
"null interest rate";
122 out <<
"simple compounding";
129 "for this interest rate");
135 out <<
"continuous compounding";
142 "for this interest rate");
144 out <<
"simple compounding up to "
154 "for this interest rate");
156 out <<
"compounding up to "
158 << ir.
frequency() <<
" simple compounding";
162 QL_FAIL(
"unknown compounding convention ("
std::string name() const
Returns the name of the day counter.
Concrete interest rate class.
const DayCounter & dayCounter() const
Compounding compounding() const
static InterestRate impliedRate(Real compound, const DayCounter &resultDC, Compounding comp, Frequency freq, Time t)
implied interest rate for a given compound factor at a given time.
InterestRate()
Default constructor returning a null interest rate.
Real compoundFactor(Time t) const
compound factor implied by the rate compounded at time t.
Frequency frequency() const
template class providing a null value for a given type.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Frequency
Frequency of events.
@ Once
only once, e.g., a zero-coupon
@ NoFrequency
null frequency
detail::percent_holder rate(Rate)
output rates and spreads as percentages
Real Time
continuous quantity with 1-year units
QL_INTEGER Integer
integer number
Compounding
Interest rate coumpounding rule.
@ CompoundedThenSimple
Compounded up to the first period then Simple.
@ SimpleThenCompounded
Simple up to the first period then Compounded.
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
ext::shared_ptr< YieldTermStructure > r