Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Functions | Variables
QuantExt::detail Namespace Reference

Classes

struct  BachelierSpec
 
struct  Black76Spec
 
class  BlackStyleSwaptionEngineDeltaGamma
 
struct  CloseEnoughComparator
 
class  ImpliedBondSpreadHelper
 helper class for implied vanilla bond spread calculation More...
 
class  LogInterpolationImpl
 
class  NadarayaWatsonImpl
 Nadaraya Watson impl. More...
 
struct  NormalSABRSpecs
 
class  NormalSABRWrapper
 
class  NpvDeltaGammaCalculator
 
class  QuadraticInterpolationImpl
 
class  RegressionImpl
 Regression impl. More...
 
class  SimpleDeltaInterpolatedSmile
 

Functions

void check (const Real p)
 
void check (const Matrix &omega, const Array &delta)
 
void check (const Matrix &omega, const Array &delta, const Matrix &gamma)
 
template<typename A >
Real absMax (const A &a)
 
template<class Key >
Real & getMapEntry (std::map< Key, Real > &map, const Key &key)
 
std::vector< Real > rebucketDeltas (const std::vector< Time > &deltaTimes, const std::map< Date, Real > &deltaRaw, const Date &referenceDate, const DayCounter &dc, const bool linearInZero)
 
Matrix rebucketGammas (const std::vector< Time > &gammaTimes, const std::map< Date, Real > &gammaDscRaw, std::map< std::pair< Date, Date >, Real > &gammaForward, std::map< std::pair< Date, Date >, Real > &gammaDscFwd, const bool forceFullMatrix, const Date &referenceDate, const DayCounter &dc, const bool linearInZero)
 
Real transformVol (const Real v)
 
Real untransformVol (const Real w)
 
QuantLib::ext::shared_ptr< SimpleDeltaInterpolatedSmilecreateSmile (const Real spot, const Real domDisc, const Real forDisc, const Real expiryTime, const std::vector< Real > &deltas, const std::vector< Real > &bfQuotes, const std::vector< Real > &rrQuotes, const Real atmVol, const DeltaVolQuote::DeltaType dt, const DeltaVolQuote::AtmType at, const Option::Type riskReversalInFavorOf, const bool butterflyIsBrokerStyle, const BlackVolatilitySurfaceBFRR::SmileInterpolation smileInterpolation)
 
template<class Curve >
QuantLib::Real dontThrowFallback (const QuantLib::BootstrapError< Curve > &error, QuantLib::Real xMin, QuantLib::Real xMax, QuantLib::Size steps)
 

Variables

const QuantLib::Rate avgInflation = 0.02
 
const QuantLib::Rate maxInflation = 0.5
 
const QuantLib::Real avgHazardRate = 0.01
 
const QuantLib::Real maxHazardRate = 3.0
 

Function Documentation

◆ check() [1/3]

void check ( const Real  p)

Definition at line 31 of file deltagammavar.cpp.

31{ QL_REQUIRE(p >= 0.0 && p <= 1.0, "p (" << p << ") must be in [0,1] in VaR calculation"); }
+ Here is the caller graph for this function:

◆ check() [2/3]

void check ( const Matrix &  omega,
const Array &  delta 
)

Definition at line 33 of file deltagammavar.cpp.

33 {
34 QL_REQUIRE(omega.rows() == omega.columns(),
35 "omega (" << omega.rows() << "x" << omega.columns() << ") must be square in VaR calculation");
36 QL_REQUIRE(delta.size() == omega.rows(), "delta vector size (" << delta.size() << ") must match omega ("
37 << omega.rows() << "x" << omega.columns() << ")");
38}

◆ check() [3/3]

void check ( const Matrix &  omega,
const Array &  delta,
const Matrix &  gamma 
)

Definition at line 40 of file deltagammavar.cpp.

40 {
41 QL_REQUIRE(gamma.rows() == omega.rows() && gamma.columns() == omega.columns(),
42 "gamma (" << gamma.rows() << "x" << gamma.columns() << ") must have same dimensions as omega ("
43 << omega.rows() << "x" << omega.columns() << ")");
44}

◆ absMax()

Real absMax ( const A &  a)

Definition at line 82 of file deltagammavar.hpp.

82 {
83 Real tmp = 0.0;
84 BOOST_FOREACH (Real x, a) {
85 if (std::abs(x) > tmp)
86 tmp = std::abs(x);
87 }
88 return tmp;
89}
+ Here is the caller graph for this function:

◆ getMapEntry()

