Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
BlackVolatilitySurfaceBFRR Class Reference

#include <qle/termstructures/blackvolsurfacebfrr.hpp>

+ Inheritance diagram for BlackVolatilitySurfaceBFRR:
+ Collaboration diagram for BlackVolatilitySurfaceBFRR:

Public Types

enum class  SmileInterpolation { Linear , Cubic }
 

Public Member Functions

 BlackVolatilitySurfaceBFRR (Date referenceDate, const std::vector< Date > &dates, const std::vector< Real > &deltas, const std::vector< std::vector< Real > > &bfQuotes, const std::vector< std::vector< Real > > &rrQuotes, const std::vector< Real > &atmQuotes, const DayCounter &dayCounter, const Calendar &calendar, const Handle< Quote > &spot, const Size spotDays, const Calendar spotCalendar, const Handle< YieldTermStructure > &domesticTS, const Handle< YieldTermStructure > &foreignTS, const DeltaVolQuote::DeltaType dt=DeltaVolQuote::DeltaType::Spot, const DeltaVolQuote::AtmType at=DeltaVolQuote::AtmType::AtmDeltaNeutral, const Period &switchTenor=2 *Years, const DeltaVolQuote::DeltaType ltdt=DeltaVolQuote::DeltaType::Fwd, const DeltaVolQuote::AtmType ltat=DeltaVolQuote::AtmType::AtmDeltaNeutral, const Option::Type riskReversalInFavorOf=Option::Call, const bool butterflyIsBrokerStyle=true, const SmileInterpolation smileInterpolation=SmileInterpolation::Cubic)
 
Date maxDate () const override
 
Real minStrike () const override
 
Real maxStrike () const override
 
const std::vector< QuantLib::Date > & dates () const
 
const std::vector< Real > & deltas () const
 
const std::vector< Real > & currentDeltas () const
 
const std::vector< std::vector< Real > > & bfQuotes () const
 
const std::vector< std::vector< Real > > & rrQuotes () const
 
const std::vector< Real > & atmQuotes () const
 
const Handle< Quote > & spot () const
 
const Handle< YieldTermStructure > & domesticTS () const
 
const Handle< YieldTermStructure > & foreignTS () const
 
DeltaVolQuote::DeltaType deltaType () const
 
DeltaVolQuote::AtmType atmType () const
 
const Period & switchTenor () const
 
DeltaVolQuote::DeltaType longTermDeltaType () const
 
DeltaVolQuote::AtmType longTermAtmType () const
 
Option::Type riskReversalInFavorOf () const
 
bool butterflyIsBrokerStyle () const
 
SmileInterpolation smileInterpolation () const
 
const std::vector< bool > & smileHasError () const
 
const std::vector< std::string > & smileErrorMessage () const
 

Private Member Functions

Volatility blackVolImpl (Time t, Real strike) const override
 
void update () override
 
void performCalculations () const override
 
void clearCaches () const
 

Private Attributes

std::vector< Date > dates_
 
std::vector< Real > deltas_
 
std::vector< std::vector< Real > > bfQuotes_
 
std::vector< std::vector< Real > > rrQuotes_
 
std::vector< Real > atmQuotes_
 
Handle< Quote > spot_
 
Size spotDays_
 
Calendar spotCalendar_
 
Handle< YieldTermStructure > domesticTS_
 
Handle< YieldTermStructure > foreignTS_
 
DeltaVolQuote::DeltaType dt_
 
DeltaVolQuote::AtmType at_
 
Period switchTenor_
 
DeltaVolQuote::DeltaType ltdt_
 
DeltaVolQuote::AtmType ltat_
 
Option::Type riskReversalInFavorOf_
 
bool butterflyIsBrokerStyle_
 
SmileInterpolation smileInterpolation_
 
Real switchTime_
 
Real settlDomDisc_
 
Real settlForDisc_
 
Real settlLag_
 
std::vector< Real > expiryTimes_
 
