46 ext::shared_ptr<ShortRateDynamics> numericDynamics(
48 ext::shared_ptr<TrinomialTree> trinomial(
50 ext::shared_ptr<ShortRateTree> numericTree(
54 ext::shared_ptr<NumericalImpl> impl =
57 for (
Size i=0; i<(grid.
size() - 1); i++) {
59 const Array& statePrices = numericTree->statePrices(i);
61 Time dt = numericTree->timeGrid().dt(i);
62 Real dx = trinomial->dx(i);
63 Real x = trinomial->underlying(i,0);
65 for (
Size j=0; j<size; j++) {
66 value += statePrices[j]*std::exp(-x*dt);
70 impl->set(grid[i],
value);
82 return std::exp(
value)*discount2/discount1;
91 Time bondMaturity)
const {
96 v =
sigma()*
B(maturity, bondMaturity)* std::sqrt(maturity);
98 v =
sigma()*
B(maturity, bondMaturity)*
99 std::sqrt(0.5*(1.0 - std::exp(-2.0*_a*maturity))/_a);
109 Time bondMaturity)
const {
114 v =
sigma()*
B(bondStart, bondMaturity)* std::sqrt(maturity);
116 Real c = exp(-2.0*_a*(bondStart-maturity))
117 - exp(-2.0*_a*bondStart)
118 -2.0*(exp(-_a*(bondStart+bondMaturity-2.0*maturity))
119 - exp(-_a*(bondStart+bondMaturity)))
120 + exp(-2.0*_a*(bondMaturity-maturity))
121 - exp(-2.0*_a*bondMaturity);
125 v =
sigma()/(_a*sqrt(2.0*_a)) * sqrt(std::max(c, 0.0));
139 "negative futures price (" << futuresPrice <<
") not allowed");
141 "negative t (" <<
t <<
") not allowed");
143 "T (" <<
T <<
") must not be less than t (" <<
t <<
")");
145 "negative sigma (" <<
sigma <<
") not allowed");
147 "negative a (" <<
a <<
") not allowed");
150 Real tempDeltaT = (1.-std::exp(-
a*deltaT)) /
a;
154 Real lambda = halfSigmaSquare * (1.-std::exp(-2.0*
a*
t)) /
a *
155 tempDeltaT * tempDeltaT;
157 Real tempT = (1.0 - std::exp(-
a*
t)) /
a;
160 Real phi = halfSigmaSquare * tempDeltaT * tempT * tempT;
165 Rate futureRate = (100.0-futuresPrice)/100.0;
166 return (1.0-std::exp(-z)) * (futureRate + 1.0/(
T-
t));
1-D array used in linear algebra.
Size size() const
dimension of the array
Real value(const Array ¶ms, const std::vector< ext::shared_ptr< CalibrationHelper > > &)
Shared handle to an observable.
Short-rate dynamics in the Hull-White model.
Analytical term-structure fitting parameter .
HullWhite(const Handle< YieldTermStructure > &termStructure, Real a=0.1, Real sigma=0.01)
static Rate convexityBias(Real futurePrice, Time t, Time T, Real sigma, Real a)
Real discountBondOption(Option::Type type, Real strike, Time maturity, Time bondMaturity) const override
void generateArguments() override
ext::shared_ptr< Lattice > tree(const TimeGrid &grid) const override
Return by default a trinomial recombining tree.
Real A(Time t, Time T) const override
Parameter which is always zero
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Real discountBond(Time now, Time maturity, Array factors) const override
Recombining trinomial tree discretizing the state variable.
const ext::shared_ptr< Impl > & implementation() const
Term-structure consistent model class.
const Handle< YieldTermStructure > & termStructure() const
Deterministic time-dependent parameter used for yield-curve fitting.
Recombining trinomial tree class.
Real B(Time t, Time T) const override
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
ext::shared_ptr< BlackVolTermStructure > v