33/*
44 Copyright (C) 2006 Mario Pucci
55 Copyright (C) 2013, 2015 Peter Caspers
6+ Copyright (C) 2026 Yassine Idyiahia
67
78 This file is part of QuantLib, a free-software/open-source library
89 for financial quantitative analysts and developers - http://quantlib.org/
@@ -71,10 +72,12 @@ namespace QuantLib {
7172
7273 Real SmileSection::optionPrice (Rate strike,
7374 Option::Type type,
74- Real discount) const {
75- Real atm = atmLevel ();
75+ Real discount,
76+ Real forward) const {
77+ Real atm = forward != Null<Real>() ? forward : atmLevel ();
7678 QL_REQUIRE (atm != Null<Real>(),
77- " smile section must provide atm level to compute option price" );
79+ " smile section must provide atm level "
80+ " or forward must be passed to compute option price" );
7881 // if lognormal or shifted lognormal,
7982 // for strike at -shift, return option price even if outside
8083 // minstrike, maxstrike interval
@@ -88,28 +91,32 @@ namespace QuantLib {
8891 Real SmileSection::digitalOptionPrice (Rate strike,
8992 Option::Type type,
9093 Real discount,
91- Real gap) const {
94+ Real gap,
95+ Real forward) const {
9296 Real m = volatilityType () == ShiftedLognormal ? Real (-shift ()) : -QL_MAX_REAL;
9397 Real kl = std::max (strike-gap/2.0 ,m);
9498 Real kr = kl+gap;
9599 return (type==Option::Call ? 1.0 : -1.0 ) *
96- (optionPrice (kl,type,discount)-optionPrice (kr,type,discount)) / gap;
100+ (optionPrice (kl,type,discount,forward )-optionPrice (kr,type,discount,forward )) / gap;
97101 }
98102
99- Real SmileSection::density (Rate strike, Real discount, Real gap) const {
103+ Real SmileSection::density (Rate strike, Real discount, Real gap,
104+ Real forward) const {
100105 Real m = volatilityType () == ShiftedLognormal ? Real (-shift ()) : -QL_MAX_REAL;
101106 Real kl = std::max (strike-gap/2.0 ,m);
102107 Real kr = kl+gap;
103- return (digitalOptionPrice (kl,Option::Call,discount,gap) -
104- digitalOptionPrice (kr,Option::Call,discount,gap)) / gap;
108+ return (digitalOptionPrice (kl,Option::Call,discount,gap,forward ) -
109+ digitalOptionPrice (kr,Option::Call,discount,gap,forward )) / gap;
105110 }
106111
107- Real SmileSection::vega (Rate strike, Real discount) const {
108- Real atm = atmLevel ();
112+ Real SmileSection::vega (Rate strike, Real discount,
113+ Real forward) const {
114+ Real atm = forward != Null<Real>() ? forward : atmLevel ();
109115 QL_REQUIRE (atm != Null<Real>(),
110- " smile section must provide atm level to compute option vega" );
116+ " smile section must provide atm level "
117+ " or forward must be passed to compute option vega" );
111118 if (volatilityType () == ShiftedLognormal)
112- return blackFormulaVolDerivative (strike,atmLevel () ,
119+ return blackFormulaVolDerivative (strike,atm ,
113120 sqrt (variance (strike)),
114121 exerciseTime (),discount,shift ())*0.01 ;
115122 else
0 commit comments