std::vector< Date > settlementDates_
 
std::vector< Real > currentDeltas_
 
std::vector< QuantLib::ext::shared_ptr< detail::SimpleDeltaInterpolatedSmile > > smiles_
 
std::map< Real, QuantLib::ext::shared_ptr< detail::SimpleDeltaInterpolatedSmile > > cachedInterpolatedSmiles_
 
std::vector< boolsmileHasError_
 
std::vector< std::string > smileErrorMessage_
 

Detailed Description

Definition at line 41 of file blackvolsurfacebfrr.hpp.

Member Enumeration Documentation

◆ SmileInterpolation

enum class SmileInterpolation
strong

Constructor & Destructor Documentation

◆ BlackVolatilitySurfaceBFRR()

BlackVolatilitySurfaceBFRR ( Date  referenceDate,
const std::vector< Date > &  dates,
const std::vector< Real > &  deltas,
const std::vector< std::vector< Real > > &  bfQuotes,
const std::vector< std::vector< Real > > &  rrQuotes,
const std::vector< Real > &  atmQuotes,
const DayCounter &  dayCounter,
const Calendar &  calendar,
const Handle< Quote > &  spot,
const Size  spotDays,
const Calendar  spotCalendar,
const Handle< YieldTermStructure > &  domesticTS,
const Handle< YieldTermStructure > &  foreignTS,
const DeltaVolQuote::DeltaType  dt = DeltaVolQuote::DeltaType::Spot,
const DeltaVolQuote::AtmType  at = DeltaVolQuote::AtmType::AtmDeltaNeutral,
const Period &  switchTenor = 2 * Years,
const DeltaVolQuote::DeltaType  ltdt = DeltaVolQuote::DeltaType::Fwd,
const DeltaVolQuote::AtmType  ltat = DeltaVolQuote::AtmType::AtmDeltaNeutral,
const Option::Type  riskReversalInFavorOf = Option::Call,
const bool  butterflyIsBrokerStyle = true,
const SmileInterpolation  smileInterpolation = SmileInterpolation::Cubic 
)

Definition at line 390 of file blackvolsurfacebfrr.cpp.

399 : BlackVolatilityTermStructure(referenceDate, calendar, Following, dayCounter), dates_(dates), deltas_(deltas),
401 spotCalendar_(spotCalendar), domesticTS_(domesticTS), foreignTS_(foreignTS), dt_(dt), at_(at),
404
405 // checks
406
407 QL_REQUIRE(!dates_.empty(), "BlackVolatilitySurfaceBFRR: no expiry dates given");
408 QL_REQUIRE(!deltas_.empty(), "BlackVolatilitySurfaceBFRR: no deltas given");
409
410 for (Size i = 0; i < deltas_.size() - 1; ++i) {
411 QL_REQUIRE(deltas_[i + 1] > deltas_[i] && !close_enough(deltas_[i], deltas_[i + 1]),
412 "BlackVolatilitySurfaceBFRR: deltas are not strictly ascending at index " << i << ": " << deltas_[i]
413 << ", " << deltas_[i + 1]);
414 }
415
416 QL_REQUIRE(bfQuotes_.size() == dates_.size(), "BlackVolatilitySurfaceBFRR: bfQuotes ("
417 << bfQuotes_.size() << ") mismatch with expiry dates ("
418 << dates_.size() << ")");
419 QL_REQUIRE(rrQuotes_.size() == dates_.size(), "BlackVolatilitySurfaceBFRR: rrQuotes ("
420 << rrQuotes_.size() << ") mismatch with expiry dates ("
421 << dates_.size() << ")");
422 QL_REQUIRE(atmQuotes_.size() == dates_.size(), "BlackVolatilitySurfaceBFRR: atmQuotes ("
423 << atmQuotes_.size() << ") mismatch with expiry dates ("
424 << dates_.size() << ")");
425 for (auto const& q : bfQuotes) {
426 QL_REQUIRE(q.size() == deltas_.size(), "BlackVolatilitySurfaceBFRR: bfQuotes inner vector ("
427 << q.size() << ") mismatch with deltas (" << deltas_.size() << ")");
428 }
429 for (auto const& q : rrQuotes) {
430 QL_REQUIRE(q.size() == deltas_.size(), "BlackVolatilitySurfaceBFRR: bfQuotes inner vector ("
431 << q.size() << ") mismatch with deltas (" << deltas_.size() << ")");
432 }
433
434 // register with observables
435
436 registerWith(spot_);
437 registerWith(domesticTS_);
438 registerWith(foreignTS_);
439}
const std::vector< Real > & atmQuotes() const
std::vector< std::vector< Real > > bfQuotes_
const std::vector< std::vector< Real > > & rrQuotes() const
SmileInterpolation smileInterpolation() const
Handle< YieldTermStructure > foreignTS_
const Handle< Quote > & spot() const
Handle< YieldTermStructure > domesticTS_
const std::vector< Real > & deltas() const
const Handle< YieldTermStructure > & domesticTS() const
const Handle< YieldTermStructure > & foreignTS() const
std::vector< std::vector< Real > > rrQuotes_
const std::vector< QuantLib::Date > & dates() const
const std::vector< std::vector< Real > > & bfQuotes() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 57 of file blackvolsurfacebfrr.hpp.

