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

#include <qle/termstructures/spreadedsmilesection2.hpp>

+ Inheritance diagram for SpreadedSmileSection2:
+ Collaboration diagram for SpreadedSmileSection2:

Public Member Functions

 SpreadedSmileSection2 (const QuantLib::ext::shared_ptr< SmileSection > &base, const std::vector< Real > &volSpreads, const std::vector< Real > &strikes, const bool strikesRelativeToAtm=false, const Real baseAtmLevel=Null< Real >(), const Real simulatedAtmLevel=Null< Real >(), const bool stickyAbsMoney=false)
 
Rate minStrike () const override
 
Rate maxStrike () const override
 
Rate atmLevel () const override
 

Protected Member Functions

Volatility volatilityImpl (Rate strike) const override
 

Private Attributes

QuantLib::ext::shared_ptr< SmileSection > base_
 
std::vector< Real > volSpreads_
 
std::vector< Real > strikes_
 
bool strikesRelativeToAtm_
 
Real baseAtmLevel_
 
Real simulatedAtmLevel_
 
bool stickyAbsMoney_
 
Interpolation volSpreadInterpolation_
 

Detailed Description

Definition at line 35 of file spreadedsmilesection2.hpp.

Constructor & Destructor Documentation

◆ SpreadedSmileSection2()

SpreadedSmileSection2 ( const QuantLib::ext::shared_ptr< SmileSection > &  base,
const std::vector< Real > &  volSpreads,
const std::vector< Real > &  strikes,
const bool  strikesRelativeToAtm = false,
const Real  baseAtmLevel = Null<Real>(),
const Real  simulatedAtmLevel = Null<Real>(),
const bool  stickyAbsMoney = false 
)
  • If stickyAbsMoney = true or if strikes are relative to atm and more than one strike is giv en, the base smile section must provide an ATM level that does not react to changes in the rate levels. Alternatively, baseAtmLevel can be provided.
  • If stickyAbsMoney = true, simulatedAtmLevel must be provided and represent the ATM level that does react to changes in the rate levels.

Definition at line 27 of file spreadedsmilesection2.cpp.

31 : SmileSection(base->exerciseTime(), base->dayCounter(), base->volatilityType(),
32 base->volatilityType() == ShiftedLognormal ? base->shift() : 0.0),
33 base_(base), volSpreads_(volSpreads), strikes_(strikes), strikesRelativeToAtm_(strikesRelativeToAtm),
34 baseAtmLevel_(baseAtmLevel), simulatedAtmLevel_(simulatedAtmLevel), stickyAbsMoney_(stickyAbsMoney) {
35 registerWith(base_);
36 QL_REQUIRE(!strikes_.empty(), "SpreadedSmileSection2: strikes empty");
37 QL_REQUIRE(strikes_.size() == volSpreads_.size(), "SpreadedSmileSection2: strike spreads ("
38 << strikes_.size() << ") inconsistent with vol spreads ("
39 << volSpreads_.size() << ")");
40 if ((strikesRelativeToAtm_ && strikes.size() > 1) || stickyAbsMoney) {
41 QL_REQUIRE(baseAtmLevel_ != Null<Real>() || base_->atmLevel() != Null<Real>(),
42 "SpreadedSmileSection2: if strikeRelativeToATM is true and more than one strike is given, or if "
43 "stickyAbsMoney is true, the base atm level must be given.");
44 }
45 if (stickyAbsMoney) {
46 QL_REQUIRE(simulatedAtmLevel_ != Null<Real>(),
47 "SpreadedSmileSection2: if stickyAbsMoney is true, the simulatedAtmLevel must be given");
48 }
49 if (volSpreads_.size() > 1) {
50 volSpreadInterpolation_ = LinearFlat().interpolate(strikes_.begin(), strikes_.end(), volSpreads_.begin());
51 volSpreadInterpolation_.enableExtrapolation();
52 }
53}
QuantLib::ext::shared_ptr< SmileSection > base_
vector< Real > strikes
+ Here is the call graph for this function:

Member Function Documentation

◆ minStrike()

Rate minStrike ( ) const
override

Definition at line 55 of file spreadedsmilesection2.cpp.

55{ return base_->minStrike(); }

◆ maxStrike()

Rate maxStrike ( ) const
override

Definition at line 56 of file spreadedsmilesection2.cpp.

56{ return base_->maxStrike(); }

◆ atmLevel()

Rate atmLevel ( ) const
override

Definition at line 57 of file spreadedsmilesection2.cpp.

57 {
58 return baseAtmLevel_ != Null<Real>() ? baseAtmLevel_ : base_->atmLevel();
59}
+ Here is the caller graph for this function:

◆ volatilityImpl()

Volatility volatilityImpl ( Rate  strike) const
overrideprotected

Definition at line 61 of file spreadedsmilesection2.cpp.

61 {
62 Real effStrike;
63 if (stickyAbsMoney_) {
64 effStrike = strike - (simulatedAtmLevel_ - atmLevel());
65 } else {
66 effStrike = strike;
67 }
68 if (volSpreads_.size() == 1)
69 return base_->volatility(effStrike) + volSpreads_.front();
70 else if (strikesRelativeToAtm_) {
71 Real f = atmLevel();
72 QL_REQUIRE(f != Null<Real>(), "SpreadedSmileSection2: atm level required");
73 return base_->volatility(effStrike) + volSpreadInterpolation_(strike - f);
74 } else {
75 return base_->volatility(effStrike) + volSpreadInterpolation_(effStrike);
76 }
77}
+ Here is the call graph for this function:

Member Data Documentation

◆ base_

QuantLib::ext::shared_ptr<SmileSection> base_
private

Definition at line 54 of file spreadedsmilesection2.hpp.

◆ volSpreads_

std::vector<Real> volSpreads_
private

Definition at line 55 of file spreadedsmilesection2.hpp.

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 56 of file spreadedsmilesection2.hpp.

◆ strikesRelativeToAtm_

bool strikesRelativeToAtm_
private

Definition at line 57 of file spreadedsmilesection2.hpp.

◆ baseAtmLevel_

Real baseAtmLevel_
private

Definition at line 58 of file spreadedsmilesection2.hpp.

◆ simulatedAtmLevel_

Real simulatedAtmLevel_
private

Definition at line 59 of file spreadedsmilesection2.hpp.

◆ stickyAbsMoney_

bool stickyAbsMoney_
private

Definition at line 60 of file spreadedsmilesection2.hpp.

◆ volSpreadInterpolation_

Interpolation volSpreadInterpolation_
private

Definition at line 61 of file spreadedsmilesection2.hpp.