28 const bool interpolate,
29 const bool exponentialExtrapolation,
30 const bool deleteArbitragePoints,
31 const std::vector<Real>& moneynessGrid,
33 const int forcedLeftIndex,
34 const int forcedRightIndex)
35 :
SmileSection(*source), source_(source), moneynessGrid_(moneynessGrid), gap_(gap),
36 interpolate_(interpolate), exponentialExtrapolation_(exponentialExtrapolation),
37 forcedLeftIndex_(forcedLeftIndex), forcedRightIndex_(forcedRightIndex) {
42 "KahaleSmileSection only supports shifted lognormal source sections");
44 ssutils_ = ext::make_shared<SmileSectionUtils>(
45 *source, moneynessGrid, atm, deleteArbitragePoints);
66 std::pair<Size, Size> afIdx =
ssutils_->arbitragefreeIndices();
70 cFunctions_ = std::vector<ext::shared_ptr<cFunction> >(
90 c1p = (secl + sec) / 2;
102 ext::shared_ptr<cFunction> cFct1(
110 QL_REQUIRE(dig >= -c1p && dig <= 1.0,
"dummy");
124 "can not extrapolate to left, right index of af region reached ("
129 Real cp0 = 0.0, cp1 = 0.0;
140 cp0 =
leftIndex_ > 0 ? (secl + sec) / 2.0 : sec;
145 secr = (
c_[i + 2] -
c_[i + 1]) / (
k_[i + 2] -
k_[i + 1]);
146 cp1 = (sec + secr) / 2.0;
147 aHelper ah(k0, k1, c0, c1, cp0, cp1);
161 k_.erase(
k_.begin() + (i + 1));
162 c_.erase(
c_.begin() + (i + 1));
169 ext::shared_ptr<cFunction> cFct(
189 cp0 = -
source_->digitalOptionPrice(
192 ext::shared_ptr<cFunction> cFct;
196 cFct = ext::make_shared<cFunction>(
197 -cp0 / c0, std::log(c0) - cp0 / c0 * k0);
205 cFct = ext::make_shared<cFunction>(
222 "can not extrapolate to right, left index of af region reached ("
227 Real discount)
const {
232 int i =
index(shifted_strike);
240 return source_->optionPrice(strike, type, discount);
245 int i =
index(shifted_strike);
248 return source_->volatility(strike);
254 type, shifted_strike,
f_,
265 static_cast<int>(std::upper_bound(
k_.begin(),
k_.end(), strike) -
Real shift() const override
Time exerciseTime() const override
const bool exponentialExtrapolation_
std::vector< ext::shared_ptr< cFunction > > cFunctions_
ext::shared_ptr< SmileSectionUtils > ssutils_
ext::shared_ptr< SmileSection > source_
Size index(Rate strike) const
KahaleSmileSection(const ext::shared_ptr< SmileSection > &source, Real atm=Null< Real >(), bool interpolate=false, bool exponentialExtrapolation=false, bool deleteArbitragePoints=false, const std::vector< Real > &moneynessGrid=std::vector< Real >(), Real gap=1.0E-5, int forcedLeftIndex=-1, int forcedRightIndex=QL_MAX_INTEGER)
Real optionPrice(Rate strike, Option::Type type=Option::Call, Real discount=1.0) const override
std::vector< Real > moneynessGrid_
Volatility volatilityImpl(Rate strike) const override
interest rate volatility smile section
virtual Real digitalOptionPrice(Rate strike, Option::Type type=Option::Call, Real discount=1.0, Real gap=1.0e-5) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
Arbitrage free smile section using a C^1 inter- and extrapolation method proposed by Kahale,...
Real blackFormulaImpliedStdDev(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real discount, Real displacement, Real guess, Real accuracy, Natural maxIterations)