Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
capfloorediborleg.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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#include <ql/termstructures/volatility/optionlet/constantoptionletvol.hpp>
22
23#include <boost/make_shared.hpp>
24
25namespace ore {
26namespace data {
27
28QuantLib::ext::shared_ptr<FloatingRateCouponPricer> CapFlooredIborLegEngineBuilder::engineImpl(const std::string& index) {
29
30 std::string ccyCode = parseIborIndex(index)->currency().code();
31 Handle<YieldTermStructure> yts = market_->discountCurve(ccyCode, configuration(MarketContext::pricing));
32 Handle<OptionletVolatilityStructure> ovs;
33 if (parseBool(engineParameter("ZeroVolatility", {}, false, "false"))) {
34 ovs = Handle<OptionletVolatilityStructure>(QuantLib::ext::make_shared<ConstantOptionletVolatility>(
35 0, NullCalendar(), Unadjusted, 0.0, Actual365Fixed(), Normal));
36 } else {
37 ovs = market_->capFloorVol(index, configuration(MarketContext::pricing));
38 }
39 BlackIborCouponPricer::TimingAdjustment timingAdjustment = BlackIborCouponPricer::Black76;
40 QuantLib::ext::shared_ptr<SimpleQuote> correlation = QuantLib::ext::make_shared<SimpleQuote>(1.0);
41 // for backwards compatibility we do not require the additional timing adjustment fields
42 if (engineParameters_.find("TimingAdjustment") != engineParameters_.end()) {
43 string adjStr = engineParameter("TimingAdjustment");
44 if (adjStr == "Black76")
45 timingAdjustment = BlackIborCouponPricer::Black76;
46 else if (adjStr == "BivariateLognormal")
47 timingAdjustment = BlackIborCouponPricer::BivariateLognormal;
48 else {
49 QL_FAIL("timing adjustment parameter (" << adjStr << ") not recognised.");
50 }
51 correlation->setValue(parseReal(engineParameter("Correlation")));
52 }
53 return QuantLib::ext::make_shared<BlackIborCouponPricer>(ovs, timingAdjustment, Handle<Quote>(correlation));
54}
55
56} // namespace data
57} // namespace ore
builder that returns an engine to price capped floored ibor legs
QuantLib::ext::shared_ptr< FloatingRateCouponPricer > engineImpl(const string &index) override
QuantLib::ext::shared_ptr< Market > market_
map< string, string > engineParameters_
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< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
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
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23