19#include <ql/math/distributions/normaldistribution.hpp>
27 Volatility bf,
bool firstApprox,
const DeltaVolQuote::AtmType& atmType,
28 const DeltaVolQuote::DeltaType& deltaType,
const Real delta)
29 :
FxSmileSection(spot, rd, rf, t), atmVol_(atmVol), rr_(rr), bf_(bf), firstApprox_(firstApprox) {
41 k_atm_ = a.atmStrike(atmType);
42 }
catch (
const std::exception& e) {
43 QL_FAIL(
"VannaVolgaSmileSection: Error during calculating atm strike: "
44 << e.what() <<
" (t=" << t <<
", atmVol=" << atmVol <<
", bf=" <<
bf_ <<
", rr=" << rr <<
", vol_c="
45 <<
vol_c_ <<
", vol_p=" <<
vol_p_ <<
", atmType=" << atmType <<
", deltaType=" << deltaType
52 k_c_ = c.strikeFromDelta(delta);
53 }
catch (
const std::exception& e) {
54 QL_FAIL(
"VannaVolgaSmileSection: Error during calculating call strike at delta "
55 << delta <<
": " << e.what() <<
" (t=" << t <<
", atmVol=" << atmVol <<
", bf=" <<
bf_ <<
", rr=" << rr
56 <<
", vol_c=" <<
vol_c_ <<
", vol_p=" <<
vol_p_ <<
", deltaType=" << deltaType <<
", spot=" << spot
63 k_p_ = p.strikeFromDelta(-delta);
64 }
catch (
const std::exception& e) {
65 QL_FAIL(
"VannaVolgaSmileSection: Error during calculating put strike at delta "
66 << delta <<
": " << e.what() <<
" (t=" << t <<
", atmVol=" << atmVol <<
", bf=" <<
bf_ <<
", rr=" << rr
67 <<
", vol_c=" <<
vol_c_ <<
", vol_p=" <<
vol_p_ <<
", deltaType=" << deltaType <<
", spot=" << spot
81 QL_REQUIRE(k >= 0,
"Non-positive strike (" << k <<
")");
89 Real r1 =
log(k2 / k) *
log(k3 / k) / (
log(k2 / k1) *
log(k3 / k1));
90 Real r2 =
log(k / k1) *
log(k3 / k) / (
log(k2 / k1) *
log(k3 / k2));
91 Real r3 =
log(k / k1) *
log(k / k2) / (
log(k3 / k1) *
log(k3 / k2));
95 return std::max(sigma1_k, Real(0.0001));
104 Real d1d2k =
d1(k) *
d2(k);
107 QL_REQUIRE(tmp >= 0,
"VannaVolga attempting to take square root of negative number in second approximation. "
108 "Consider using first approximation in fxvol config.");
DiscountFactor domesticDiscount() const
DiscountFactor foreignDiscount() const
VannaVolgaSmileSection(Real spot, Real rd, Real rf, Time t, Volatility atmVol, Volatility rr, Volatility bf, bool firstApprox=false, const DeltaVolQuote::AtmType &atmType=DeltaVolQuote::AtmType::AtmDeltaNeutral, const DeltaVolQuote::DeltaType &deltaType=DeltaVolQuote::DeltaType::Spot, const Real delta=0.25)
Volatility volatility(Real strike) const override
FX smile section assuming a strike/volatility space using vanna volga method.
RandomVariable sqrt(RandomVariable x)
CompiledFormula log(CompiledFormula x)