57{ return Date::maxDate(); }

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 58 of file blackvolsurfacebfrr.hpp.

58{ return 0; }

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 59 of file blackvolsurfacebfrr.hpp.

59{ return QL_MAX_REAL; }

◆ dates()

const std::vector< QuantLib::Date > & dates ( ) const

Definition at line 61 of file blackvolsurfacebfrr.hpp.

61{ return dates_; }

◆ deltas()

const std::vector< Real > & deltas ( ) const

Definition at line 62 of file blackvolsurfacebfrr.hpp.

62{ return deltas_; }

◆ currentDeltas()

const std::vector< Real > & currentDeltas ( ) const

Definition at line 63 of file blackvolsurfacebfrr.hpp.

63{ return currentDeltas_; }

◆ bfQuotes()

const std::vector< std::vector< Real > > & bfQuotes ( ) const

Definition at line 64 of file blackvolsurfacebfrr.hpp.

64{ return bfQuotes_; }
+ Here is the caller graph for this function:

◆ rrQuotes()

const std::vector< std::vector< Real > > & rrQuotes ( ) const

Definition at line 65 of file blackvolsurfacebfrr.hpp.

65{ return rrQuotes_; }
+ Here is the caller graph for this function:

◆ atmQuotes()

const std::vector< Real > & atmQuotes ( ) const

Definition at line 66 of file blackvolsurfacebfrr.hpp.

66{ return atmQuotes_; }

◆ spot()

const Handle< Quote > & spot ( ) const

Definition at line 67 of file blackvolsurfacebfrr.hpp.

67{ return spot_; }

◆ domesticTS()

const Handle< YieldTermStructure > & domesticTS ( ) const

Definition at line 68 of file blackvolsurfacebfrr.hpp.

68{ return domesticTS_; }

◆ foreignTS()

const Handle< YieldTermStructure > & foreignTS ( ) const

Definition at line 69 of file blackvolsurfacebfrr.hpp.

69{ return foreignTS_; }

◆ deltaType()

DeltaVolQuote::DeltaType deltaType ( ) const

Definition at line 70 of file blackvolsurfacebfrr.hpp.

70{ return dt_; }

◆ atmType()

DeltaVolQuote::AtmType atmType ( ) const

Definition at line 71 of file blackvolsurfacebfrr.hpp.

71{ return at_; }

◆ switchTenor()

const Period & switchTenor ( ) const

Definition at line 72 of file blackvolsurfacebfrr.hpp.

72{ return switchTenor_; }

◆ longTermDeltaType()