Real & getMapEntry ( std::map< Key, Real > &  map,
const Key &  key 
)

Definition at line 27 of file discountingswapenginedeltagamma.cpp.

27 {
28 auto f = map.find(key);
29 if (f == map.end()) {
30 return map.insert(std::make_pair(key, 0.0)).first->second;
31 } else {
32 return f->second;
33 }
34}
+ Here is the caller graph for this function:

◆ rebucketDeltas()

std::vector< Real > rebucketDeltas ( const std::vector< Time > &  deltaTimes,
const std::map< Date, Real > &  deltaRaw,
const Date &  referenceDate,
const DayCounter &  dc,
const bool  linearInZero 
)

Definition at line 203 of file discountingswapenginedeltagamma.cpp.

204 {
205 std::vector<Real> delta(deltaTimes.size(), 0.0);
206 for (std::map<Date, Real>::const_iterator i = deltaRaw.begin(); i != deltaRaw.end(); ++i) {
207 Real t = dc.yearFraction(referenceDate, i->first);
208 Size b = std::upper_bound(deltaTimes.begin(), deltaTimes.end(), t) - deltaTimes.begin();
209 if (b == 0) {
210 delta[0] += i->second;
211 } else if (b == deltaTimes.size()) {
212 delta.back() += i->second;
213 } else {
214 Real tmp = (deltaTimes[b] - t) / (deltaTimes[b] - deltaTimes[b - 1]);
215 if (linearInZero) {
216 delta[b - 1] += i->second * tmp;
217 delta[b] += i->second * (1.0 - tmp);
218 } else {
219 delta[b - 1] += i->second * tmp * deltaTimes[b - 1] / t;
220 delta[b] += i->second * (1.0 - tmp) * deltaTimes[b] / t;
221 }
222 }
223 }
224 return delta;
225}
+ Here is the caller graph for this function:

◆ rebucketGammas()

Matrix rebucketGammas ( const std::vector< Time > &  gammaTimes,
const std::map< Date, Real > &  gammaDscRaw,
std::map< std::pair< Date, Date >, Real > &  gammaForward,
std::map< std::pair< Date, Date >, Real > &  gammaDscFwd,
const bool  forceFullMatrix,
const Date &  referenceDate,
const DayCounter &  dc,
const bool  linearInZero 
)

Definition at line 227 of file discountingswapenginedeltagamma.cpp.

