Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
capflooredaverageonindexedcouponleg.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
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 Handle<OptionletVolatilityStructure> ovs = market_->capFloorVol(index, configuration(MarketContext::pricing));
37
38 /* if we are pricing an overnight index coupon with rate computation period different from the one on which the
39 market vol surface is based, we apply a moneyness adjustment accounting for this difference */
40 auto [volIndex, volRateComputationPeriod] =
41 market_->capFloorVolIndexBase(index, configuration(MarketContext::pricing));
42 if (volIndex == index && volRateComputationPeriod != rateComputationPeriod &&
43 volRateComputationPeriod != 0 * Days && rateComputationPeriod != 0 * Days) {
44 ovs = Handle<OptionletVolatilityStructure>(QuantLib::ext::make_shared<QuantExt::ProxyOptionletVolatility>(
45 ovs, *market_->iborIndex(volIndex, configuration(MarketContext::pricing)),
46 *market_->iborIndex(index, configuration(MarketContext::pricing)), volRateComputationPeriod,
47 rateComputationPeriod));
48 }
49
50 return QuantLib::ext::make_shared<QuantExt::BlackAverageONIndexedCouponPricer>(ovs);
51}
52
54 const QuantLib::Period& rateComputationPeriod) {
55 return index + "_" + ore::data::to_string(rateComputationPeriod);
56}
57
58} // namespace data
59} // namespace ore
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