Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
durationadjustedcms.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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
19/*! \file durationadjustedcms.hpp
20 \brief coupon pricer builder for duration adjusted cms coupons
21 \ingroup builders
22*/
23
25
28
29#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
30
31namespace ore {
32namespace data {
33
34using namespace QuantExt;
35
36QuantLib::ext::shared_ptr<FloatingRateCouponPricer>
38 std::string ccy = key;
39 QuantLib::ext::shared_ptr<IborIndex> index;
40 if (tryParseIborIndex(key, index))
41 ccy = index->currency().code();
42 Real reversion = parseReal(engineParameter("MeanReversion", {key, ccy}, true));
43
44 Handle<Quote> reversionQuote(QuantLib::ext::make_shared<SimpleQuote>(reversion));
45 Handle<SwaptionVolatilityStructure> vol;
46 if (parseBool(engineParameter("ZeroVolatility", {}, false, "false"))) {
47 vol = Handle<SwaptionVolatilityStructure>(QuantLib::ext::make_shared<ConstantSwaptionVolatility>(
48 0, NullCalendar(), Unadjusted, 0.0, Actual365Fixed(), Normal));
49 } else {
50 vol = market_->swaptionVol(key, configuration(MarketContext::pricing));
51 }
52
53 string lowerBoundStr =
54 (vol->volatilityType() == ShiftedLognormal) ? "LowerRateBoundLogNormal" : "LowerRateBoundNormal";
55 string upperBoundStr =
56 (vol->volatilityType() == ShiftedLognormal) ? "UpperRateBoundLogNormal" : "UpperRateBoundNormal";
57
58 Real lower = parseReal(engineParameter(lowerBoundStr));
59 Real upper = parseReal(engineParameter(upperBoundStr));
60
61 return QuantLib::ext::make_shared<DurationAdjustedCmsCouponTsrPricer>(
62 vol, QuantLib::ext::make_shared<LinearAnnuityMappingBuilder>(reversionQuote), lower, upper);
63};
64
65} // namespace data
66} // namespace ore
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)
QuantLib::ext::shared_ptr< FloatingRateCouponPricer > engineImpl(const string &key) override
coupon pricer builder for duration adjusted cms coupons
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23