230 {
231 int n = gammaTimes.size();
232 // if we have two curves c1, c2, the matrix contains c1-c1, c1-c2, c2-c1, c2-c2 blocks
233 Size n2 = !forceFullMatrix && gammaForward.empty() && gammaDscFwd.empty() ? n : 2 * n;
234 Matrix gamma(n2, n2, 0.0);
235 // pure dsc
236 for (std::map<Date, Real>::const_iterator i = gammaDscRaw.begin(); i != gammaDscRaw.end(); ++i) {
237 Real t = dc.yearFraction(referenceDate, i->first);
238 int b = (int)(std::upper_bound(gammaTimes.begin(), gammaTimes.end(), t) - gammaTimes.begin());
239 if (b == 0) {
240 gamma[0][0] += i->second;
241 } else if (b == n) {
242 gamma[n - 1][n - 1] += i->second;
243 } else {
244 Real tmp = (gammaTimes[b] - t) / (gammaTimes[b] - gammaTimes[b - 1]);
245 if (linearInZero) {
246 gamma[b - 1][b - 1] += i->second * tmp * tmp;
247 gamma[b - 1][b] += i->second * (1.0 - tmp) * tmp;
248 gamma[b][b - 1] += i->second * tmp * (1.0 - tmp);
249 gamma[b][b] += i->second * (1.0 - tmp) * (1.0 - tmp);
250 } else {
251 gamma[b - 1][b - 1] += i->second * tmp * tmp * gammaTimes[b - 1] * gammaTimes[b - 1] / (t * t);
252 gamma[b - 1][b] += i->second * (1.0 - tmp) * tmp * gammaTimes[b] * gammaTimes[b - 1] / (t * t);
253 gamma[b][b - 1] += i->second * tmp * (1.0 - tmp) * gammaTimes[b - 1] * gammaTimes[b] / (t * t);
254 gamma[b][b] += i->second * (1.0 - tmp) * (1.0 - tmp) * gammaTimes[b] * gammaTimes[b] / (t * t);
255 }
256 }
257 }
258 // dsc-fwd
259 if (!gammaDscFwd.empty()) {
260 Matrix gammadf(n, n, 0.0);
261 for (std::map<std::pair<Date, Date>, Real>::const_iterator i = gammaDscFwd.begin(); i != gammaDscFwd.end();
262 ++i) {
263 Real t1 = dc.yearFraction(referenceDate, i->first.first);
264 Real t2 = dc.yearFraction(referenceDate, i->first.second);
265 int b1 = (int)(std::upper_bound(gammaTimes.begin(), gammaTimes.end(), t1) - gammaTimes.begin());
266 int b2 = (int)(std::upper_bound(gammaTimes.begin(), gammaTimes.end(), t2) - gammaTimes.begin());
267 Real w1 = 0.0, w2 = 0.0;
268 int i1 = 0, i2 = 0;
269 if (b1 == 0) {
270 w1 = 1.0;
271 i1 = 0;
272 } else if (b1 == n) {
273 w1 = 0.0;
274 i1 = n - 2;
275 } else {
276 w1 = (gammaTimes[b1] - t1) / (gammaTimes[b1] - gammaTimes[b1 - 1]);
277 i1 = b1 - 1;
278 }
279 if (b2 == 0) {
280 w2 = 1.0;
281 i2 = 0;
282 } else if (b2 == n) {
283 w2 = 0.0;
284 i2 = n - 2;
285 } else {
286 w2 = (gammaTimes[b2] - t2) / (gammaTimes[b2] - gammaTimes[b2 - 1]);
287 i2 = b2 - 1;
288 }
289 if (i1 >= 0) {
290 if (i2 < n - 1)
291 gammadf[i1][i2 + 1] += w1 * (1.0 - w2) * i->second *
292 (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2] / (t1 * t2));
293 if (i2 >= 0) {
294 gammadf[i1][i2] += w1 * w2 * i->second *
295 (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2 - 1] / (t1 * t2));
296 }
297 }
298 if (i2 >= 0 && i1 < n - 1) {
299 gammadf[i1 + 1][i2] += (1.0 - w1) * w2 * i->second *
300 (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2 - 1] / (t1 * t2));
301 }
302 if (i1 < n - 1 && i2 < n - 1) {
303 gammadf[i1 + 1][i2 + 1] += (1.0 - w1) * (1.0 - w2) * i->second *
304 (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2] / (t1 * t2));
305 }
306 }
307 for (int i = 0; i < n; ++i) {
308 for (int j = 0; j < n; ++j) {
309 gamma[i][n + j] = gamma[n + j][i] = gammadf[i][j];
310 }
311 }
312 }
313 // fwd-fwd
314 for (std::map<std::pair<Date, Date>, Real>::const_iterator i = gammaForward.begin(); i != gammaForward.end(); ++i) {
315 Real t1 = dc.yearFraction(referenceDate, i->first.first);
316 Real t2 = dc.yearFraction(referenceDate, i->first.second);
317 int b1 = (int)(std::upper_bound(gammaTimes.begin(), gammaTimes.end(), t1) - gammaTimes.begin());
318 int b2 = (int)(std::upper_bound(gammaTimes.begin(), gammaTimes.end(), t2) - gammaTimes.begin());
319 Real tmp = 0.5 * i->second;
320 Real w1 = 0.0, w2 = 0.0;
321 int i1 = 0, i2 = 0;
322 if (b1 == 0) {
323 w1 = 1.0;
324 i1 = 0;
325 } else if (b1 == n) {
326 w1 = 0.0;
327 i1 = n - 2;
328 } else {
329 w1 = (gammaTimes[b1] - t1) / (gammaTimes[b1] - gammaTimes[b1 - 1]);
330 i1 = b1 - 1;
331 }
332 if (b2 == 0) {
333 w2 = 1.0;
334 i2 = 0;
335 } else if (b2 == n) {
336 w2 = 0.0;
337 i2 = n - 2;
338 } else {
339 w2 = (gammaTimes[b2] - t2) / (gammaTimes[b2] - gammaTimes[b2 - 1]);
340 i2 = b2 - 1;
341 }
342 if (i1 >= 0) {
343 if (i2 < n - 1) {
344 gamma[n + i1][n + i2 + 1] +=
345 w1 * (1.0 - w2) * tmp * (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2] / (t1 * t2));
346 gamma[n + i2 + 1][n + i1] +=
347 w1 * (1.0 - w2) * tmp * (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2] / (t1 * t2));
348 }
349 if (i2 >= 0) {
350 gamma[n + i1][n + i2] +=
351 w1 * w2 * tmp * (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2 - 1] / (t1 * t2));
352 gamma[n + i2][n + i1] +=
353 w1 * w2 * tmp * (linearInZero ? 1.0 : gammaTimes[b1 - 1] * gammaTimes[b2 - 1] / (t1 * t2));
354 }
355 }
356 if (i2 >= 0 && i1 < n - 1) {
357 gamma[n + i1 + 1][n + i2] +=
358 (1.0 - w1) * w2 * tmp * (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2 - 1] / (t1 * t2));
359 gamma[n + i2][n + i1 + 1] +=
360 (1.0 - w1) * w2 * tmp * (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2 - 1] / (t1 * t2));
361 }
362 if (i1 < n - 1 && i2 < n - 1) {
363 gamma[n + i1 + 1][n + i2 + 1] +=
364 (1.0 - w1) * (1.0 - w2) * tmp * (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2] / (t1 * t2));
365 gamma[n + i2 + 1][n + i1 + 1] +=
366 (1.0 - w1) * (1.0 - w2) * tmp * (linearInZero ? 1.0 : gammaTimes[b1] * gammaTimes[b2] / (t1 * t2));
367 }
368 }
369
370 return gamma;
371} // rebucketGammas
+ Here is the caller graph for this function:

◆ transformVol()

Real transformVol ( const Real  v)

Definition at line 32 of file blackvolsurfacebfrr.cpp.

32{ return std::log(v); }
+ Here is the caller graph for this function:

◆ untransformVol()

Real untransformVol ( const Real  w)

Definition at line 33 of file blackvolsurfacebfrr.cpp.

33{ return std::exp(w); }
+ Here is the caller graph for this function:

◆ createSmile()

QuantLib::ext::shared_ptr< SimpleDeltaInterpolatedSmile > createSmile ( const Real  spot,
const Real  domDisc,
const Real  forDisc,
const Real  expiryTime,
const std::vector< Real > &  deltas,
const std::vector< Real > &  bfQuotes,
const std::vector< Real > &  rrQuotes,
const Real  atmVol,
const DeltaVolQuote::DeltaType  dt,
const DeltaVolQuote::AtmType  at,
const Option::Type  riskReversalInFavorOf,
const bool  butterflyIsBrokerStyle,
const BlackVolatilitySurfaceBFRR::SmileInterpolation  smileInterpolation 
)

Definition at line 209 of file blackvolsurfacebfrr.cpp.

213 {
214
215 Real phirr = riskReversalInFavorOf == Option::Call ? 1.0 : -1.0;
216 QuantLib::ext::shared_ptr<SimpleDeltaInterpolatedSmile> resultSmile;
217
218 if (!butterflyIsBrokerStyle) {
219
220 // butterfly is not broker style: we can directly compute the call/put vols ...
221
222 std::vector<Real> vol_p, vol_c;
223
224 for (Size i = 0; i < deltas.size(); ++i) {
225 QL_REQUIRE(atmVol + bfQuotes[i] - 0.5 * std::abs(rrQuotes[i]) > 0.0,
226 "createSmile: atmVol ("
227 << atmVol << ") + bf (" << bfQuotes[i] << ") - rr (" << rrQuotes[i]
228 << ") must be positive when creating smile from smile bf quotes, tte=" << expiryTime);
229 vol_p.push_back(atmVol + bfQuotes[i] - 0.5 * phirr * rrQuotes[i]);
230 vol_c.push_back(atmVol + bfQuotes[i] + 0.5 * phirr * rrQuotes[i]);
231 }
232
233 // ... and set up the interpolated smile
234
235 resultSmile = QuantLib::ext::make_shared<SimpleDeltaInterpolatedSmile>(
236 spot, domDisc, forDisc, expiryTime, deltas, vol_p, vol_c, atmVol, dt, at, smileInterpolation);
237
238 } else {
239
240 Real forward = spot / domDisc * forDisc;
241
242 /* handle broker style butterflys: first determine the strikes and the (non-discounted) premiums
243 of the broker butterflies */
244
245 std::vector<Real> kb_c, kb_p, vb;
246
247 for (Size i = 0; i < deltas.size(); ++i) {
248 Real stddevb = (atmVol + bfQuotes[i]) * std::sqrt(expiryTime);
249 QL_REQUIRE(stddevb > 0.0,
250 "createSmile: atmVol ("
251 << atmVol << ") + bf (" << bfQuotes[i]
252 << ") must be positive when creating smile from broker bf quotes, tte=" << expiryTime);
253 BlackDeltaCalculator cp(Option::Type::Put, dt, spot, domDisc, forDisc, stddevb);
254 BlackDeltaCalculator cc(Option::Type::Call, dt, spot, domDisc, forDisc, stddevb);
255 kb_p.push_back(cp.strikeFromDelta(-deltas[i]));
256 kb_c.push_back(cc.strikeFromDelta(deltas[i]));
257 vb.push_back(blackFormula(Option::Put, kb_p.back(), forward, stddevb) +
258 blackFormula(Option::Call, kb_c.back(), forward, stddevb));
259 }
260
261 /* set initial guess for smile butterfly vol := broker butterfly vol
262 we optimise in z = log( bf - 0.5 * abs(rr) + atmVol ) */
263
264 Array guess(deltas.size());
265 for (Size i = 0; i < deltas.size(); ++i) {
266 guess[i] = std::log(std::max(0.0001, bfQuotes[i] - 0.5 * std::abs(rrQuotes[i]) + atmVol));
267 }
268
269 /* define the target function to match up the butterfly market values and smile values */
270
271 struct TargetFunction : public QuantLib::CostFunction {
272 TargetFunction(Real atmVol, Real phirr, Real spot, Real domDisc, Real forDisc, Real forward,
273 Real expiryTime, DeltaVolQuote::DeltaType dt, DeltaVolQuote::AtmType at,
274 const std::vector<Real>& rrQuotes, const std::vector<Real>& deltas,
275 const std::vector<Real>& kb_p, const std::vector<Real>& kb_c, const std::vector<Real>& vb,
276 BlackVolatilitySurfaceBFRR::SmileInterpolation smileInterpolation)
277 : atmVol(atmVol), phirr(phirr), spot(spot), domDisc(domDisc), forDisc(forDisc), forward(forward),
278 expiryTime(expiryTime), dt(dt), at(at), rrQuotes(rrQuotes), deltas(deltas), kb_p(kb_p), kb_c(kb_c),
279 vb(vb), smileInterpolation(smileInterpolation) {}
280
281 Real atmVol, phirr, spot, domDisc, forDisc, forward, expiryTime;
282 DeltaVolQuote::DeltaType dt;
283 DeltaVolQuote::AtmType at;
284 const std::vector<Real>&rrQuotes, deltas, kb_p, kb_c, vb;
285 BlackVolatilitySurfaceBFRR::SmileInterpolation smileInterpolation;
286
287 mutable Real bestValue = QL_MAX_REAL;
288 mutable QuantLib::ext::shared_ptr<SimpleDeltaInterpolatedSmile> bestSmile;
289
290 Array values(const Array& x) const override {
291
292 constexpr Real large_error = 1E6;
293
294 Array smileBfVol(x.size());
295 for (Size i = 0; i < x.size(); ++i)
296 smileBfVol[i] = std::exp(x[i]) + 0.5 * std::abs(rrQuotes[i]) - atmVol;
297
298 // compute the call/put vols ....
299
300 std::vector<Real> vol_c, vol_p;
301
302 for (Size i = 0; i < deltas.size(); ++i) {
303 vol_p.push_back(atmVol + smileBfVol[i] - 0.5 * phirr * rrQuotes[i]);
304 vol_c.push_back(atmVol + smileBfVol[i] + 0.5 * phirr * rrQuotes[i]);
305 QL_REQUIRE(vol_p.back() > 0.0, " createSmile: internal error: put vol = "
306 << vol_p.back() << " during broker bf fitting");
307 QL_REQUIRE(vol_c.back() > 0.0, " createSmile: internal error: call vol = "
308 << vol_c.back() << " during broker bf fitting");
309 }
310
311 // ... set up the interpolated smile ...
312
313 QuantLib::ext::shared_ptr<SimpleDeltaInterpolatedSmile> tmpSmile;
314 try {
315 tmpSmile = QuantLib::ext::make_shared<SimpleDeltaInterpolatedSmile>(
316 spot, domDisc, forDisc, expiryTime, deltas, vol_p, vol_c, atmVol, dt, at, smileInterpolation);
317 } catch (...) {
318 // if we run into a problem we return max error and continue with the optimization
319 return Array(deltas.size(), large_error);
320 }
321
322 // ... and price the market butterfly on the constructed smile
323
324 std::vector<Real> vs;
325 for (Size i = 0; i < deltas.size(); ++i) {
326 Real pvol, cvol;
327 try {
328 pvol = tmpSmile->volatility(kb_p[i]);
329 cvol = tmpSmile->volatility(kb_c[i]);
330 } catch (...) {
331 // as above, if there is a problem, return max error
332 return Array(deltas.size(), large_error);
333 }
334 vs.push_back(blackFormula(Option::Put, kb_p[i], forward, pvol * std::sqrt(expiryTime)) +
335 blackFormula(Option::Call, kb_c[i], forward, cvol * std::sqrt(expiryTime)));
336 }
337
338 // now set the target function to the relative difference of smile vs. market price
339
340 Array result(deltas.size());
341 for (Size i = 0; i < deltas.size(); ++i) {
342 result[i] = (vs[i] - vb[i]) / vb[i];
343 if (!std::isfinite(result[i]))
344 result[i] = large_error;
345 }
346
347 Real value = std::sqrt(std::accumulate(result.begin(), result.end(), 0.0,
348 [](Real acc, Real x) { return acc + x * x; })) /
349 result.size();
350
351 if (value < bestValue) {
352 bestValue = value;
353 bestSmile = tmpSmile;
354 }
355
356 return result;
357 }
358 }; // TargetFunction declaration;
359
360 TargetFunction targetFunction{atmVol, phirr, spot, domDisc, forDisc, forward, expiryTime, dt,
361 at, rrQuotes, deltas, kb_p, kb_c, vb, smileInterpolation};
362 NoConstraint noConstraint;
363 LevenbergMarquardt lm;
364 EndCriteria endCriteria(100, 10, 1E-8, 1E-8, 1E-8);
365 Problem problem(targetFunction, noConstraint, guess);
366 lm.minimize(problem, endCriteria);
367
368 QL_REQUIRE(targetFunction.bestValue < 0.01, "createSmile at expiry "
369 << expiryTime << " failed: target function value ("
370 << problem.functionValue() << ") not close to zero");
371
372 resultSmile = targetFunction.bestSmile;
373 }
374
375 // sanity check of result smile before return it
376
377 static const std::vector<Real> samplePoints = {0.01, 0.05, 0.1, 0.2, 0.5, 0.8, 0.9, 0.95, 0.99};
378 for (auto const& simpleDelta : samplePoints) {
379 Real vol = resultSmile->volatilityAtSimpleDelta(simpleDelta);
380 QL_REQUIRE(vol > 0.0001 && vol < 5.0, "createSmile at expiry " << expiryTime << ": volatility at simple delta "
381 << simpleDelta << " (" << vol
382 << ") is not plausible.");
383 }
384
385 return resultSmile;
386}
+ Here is the caller graph for this function:

