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

FxEq Option Helper. More...

#include <qle/models/fxeqoptionhelper.hpp>

+ Inheritance diagram for FxEqOptionHelper:
+ Collaboration diagram for FxEqOptionHelper:

Public Member Functions

 FxEqOptionHelper (const Period &maturity, const Calendar &calendar, const Real strike, const Handle< Quote > spot, const Handle< Quote > volatility, const Handle< YieldTermStructure > &domesticYield, const Handle< YieldTermStructure > &foreignYield, BlackCalibrationHelper::CalibrationErrorType errorType=BlackCalibrationHelper::RelativePriceError)
 
 FxEqOptionHelper (const Date &exerciseDate, const Real strike, const Handle< Quote > spot, const Handle< Quote > volatility, const Handle< YieldTermStructure > &domesticYield, const Handle< YieldTermStructure > &foreignYield, BlackCalibrationHelper::CalibrationErrorType errorType=BlackCalibrationHelper::RelativePriceError)
 
void addTimesTo (std::list< Time > &) const override
 
void performCalculations () const override
 
Real modelValue () const override
 
Real blackPrice (Real volatility) const override
 
QuantLib::ext::shared_ptr< VanillaOption > option () const
 
Real strike () const
 

Private Attributes

Handle< YieldTermStructure > termStructure_
 
const bool hasMaturity_
 
Period maturity_
 
Date exerciseDate_
 
Calendar calendar_
 
const Real strike_
 
const Handle< Quote > spot_
 
const Handle< YieldTermStructure > foreignYield_
 
Real tau_
 
Real atm_
 
Option::Type type_
 
QuantLib::ext::shared_ptr< VanillaOption > option_
 
Real effStrike_
 

Detailed Description

FxEq Option Helper.

Definition at line 36 of file fxeqoptionhelper.hpp.

Constructor & Destructor Documentation

◆ FxEqOptionHelper() [1/2]

FxEqOptionHelper ( const Period &  maturity,
const Calendar &  calendar,
const Real  strike,
const Handle< Quote >  spot,
const Handle< Quote >  volatility,
const Handle< YieldTermStructure > &  domesticYield,
const Handle< YieldTermStructure > &  foreignYield,
BlackCalibrationHelper::CalibrationErrorType  errorType = BlackCalibrationHelper::RelativePriceError 
)

the spot is interpreted as of today (or discounted spot) if strike is null, an (fwd-) atm option is constructed, a slight approximation is introduced because there is no settlement lag, however this applies consistently to the black and the model pricing

Definition at line 28 of file fxeqoptionhelper.cpp.

33 : BlackCalibrationHelper(volatility, errorType), termStructure_(domesticYield), hasMaturity_(true),
34 maturity_(maturity), calendar_(calendar), strike_(strike), spot_(spot), foreignYield_(foreignYield) {
35 registerWith(spot_);
36 registerWith(foreignYield_);
37}
const Handle< Quote > spot_
const Handle< YieldTermStructure > foreignYield_
Handle< YieldTermStructure > termStructure_

◆ FxEqOptionHelper() [2/2]

FxEqOptionHelper ( const Date &  exerciseDate,
const Real  strike,
const Handle< Quote >  spot,
const Handle< Quote >  volatility,
const Handle< YieldTermStructure > &  domesticYield,
const Handle< YieldTermStructure > &  foreignYield,
BlackCalibrationHelper::CalibrationErrorType  errorType = BlackCalibrationHelper::RelativePriceError 
)

Definition at line 39 of file fxeqoptionhelper.cpp.

43 : BlackCalibrationHelper(volatility, errorType), termStructure_(domesticYield), hasMaturity_(false),
44 exerciseDate_(exerciseDate), strike_(strike), spot_(spot), foreignYield_(foreignYield) {
45 registerWith(spot_);
46 registerWith(foreignYield_);
47}

Member Function Documentation

◆ addTimesTo()

void addTimesTo ( std::list< Time > &  ) const
override

Definition at line 52 of file fxeqoptionhelper.hpp.

52{}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 49 of file fxeqoptionhelper.cpp.

49 {
50 if (hasMaturity_)
51 exerciseDate_ = calendar_.advance(termStructure_->referenceDate(), maturity_);
52 tau_ = termStructure_->timeFromReference(exerciseDate_);
53 atm_ = spot_->value() * foreignYield_->discount(tau_) / termStructure_->discount(tau_);
55 if (effStrike_ == Null<Real>())
57 type_ = effStrike_ >= atm_ ? Option::Call : Option::Put;
58 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff(new PlainVanillaPayoff(type_, effStrike_));
59 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<EuropeanExercise>(exerciseDate_);
60 option_ = QuantLib::ext::shared_ptr<VanillaOption>(new VanillaOption(payoff, exercise));
61 BlackCalibrationHelper::performCalculations();
62}
QuantLib::ext::shared_ptr< VanillaOption > option_

◆ modelValue()

Real modelValue ( ) const
override

Definition at line 64 of file fxeqoptionhelper.cpp.

64 {
65 calculate();
66 option_->setPricingEngine(engine_);
67 return option_->NPV();
68}
QuantLib::ext::shared_ptr< PricingEngine > engine_
Definition: cdsoption.cpp:78

◆ blackPrice()

Real blackPrice ( Real  volatility) const
override

Definition at line 70 of file fxeqoptionhelper.cpp.

70 {
71 calculate();
72 const Real stdDev = volatility * std::sqrt(tau_);
73 return blackFormula(type_, effStrike_, atm_, stdDev, termStructure_->discount(tau_));
74}

◆ option()

QuantLib::ext::shared_ptr< VanillaOption > option ( ) const

Definition at line 56 of file fxeqoptionhelper.hpp.

56{ return option_; }

◆ strike()

Real strike ( ) const

Definition at line 57 of file fxeqoptionhelper.hpp.

57 {
58 calculate();
59 return effStrike_;
60 }

Member Data Documentation

◆ termStructure_

Handle<YieldTermStructure> termStructure_
private

Definition at line 63 of file fxeqoptionhelper.hpp.

◆ hasMaturity_

const bool hasMaturity_
private

Definition at line 64 of file fxeqoptionhelper.hpp.

◆ maturity_

Period maturity_
private

Definition at line 65 of file fxeqoptionhelper.hpp.

◆ exerciseDate_

Date exerciseDate_
mutableprivate

Definition at line 66 of file fxeqoptionhelper.hpp.

◆ calendar_

Calendar calendar_
private

Definition at line 67 of file fxeqoptionhelper.hpp.

◆ strike_

const Real strike_
private

Definition at line 68 of file fxeqoptionhelper.hpp.

◆ spot_

const Handle<Quote> spot_
private

Definition at line 69 of file fxeqoptionhelper.hpp.

◆ foreignYield_

const Handle<YieldTermStructure> foreignYield_
private

Definition at line 70 of file fxeqoptionhelper.hpp.

◆ tau_

Real tau_
mutableprivate

Definition at line 71 of file fxeqoptionhelper.hpp.

◆ atm_

Real atm_
mutableprivate

Definition at line 72 of file fxeqoptionhelper.hpp.

◆ type_

Option::Type type_
mutableprivate

Definition at line 73 of file fxeqoptionhelper.hpp.

◆ option_

QuantLib::ext::shared_ptr<VanillaOption> option_
mutableprivate

Definition at line 74 of file fxeqoptionhelper.hpp.

◆ effStrike_

Real effStrike_
mutableprivate

Definition at line 75 of file fxeqoptionhelper.hpp.