DeltaVolQuote::DeltaType longTermDeltaType ( ) const

Definition at line 73 of file blackvolsurfacebfrr.hpp.

73{ return ltdt_; }

◆ longTermAtmType()

DeltaVolQuote::AtmType longTermAtmType ( ) const

Definition at line 74 of file blackvolsurfacebfrr.hpp.

74{ return ltat_; }

◆ riskReversalInFavorOf()

Option::Type riskReversalInFavorOf ( ) const

Definition at line 75 of file blackvolsurfacebfrr.hpp.

75{ return riskReversalInFavorOf_; }

◆ butterflyIsBrokerStyle()

bool butterflyIsBrokerStyle ( ) const

Definition at line 76 of file blackvolsurfacebfrr.hpp.

◆ smileInterpolation()

SmileInterpolation smileInterpolation ( ) const

Definition at line 77 of file blackvolsurfacebfrr.hpp.

77{ return smileInterpolation_; }

◆ smileHasError()

const std::vector< bool > & smileHasError ( ) const

Definition at line 441 of file blackvolsurfacebfrr.cpp.

441 {
442 calculate();
443 return smileHasError_;
444}

◆ smileErrorMessage()

const std::vector< std::string > & smileErrorMessage ( ) const

Definition at line 446 of file blackvolsurfacebfrr.cpp.

446 {
447 calculate();
448 return smileErrorMessage_;
449}
std::vector< std::string > smileErrorMessage_

◆ blackVolImpl()

Volatility blackVolImpl ( Time  t,
Real  strike 
) const
overrideprivate

Definition at line 500 of file blackvolsurfacebfrr.cpp.

