Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
capflooredyoyleg.hpp
Go to the documentation of this file.
1/*
2Copyright (C) 2019 Quaternion Risk Management Ltd
3All rights reserved.
4
5This file is part of ORE, a free-software/open-source library
6for transparent pricing and risk analysis - http://opensourcerisk.org
7
8ORE is free software: you can redistribute it and/or modify it
9under the terms of the Modified BSD License. You should have received a
10copy of the license along with this program.
11The license is also available online at <http://opensourcerisk.org>
12
13This program is distributed on the basis that it will form a useful
14contribution to risk analytics and model standardisation, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/portfolio/builders/capflooredyoyleg.hpp
20\brief builder that returns an engine to price capped floored yoy inflation legs
21\ingroup builders
22*/
23
24#pragma once
25
28#include <ql/cashflows/couponpricer.hpp>
29#include <ql/cashflows/inflationcouponpricer.hpp>
30#include <ql/indexes/inflationindex.hpp>
31#include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp>
32
33namespace ore {
34namespace data {
35//! CouponPricer Builder for Capped/Floored YoY Inflation Leg
36/*! The coupon pricers are cached by index name
37\ingroup builders
38*/
40public:
42 : CachingEngineBuilder("CapFlooredYYModel", "CapFlooredYYCouponPricer", {"CapFlooredYYLeg"}) {}
43
44protected:
45 virtual string keyImpl(const string& indexName) override { return indexName; }
46 virtual QuantLib::ext::shared_ptr<QuantLib::InflationCouponPricer> engineImpl(const string& indexName) override {
47 QuantLib::ext::shared_ptr<YoYOptionletVolatilitySurface> vol =
48 market_->yoyCapFloorVol(indexName, configuration(MarketContext::pricing)).currentLink();
49 Handle<YoYInflationIndex> index = market_->yoyInflationIndex(indexName, configuration(MarketContext::pricing));
50 Handle<YieldTermStructure> yts = market_->discountCurve(index->currency().code());
51 if (vol->volatilityType() == VolatilityType::ShiftedLognormal && vol->displacement() == 0.0)
52 return QuantLib::ext::make_shared<BlackYoYInflationCouponPricer>(Handle<YoYOptionletVolatilitySurface>(vol), yts);
53 else if (vol->volatilityType() == VolatilityType::ShiftedLognormal && vol->displacement() != 0.0)
54 return QuantLib::ext::make_shared<UnitDisplacedBlackYoYInflationCouponPricer>(
55 Handle<YoYOptionletVolatilitySurface>(vol), yts);
56 else if (vol->volatilityType() == VolatilityType::Normal)
57 return QuantLib::ext::make_shared<BachelierYoYInflationCouponPricer>(Handle<YoYOptionletVolatilitySurface>(vol),
58 yts);
59 else
60 QL_FAIL("Unknown VolatilityType of YoYOptionletVolatilitySurface");
61 }
62};
63} // namespace data
64} // namespace ore
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
CouponPricer Builder for Capped/Floored YoY Inflation Leg.
virtual QuantLib::ext::shared_ptr< QuantLib::InflationCouponPricer > engineImpl(const string &indexName) override
virtual string keyImpl(const string &indexName) override
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Pricing Engine Factory.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23