Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cpicapfloor.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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
21
25#include <boost/make_shared.hpp>
26
27namespace ore {
28namespace data {
29
30QuantLib::ext::shared_ptr<PricingEngine> CpiCapFloorEngineBuilder::engineImpl(const string& indexName) {
31 Handle<ZeroInflationIndex> cpiIndex = market_->zeroInflationIndex(indexName, configuration(MarketContext::pricing));
32 // QL_REQUIRE(!cpiIndex.empty(), "engineFactory error, cpi index " << indexName << " not found");
33 std::string ccyCode = cpiIndex->currency().code();
34 Handle<YieldTermStructure> discountCurve = market_->discountCurve(ccyCode, configuration(MarketContext::pricing));
35 Handle<QuantLib::CPIVolatilitySurface> ovs =
36 market_->cpiInflationCapFloorVolatilitySurface(indexName, configuration(MarketContext::pricing));
37 // QL_REQUIRE(!ovs.empty(),
38 // "engineFactory error: cpi cap/floor vol surface for index " << indexName << " not found");
39 bool useLastFixingDate =
40 parseBool(engineParameter("useLastFixingDate", std::vector<std::string>(), false, "false"));
41
42 bool isLogNormal = QuantExt::ZeroInflation::isCPIVolSurfaceLogNormal(ovs.currentLink());
43
44 if (isLogNormal) {
45 return QuantLib::ext::make_shared<QuantExt::CPIBlackCapFloorEngine>(discountCurve, ovs, useLastFixingDate);
46 } else {
47 return QuantLib::ext::make_shared<QuantExt::CPIBachelierCapFloorEngine>(discountCurve, ovs, useLastFixingDate);
48 }
49
50}
51} // namespace data
52} // namespace ore
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &indexName) override
Definition: cpicapfloor.cpp:30
QuantLib::ext::shared_ptr< Market > market_
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
bool isCPIVolSurfaceLogNormal(const boost::shared_ptr< QuantLib::CPIVolatilitySurface > &surface)
Serializable Credit Default Swap.
Definition: namespaces.docs:23
builder that returns an engine to price a CPI cap or floor