Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
mcgaussianformulabasedcouponpricer.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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 qle/cashflows/mcgaussianformulabasedcouponpricer.hpp
20 \brief formula based coupon pricer
21 \ingroup cashflows
22*/
23
24#pragma once
25
27
28#include <ql/math/matrixutilities/pseudosqrt.hpp>
29
31
32namespace QuantExt {
33using namespace QuantLib;
34
35//! Formula based coupon pricer
36/*! - we assume a generalised version of the model in QuantLib::LognormalCmsSpreadPricer
37 - TODO possibly we want to add a cache similar to LognormalCmsSpreadPricer?
38*/
39
41public:
42 /*! ibor pricers and cms pricers must be given by (index) currency codes, fx vols must be given by index currency
43 codes (if not equal to payment currency), these must all be vs. payment currency; correlations must be given by
44 pairs of index names, resp. by a pair of an index name and the special string "FX" indicating the correlation
45 of the index rate and the the FX rate "index ccy vs. payment currency" for the quanto adjustemnts;
46 missing correlations in the given map are assumed to be zero; the coupon discount curve must be in payment ccy
47
48 Warning: The given fx vol structures must return the atm vol if a strike = Null<Real>() is passed to them. */
49
51 const std::string& paymentCurrencyCode,
52 const std::map<std::string, QuantLib::ext::shared_ptr<IborCouponPricer>>& iborPricers,
53 const std::map<std::string, QuantLib::ext::shared_ptr<CmsCouponPricer>>& cmsPricers,
54 const std::map<std::string, Handle<BlackVolTermStructure>>& fxVolatilities,
55 const std::map<std::pair<std::string, std::string>, Handle<QuantExt::CorrelationTermStructure>>& correlation,
56 const Handle<YieldTermStructure>& couponDiscountCurve, const Size samples = 10000, const Size seed = 42,
57 const bool useSobol = true, SalvagingAlgorithm::Type salvaging = SalvagingAlgorithm::None);
58 /* */
59 virtual Real swapletPrice() const override;
60 virtual Rate swapletRate() const override;
61 virtual Real capletPrice(Rate effectiveCap) const override;
62 virtual Rate capletRate(Rate effectiveCap) const override;
63 virtual Real floorletPrice(Rate effectiveFloor) const override;
64 virtual Rate floorletRate(Rate effectiveFloor) const override;
65 /* */
66
67private:
68 void initialize(const FloatingRateCoupon& coupon) override;
69 //
70 void compute() const;
71 //
72 const std::map<std::string, QuantLib::ext::shared_ptr<IborCouponPricer>> iborPricers_;
73 const std::map<std::string, QuantLib::ext::shared_ptr<CmsCouponPricer>> cmsPricers_;
74 const Handle<YieldTermStructure> couponDiscountCurve_;
75 const Size samples_, seed_;
76 const bool useSobol_;
77 const SalvagingAlgorithm::Type salvaging_;
78 //
79 Size n_;
82 QuantLib::ext::shared_ptr<FormulaBasedIndex> index_;
84 //
85 std::vector<VolatilityType> volType_;
86 std::vector<Real> volShift_, atmRate_;
87 Array mean_;
89 //
90 mutable Real rateEstimate_;
91};
92
93} // namespace QuantExt
formula based coupon class
base pricer for formula based coupons
virtual Real capletPrice(Rate effectiveCap) const override
virtual Rate floorletRate(Rate effectiveFloor) const override
const std::map< std::string, QuantLib::ext::shared_ptr< CmsCouponPricer > > cmsPricers_
const std::map< std::string, QuantLib::ext::shared_ptr< IborCouponPricer > > iborPricers_
void initialize(const FloatingRateCoupon &coupon) override
QuantLib::ext::shared_ptr< FormulaBasedIndex > index_
virtual Real floorletPrice(Rate effectiveFloor) const override
virtual Rate capletRate(Rate effectiveCap) const override
Term structure of correlations.
formula based coupon