31 class ImpliedSpotHelper {
35 Real standardDeviation,
36 ext::shared_ptr<PlainVanillaPayoff>
payoff,
43 standardDeviation_,riskFreeDiscount_);
51 ext::shared_ptr<PlainVanillaPayoff>
payoff_;
57 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
58 : process_(
std::move(process)) {
65 "Daughter strike must be positive");
68 "Mother strike must be positive");
73 Date helpDate(
process_->riskFreeRate()->referenceDate());
75 Real vol =
process_->blackVolatility()->blackVol(helpMaturity,
79 vol=vol*std::sqrt(helpTimeToMat);
82 process_->dividendYield()->discount(helpMaturity);
85 process_->riskFreeRate()->discount(helpMaturity);
88 ext::shared_ptr<ImpliedSpotHelper>
f(
89 new ImpliedSpotHelper(dividendDiscount, riskFreeDiscount,
94 Real accuracy = 1.0e-6;
126 Real N2XmSM=N2(-phi*w*XmSM,phi*dP);
127 Real N2X=N2(-phi*w*X,phi*dM);
133 Real invMTime=1/std::sqrt(rTM);
134 Real invDTime=1/std::sqrt(rTD);
136 Real tempRes=phi*w*
S*ddD*N2XmSM-phi*w*strD*rdD*N2X-w*strM*rdM*NX;
137 Real tempDelta=phi*w*ddD*N2XmSM;
138 Real tempGamma=(ddD/(vD*
S))*(invMTime*nXm*NT12+w*invDTime*ndP*NeX);
139 Real tempVega=ddD*
S*((1/invMTime)*nXm*NT12+w*(1/invDTime)*ndP*NeX);
140 Real tempTheta=phi*w*dD*
S*ddD*N2XmSM-phi*w*rD*strD*rdD*N2X-w*rD*strM*rdM*NX;
141 tempTheta-=0.5*vD*
S*ddD*(invMTime*nXm*NT12+w*invDTime*ndP*NeX);
200 ext::shared_ptr<PlainVanillaPayoff>
202 ext::shared_ptr<PlainVanillaPayoff> dPayoff =
203 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
205 QL_REQUIRE(dPayoff,
"non-plain payoff given");
209 ext::shared_ptr<PlainVanillaPayoff>
211 ext::shared_ptr<PlainVanillaPayoff> mPayoff =
212 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
213 QL_REQUIRE(mPayoff,
"non-plain payoff given");
285 resX=resX*std::exp(0.5*sd*sd);
295 return (X*std::sqrt(rtD)+std::sqrt(rtM)*
dMinus())/std::sqrt(rtD-rtM);
Real transformX(Real X) const
Real volatilityMother() const
Time residualTimeMother() const
Real stdDeviationDaughter() const
DiscountFactor dividendDiscountMotherDaughter() const
DiscountFactor riskFreeDiscountMotherDaughter() const
DiscountFactor riskFreeDiscountMother() const
Real dividendRateDaughter() const
Real stdDeviationMother() const
ext::shared_ptr< PlainVanillaPayoff > payoffDaughter() const
Real dPlusTau12(Real S) const
Time residualTimeMotherDaughter() const
void calculate() const override
DiscountFactor dividendDiscountDaughter() const
Date maturityDaughter() const
AnalyticCompoundOptionEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
Real typeDaughter() const
Real riskFreeRateDaughter() const
ext::shared_ptr< PlainVanillaPayoff > payoffMother() const
Real strikeDaughter() const
Real strikeMother() const
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Time residualTimeDaughter() const
DiscountFactor dividendDiscountMother() const
Real volatilityDaughter() const
Date maturityMother() const
CumulativeNormalDistribution N_
DiscountFactor riskFreeDiscountDaughter() const
Cumulative bivariate normal distribution function.
ext::shared_ptr< Exercise > daughterExercise
ext::shared_ptr< StrikedTypePayoff > daughterPayoff
CompoundOption::results results_
CompoundOption::arguments arguments_
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
void setMaxEvaluations(Size evaluations)
Real solve(const F &f, Real accuracy, Real guess, Real step) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
const ext::shared_ptr< Payoff > payoff_
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
ext::shared_ptr< QuantLib::Payoff > payoff
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
Analytic compound option engines.