◆ dontThrowFallback()

QuantLib::Real dontThrowFallback ( const QuantLib::BootstrapError< Curve > &  error,
QuantLib::Real  xMin,
QuantLib::Real  xMax,
QuantLib::Size  steps 
)

If dontThrow is true in QuantExt::IterativeBootstrap and on a given pillar the bootstrap fails when searching for a helper root between xMin and xMax, we use this function to return the value that gives the minimum absolute helper error in the interval between xMin and xMax inclusive.

Definition at line 42 of file iterativebootstrap.hpp.

43 {
44
45 QL_REQUIRE(xMin < xMax, "Expected xMin to be less than xMax");
46
47 QuantLib::Real result = xMin;
48 QuantLib::Real minError = QL_MAX_REAL;
49 QuantLib::Real stepSize = (xMax - xMin) / steps;
50
51 for (QuantLib::Size i = 0; i <= steps; ++i) {
52 QuantLib::Real x = xMin + stepSize * static_cast<double>(i);
53 QuantLib::Real absError = QL_MAX_REAL;
54 try {
55 absError = std::abs(error(x));
56 } catch (...) {
57 }
58
59 if (absError < minError) {
60 result = x;
61 minError = absError;
62 }
63 }
64
65 return result;
66}
std::vector< Size > steps
+ Here is the caller graph for this function:

Variable Documentation

◆ avgInflation

const QuantLib::Rate avgInflation = 0.02

Definition at line 32 of file inflationtraits.hpp.

◆ maxInflation

const QuantLib::Rate maxInflation = 0.5

Definition at line 33 of file inflationtraits.hpp.

◆ avgHazardRate

const QuantLib::Real avgHazardRate = 0.01

Definition at line 34 of file probabilitytraits.hpp.

◆ maxHazardRate

const QuantLib::Real maxHazardRate = 3.0

Definition at line 35 of file probabilitytraits.hpp.