Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yoycapfloor.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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
23
24#include <boost/make_shared.hpp>
25
26namespace ore {
27namespace data {
28
29QuantLib::ext::shared_ptr<PricingEngine> YoYCapFloorEngineBuilder::engineImpl(const string& indexName) {
30 Handle<YoYInflationIndex> yoyTs = market_->yoyInflationIndex(indexName, configuration(MarketContext::pricing));
31 Handle<YieldTermStructure> discount =
32 market_->discountCurve(yoyTs->currency().code(), configuration(MarketContext::pricing));
33 Handle<QuantExt::YoYOptionletVolatilitySurface> ovs =
34 market_->yoyCapFloorVol(indexName, configuration(MarketContext::pricing));
35 if (ovs.empty())
36 return QuantLib::ext::make_shared<QuantExt::YoYInflationBlackCapFloorEngine>(
37 *yoyTs, Handle<QuantLib::YoYOptionletVolatilitySurface>(), discount);
38 switch (ovs->volatilityType()) {
39 case ShiftedLognormal:
40 if (ovs->displacement() == 0.0) {
41 LOG("Build YoYInflationBlackCapFloorEngine for inflation index " << indexName);
42 return QuantLib::ext::make_shared<QuantExt::YoYInflationBlackCapFloorEngine>(
43 *yoyTs, Handle<QuantLib::YoYOptionletVolatilitySurface>(ovs), discount);
44 break;
45 } else {
46 LOG("Build YoYInflationUnitDisplacedBlackCapFloorEngine for inflation index " << indexName);
47 return QuantLib::ext::make_shared<QuantExt::YoYInflationUnitDisplacedBlackCapFloorEngine>(
48 *yoyTs, Handle<QuantLib::YoYOptionletVolatilitySurface>(ovs), discount);
49 break;
50 }
51 case Normal:
52 LOG("Build YoYInflationBachelierCapFloorEngine for inflation index " << indexName);
53 return QuantLib::ext::make_shared<QuantExt::YoYInflationBachelierCapFloorEngine>(
54 *yoyTs, Handle<QuantLib::YoYOptionletVolatilitySurface>(ovs), discount);
55 break;
56 default:
57 QL_FAIL("Caplet volatility type, " << ovs->volatilityType() << ", not covered in EngineFactory");
58 return nullptr; // avoid gcc warning
59 break;
60 }
61}
62} // namespace data
63} // namespace ore
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &indexName) override
Definition: yoycapfloor.cpp:29
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Engine builder for year-on-year inflation caps/floors.