Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
capflooredovernightindexedcouponleg.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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
22
25
26#include <boost/make_shared.hpp>
27
28namespace ore {
29namespace data {
30
31QuantLib::ext::shared_ptr<FloatingRateCouponPricer>
33 const QuantLib::Period& rateComputationPeriod) {
34 std::string ccyCode = parseIborIndex(index)->currency().code();
35 Handle<YieldTermStructure> yts = market_->discountCurve(ccyCode, configuration(MarketContext::pricing));
36 QL_REQUIRE(!yts.empty(), "engineFactory error: yield term structure not found for currency " << ccyCode);
37 Handle<OptionletVolatilityStructure> ovs = market_->capFloorVol(index, configuration(MarketContext::pricing));
38
39 /* if we are pricing an overnight index coupon with rate computation period different from the one on which the
40 market vol surface is based, we apply a moneyness adjustment accounting for this difference */
41 auto [volIndex, volRateComputationPeriod] =
42 market_->capFloorVolIndexBase(index, configuration(MarketContext::pricing));
43 if (volIndex == index && volRateComputationPeriod != rateComputationPeriod &&
44 volRateComputationPeriod != 0 * Days && rateComputationPeriod != 0 * Days) {
45 ovs = Handle<OptionletVolatilityStructure>(QuantLib::ext::make_shared<QuantExt::ProxyOptionletVolatility>(
46 ovs, *market_->iborIndex(volIndex, configuration(MarketContext::pricing)),
47 *market_->iborIndex(index, configuration(MarketContext::pricing)), volRateComputationPeriod,
48 rateComputationPeriod));
49 }
50
51 return QuantLib::ext::make_shared<QuantExt::BlackOvernightIndexedCouponPricer>(ovs);
52}
53
55 const QuantLib::Period& rateComputationPeriod) {
56 return index + "_" + ore::data::to_string(rateComputationPeriod);
57}
58
59} // namespace data
60} // namespace ore
builder that returns an engine to price capped floored ibor legs
QuantLib::ext::shared_ptr< FloatingRateCouponPricer > engineImpl(const string &index, const QuantLib::Period &rateComputationPeriod) override
string keyImpl(const string &index, const QuantLib::Period &rateComputationPeriod) override
QuantLib::ext::shared_ptr< Market > market_
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.
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string conversion utilities