Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cpicapfloorhelper.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21#include <ql/quotes/simplequote.hpp>
22
23#include <boost/make_shared.hpp>
24
25namespace QuantExt {
26
27CpiCapFloorHelper::CpiCapFloorHelper(Option::Type type, Real baseCPI, const Date& maturity, const Calendar& fixCalendar,
28 BusinessDayConvention fixConvention, const Calendar& payCalendar,
29 BusinessDayConvention payConvention, Real strike,
30 const Handle<ZeroInflationIndex>& infIndex, const Period& observationLag,
31 Real marketPremium, CPI::InterpolationType observationInterpolation,
32 BlackCalibrationHelper::CalibrationErrorType errorType)
33 : BlackCalibrationHelper(Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0)), errorType),
34 // start date does not really matter ?
35 instrument_(QuantLib::ext::shared_ptr<CPICapFloor>(new CPICapFloor(
36 type, 1.0, Settings::instance().evaluationDate(), baseCPI, maturity, fixCalendar, fixConvention, payCalendar,
37 payConvention, strike, infIndex.currentLink(), observationLag, observationInterpolation))) {
38 QL_REQUIRE(errorType == BlackCalibrationHelper::PriceError ||
39 errorType == BlackCalibrationHelper::RelativePriceError,
40 "CpiCapFloorHelper supports only PriceError and "
41 "RelativePriceError error types");
42 marketValue_ = marketPremium;
43}
44
46 calculate();
47 instrument_->setPricingEngine(engine_);
48 return instrument_->NPV();
49}
50
51Real CpiCapFloorHelper::blackPrice(Volatility) const {
52 calculate();
53 return marketValue_;
54}
55
56} // namespace QuantExt
QuantLib::ext::shared_ptr< PricingEngine > engine_
Definition: cdsoption.cpp:78
Real blackPrice(Volatility volatility) const override
Real modelValue() const override
QuantLib::ext::shared_ptr< CPICapFloor > instrument_
CpiCapFloorHelper(Option::Type type, Real baseCPI, const Date &maturity, const Calendar &fixCalendar, BusinessDayConvention fixConvention, const Calendar &payCalendar, BusinessDayConvention payConvention, Real strike, const Handle< ZeroInflationIndex > &infIndex, const Period &observationLag, Real marketPremium, CPI::InterpolationType observationInterpolation=CPI::AsIndex, BlackCalibrationHelper::CalibrationErrorType errorType=BlackCalibrationHelper::RelativePriceError)
CPI Cap Floor calibration helper.