500 {
501
502 calculate();
503
504 /* minimum supported time is 1D, i.e. if t is smaller, we return the vol at 1D */
505
506 t = std::max(t, 1.0 / 365.0);
507
508 t = t <= expiryTimes_.back() ? t : expiryTimes_.back();
509
510 /* if we have cached the interpolated smile at t, we use that */
511
512 auto s = cachedInterpolatedSmiles_.find(t);
513 if (s != cachedInterpolatedSmiles_.end()) {
514 return s->second->volatility(strike);
515 }
516
517 /* find the indices ip and im such that t_im <= t < t_ip, im will be null if t < first expiry,
518 ip will be null if t >= last expiry */
519
520 Size index_p = std::upper_bound(expiryTimes_.begin(), expiryTimes_.end(), t) - expiryTimes_.begin();
521 Size index_m = index_p == 0 ? Null<Size>() : index_p - 1;
522 if (index_p == expiryTimes_.size())
523 index_p = Null<Size>();
524
525 /* the smiles at the indices might have errors, then go to the next ones without errors */
526
527 while (index_m != Null<Size>() && index_m > 0 && smileHasError_[index_m])
528 --index_m;
529
530 while (index_p != Null<Size>() && index_p < expiryTimes_.size() - 1 && smileHasError_[index_p])
531 ++index_p;
532
533 if (index_m != Null<Size>() && smileHasError_[index_m])
534 index_m = Null<Size>();
535
536 if (index_p != Null<Size>() && smileHasError_[index_p])
537 index_p = Null<Size>();
538
539 if (index_m == Null<Size>() && index_p == Null<Size>()) {
540
541 /* no valid smiles, try to remove the smallest delta until there is only one delta left, then throw an error */
542
543 if (currentDeltas_.size() <= 1) {
544 QL_FAIL("BlackVolatilitySurfaceBFRR::blackVolImpl(" << t << "," << strike
545 << "): no valid smiles, check the market data input.");
546 }
547
548 currentDeltas_.erase(currentDeltas_.begin());
549 clearCaches();
550 return blackVolImpl(t, strike);
551 }
552
553 /* build the smiles on the indices, if we do not have them yet */
554
555 if (index_m != Null<Size>() && smiles_[index_m] == nullptr) {
556 DeltaVolQuote::AtmType at;
557 DeltaVolQuote::DeltaType dt;
558 if (expiryTimes_[index_m] < switchTime_ && !close_enough(switchTime_, expiryTimes_[index_m])) {
559 at = at_;
560 dt = dt_;
561 } else {
562 at = ltat_;
563 dt = ltdt_;
564 }
565 try {
566 smiles_[index_m] = detail::createSmile(
567 spot_->value(), domesticTS_->discount(settlementDates_[index_m]) / settlDomDisc_,
569 bfQuotes_[index_m], rrQuotes_[index_m], atmQuotes_[index_m], dt, at, riskReversalInFavorOf_,
571 } catch (const std::exception& e) {
572 smileHasError_[index_m] = true;
573 smileErrorMessage_[index_m] = e.what();
574 return blackVolImpl(t, strike);
575 }
576 }
577
578 if (index_p != Null<Size>() && smiles_[index_p] == nullptr) {
579 DeltaVolQuote::AtmType at;
580 DeltaVolQuote::DeltaType dt;
581 if (expiryTimes_[index_p] < switchTime_ && !close_enough(switchTime_, expiryTimes_[index_p])) {
582 at = at_;
583 dt = dt_;
584 } else {
585 at = ltat_;
586 dt = ltdt_;
587 }
588 try {
589 smiles_[index_p] = detail::createSmile(
590 spot_->value(), domesticTS_->discount(settlementDates_[index_p]) / settlDomDisc_,
592 bfQuotes_[index_p], rrQuotes_[index_p], atmQuotes_[index_p], dt, at, riskReversalInFavorOf_,
594 } catch (const std::exception& e) {
595 smileHasError_[index_p] = true;
596 smileErrorMessage_[index_p] = e.what();
597 return blackVolImpl(t, strike);
598 }
599 }
600
601 /* Choose a consistent set of smile conventions for all maturities, we follow Clark, 4.2.3 and set
602 delta type = forward delta, with pa if the original (short term) delta convention has pa.
603 The atm type ist set to delta neutral. */
604
605 DeltaVolQuote::DeltaType dt_c =
606 dt_ == (DeltaVolQuote::Spot || dt_ == DeltaVolQuote::Fwd) ? DeltaVolQuote::Fwd : DeltaVolQuote::PaFwd;
607 DeltaVolQuote::AtmType at_c = DeltaVolQuote::AtmDeltaNeutral;
608
609 /* find the vols on both smiles for the artificial smile conventions */
610
611 Real atmVol_m = 0.0, atmVol_p = 0.0;
612 std::vector<Real> putVols_m, callVols_m, putVols_p, callVols_p;
613
614 if (index_m != Null<Size>()) {
615 try {
616 atmVol_m = smiles_[index_m]->volatility(smiles_[index_m]->atmStrike(dt_c, at_c));
617 for (auto const& d : currentDeltas_) {
618 putVols_m.push_back(
619 smiles_[index_m]->volatility(smiles_[index_m]->strikeFromDelta(Option::Put, d, dt_c)));
620 callVols_m.push_back(
621 smiles_[index_m]->volatility(smiles_[index_m]->strikeFromDelta(Option::Call, d, dt_c)));
622 }
623 } catch (const std::exception& e) {
624 smileHasError_[index_m] = true;
625 smileErrorMessage_[index_m] = e.what();
626 return blackVolImpl(t, strike);
627 }
628 }
629
630 if (index_p != Null<Size>()) {
631 try {
632 atmVol_p = smiles_[index_p]->volatility(smiles_[index_p]->atmStrike(dt_c, at_c));
633 for (auto const& d : currentDeltas_) {
634 putVols_p.push_back(
635 smiles_[index_p]->volatility(smiles_[index_p]->strikeFromDelta(Option::Put, d, dt_c)));
636 callVols_p.push_back(
637 smiles_[index_p]->volatility(smiles_[index_p]->strikeFromDelta(Option::Call, d, dt_c)));
638 }
639 } catch (const std::exception& e) {
640 smileHasError_[index_p] = true;
641 smileErrorMessage_[index_p] = e.what();
642 return blackVolImpl(t, strike);
643 }
644 }
645
646 /* find the interpolated vols */
647
648 Real atmVol_i;
649 std::vector<Real> putVols_i, callVols_i;
650
651 if (index_p == Null<Size>()) {
652 // extrapolate beyond last expiry
653 atmVol_i = atmVol_m;
654 putVols_i = putVols_m;
655 callVols_i = callVols_m;
656 QL_REQUIRE(atmVol_i > 0.0, "BlackVolatilitySurfaceBFRR: negative front-extrapolated atm vol " << atmVol_i);
657 for (Size i = 0; i < currentDeltas_.size(); ++i) {
658 QL_REQUIRE(putVols_i[i] > 0.0,
659 "BlackVolatilitySurfaceBFRR: negative front-extrapolated put vol " << putVols_i[i]);
660 QL_REQUIRE(callVols_i[i] > 0.0,
661 "BlackVolatilitySurfaceBFRR: negative front-extrapolated call vol " << callVols_i[i]);
662 }
663 } else if (index_m == Null<Size>()) {
664 // extrapolate before first expiry
665 atmVol_i = atmVol_p;
666 putVols_i = putVols_p;
667 callVols_i = callVols_p;
668 QL_REQUIRE(atmVol_i > 0.0, "BlackVolatilitySurfaceBFRR: negative back-extrapolated atm vol " << atmVol_i);
669 for (Size i = 0; i < currentDeltas_.size(); ++i) {
670 QL_REQUIRE(putVols_i[i] > 0.0,
671 "BlackVolatilitySurfaceBFRR: negative back-extrapolated put vol " << putVols_i[i]);
672 QL_REQUIRE(callVols_i[i] > 0.0,
673 "BlackVolatilitySurfaceBFRR: negative back-extrapolated call vol " << callVols_i[i]);
674 }
675 } else {
676 // interpolate between two expiries
677 Real a = (t - expiryTimes_[index_m]) / (expiryTimes_[index_p] - expiryTimes_[index_m]);
678 atmVol_i = (1.0 - a) * atmVol_m + a * atmVol_p;
679 QL_REQUIRE(atmVol_i > 0.0, "BlackVolatilitySurfaceBFRR: negative atm vol "
680 << atmVol_i << " = " << (1.0 - a) << " * " << atmVol_m << " + " << a << " * "
681 << atmVol_p);
682 for (Size i = 0; i < currentDeltas_.size(); ++i) {
683 putVols_i.push_back((1.0 - a) * putVols_m[i] + a * putVols_p[i]);
684 callVols_i.push_back((1.0 - a) * callVols_m[i] + a * callVols_p[i]);
685 QL_REQUIRE(putVols_i.back() > 0.0, "BlackVolatilitySurfaceBFRR: negative put vol for delta="
686 << currentDeltas_[i] << ", " << putVols_i.back() << " = "
687 << (1.0 - a) << " * " << putVols_m[i] << " + " << a << " * "
688 << putVols_p[i]);
689 QL_REQUIRE(callVols_i.back() > 0.0, "BlackVolatilitySurfaceBFRR: negative call vol for delta="
690 << currentDeltas_[i] << ", " << callVols_i.back() << " = "
691 << (1.0 - a) << " * " << callVols_m[i] << " + " << a << " * "
692 << callVols_p[i]);
693 }
694 }
695
696 /* build a new smile using the interpolated vols and artificial conventions
697 (querying the dom / for TS at t + settlLag_ is not entirely correct, because
698 - of possibly different dcs in the curves and the vol ts and
699 - because settLag_ is the time from today
700 to today's settlement date,
701 but the best we can realistically do in this context, because we don't have a date
702 corresponding to t) */
703
704 QuantLib::ext::shared_ptr<detail::SimpleDeltaInterpolatedSmile> smile;
705
706 try {
707 smile = QuantLib::ext::make_shared<detail::SimpleDeltaInterpolatedSmile>(
708 spot_->value(), domesticTS_->discount(t + settlLag_) / settlDomDisc_,
709 foreignTS_->discount(t + settlLag_) / settlForDisc_, t, currentDeltas_, putVols_i, callVols_i, atmVol_i,
710 dt_c, at_c, smileInterpolation_);
711 } catch (const std::exception& e) {
712 // the interpolated smile failed to build => mark the "m" smile as a failure if available and retry, otherwise
713 // market the "p" smile as a failure and retry
714 Size failureIndex = index_m != Null<Size>() ? index_m : index_p;
715 smileHasError_[failureIndex] = true;
716 smileErrorMessage_[failureIndex] = e.what();
717 return blackVolImpl(t, strike);
718 }
719
720 /* store the new smile in the cache */
721
722 cachedInterpolatedSmiles_[t] = smile;
723
724 /* return the volatility from the smile we just created */
725
726 return smile->volatility(strike);
727}
std::map< Real, QuantLib::ext::shared_ptr< detail::SimpleDeltaInterpolatedSmile > > cachedInterpolatedSmiles_
Volatility blackVolImpl(Time t, Real strike) const override
std::vector< QuantLib::ext::shared_ptr< detail::SimpleDeltaInterpolatedSmile > > smiles_
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)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void update ( )
overrideprivate

Definition at line 488 of file blackvolsurfacebfrr.cpp.

488 {
489 BlackVolatilityTermStructure::update();
490 LazyObject::update();
491}

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 451 of file blackvolsurfacebfrr.cpp.

451 {
452
453 // calculate switch time
454
455 switchTime_ = switchTenor_ == 0 * Days ? QL_MAX_REAL : timeFromReference(optionDateFromTenor(switchTenor_));
456
457 // calculate times associated to expiry dates
458
459 expiryTimes_.clear();
460 settlementDates_.clear();
461 for (auto const& d : dates_) {
462 expiryTimes_.push_back(timeFromReference(d));
463 settlementDates_.push_back(spotCalendar_.advance(d, spotDays_ * Days));
464 }
465
466 // resize cache for smiles on expiry dates
467
468 smiles_.resize(expiryTimes_.size());
469 smileHasError_.resize(expiryTimes_.size());
470 smileErrorMessage_.resize(expiryTimes_.size());
471
472 // calculate discount factors for spot settlement date and the settlement lag
473
474 Date settlDate = spotCalendar_.advance(referenceDate(), spotDays_ * Days);
475 settlDomDisc_ = domesticTS_->discount(settlDate);
476 settlForDisc_ = foreignTS_->discount(settlDate);
477 settlLag_ = timeFromReference(settlDate);
478
479 // clear caches
480
481 clearCaches();
482
483 // reset deltas to use
484
486}
+ Here is the call graph for this function:

◆ clearCaches()

void clearCaches ( ) const
private

Definition at line 493 of file blackvolsurfacebfrr.cpp.

493 {
494 std::fill(smiles_.begin(), smiles_.end(), nullptr);
495 std::fill(smileHasError_.begin(), smileHasError_.end(), false);
496 std::fill(smileErrorMessage_.begin(), smileErrorMessage_.end(), std::string());
498}
+ Here is the caller graph for this function:

Member Data Documentation

◆ dates_

std::vector<Date> dates_
private

Definition at line 88 of file blackvolsurfacebfrr.hpp.

◆ deltas_

std::vector<Real> deltas_
private

Definition at line 89 of file blackvolsurfacebfrr.hpp.

◆ bfQuotes_

std::vector<std::vector<Real> > bfQuotes_
private

Definition at line 90 of file blackvolsurfacebfrr.hpp.

◆ rrQuotes_

std::vector<std::vector<Real> > rrQuotes_
private

Definition at line 91 of file blackvolsurfacebfrr.hpp.

◆ atmQuotes_

std::vector<Real> atmQuotes_
private

Definition at line 92 of file blackvolsurfacebfrr.hpp.

◆ spot_

Handle<Quote> spot_
private

Definition at line 93 of file blackvolsurfacebfrr.hpp.

◆ spotDays_

Size spotDays_
private

Definition at line 94 of file blackvolsurfacebfrr.hpp.

◆ spotCalendar_

Calendar spotCalendar_
private

Definition at line 95 of file blackvolsurfacebfrr.hpp.

◆ domesticTS_

Handle<YieldTermStructure> domesticTS_
private

Definition at line 96 of file blackvolsurfacebfrr.hpp.

◆ foreignTS_

Handle<YieldTermStructure> foreignTS_
private

Definition at line 97 of file blackvolsurfacebfrr.hpp.

◆ dt_

DeltaVolQuote::DeltaType dt_
private

Definition at line 98 of file blackvolsurfacebfrr.hpp.

◆ at_

DeltaVolQuote::AtmType at_
private

Definition at line 99 of file blackvolsurfacebfrr.hpp.

◆ switchTenor_

Period switchTenor_
private

Definition at line 100 of file blackvolsurfacebfrr.hpp.

◆ ltdt_

DeltaVolQuote::DeltaType ltdt_
private

Definition at line 101 of file blackvolsurfacebfrr.hpp.

◆ ltat_

DeltaVolQuote::AtmType ltat_
private

Definition at line 102 of file blackvolsurfacebfrr.hpp.

◆ riskReversalInFavorOf_

Option::Type riskReversalInFavorOf_
private

Definition at line 103 of file blackvolsurfacebfrr.hpp.

◆ butterflyIsBrokerStyle_

bool butterflyIsBrokerStyle_
private

Definition at line 104 of file blackvolsurfacebfrr.hpp.

◆ smileInterpolation_

SmileInterpolation smileInterpolation_
private

Definition at line 105 of file blackvolsurfacebfrr.hpp.

◆ switchTime_

Real switchTime_
mutableprivate

Definition at line 107 of file blackvolsurfacebfrr.hpp.

◆ settlDomDisc_

Real settlDomDisc_
private

Definition at line 107 of file blackvolsurfacebfrr.hpp.

◆ settlForDisc_

Real settlForDisc_
private

Definition at line 107 of file blackvolsurfacebfrr.hpp.

◆ settlLag_

Real settlLag_
private

Definition at line 107 of file blackvolsurfacebfrr.hpp.

◆ expiryTimes_

std::vector<Real> expiryTimes_
mutableprivate

Definition at line 108 of file blackvolsurfacebfrr.hpp.

◆ settlementDates_

std::vector<Date> settlementDates_
mutableprivate

Definition at line 109 of file blackvolsurfacebfrr.hpp.

◆ currentDeltas_

std::vector<Real> currentDeltas_
mutableprivate

Definition at line 110 of file blackvolsurfacebfrr.hpp.

◆ smiles_

std::vector<QuantLib::ext::shared_ptr<detail::SimpleDeltaInterpolatedSmile> > smiles_
mutableprivate

Definition at line 112 of file blackvolsurfacebfrr.hpp.

◆ cachedInterpolatedSmiles_

std::map<Real, QuantLib::ext::shared_ptr<detail::SimpleDeltaInterpolatedSmile> > cachedInterpolatedSmiles_
mutableprivate

Definition at line 113 of file blackvolsurfacebfrr.hpp.

◆ smileHasError_

std::vector<bool> smileHasError_
mutableprivate

Definition at line 114 of file blackvolsurfacebfrr.hpp.

◆ smileErrorMessage_

std::vector<std::string> smileErrorMessage_
mutableprivate

Definition at line 115 of file blackvolsurfacebfrr.hpp.