Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
annuitymapping.hpp
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 annuitymapping.hpp
20 \brief base class for annuity mapping functions used in TSR models
21*/
22
23#pragma once
24
25#include <ql/instruments/vanillaswap.hpp>
26#include <ql/termstructures/yieldtermstructure.hpp>
27#include <ql/time/date.hpp>
28#include <ql/types.hpp>
29
30namespace QuantExt {
31
32using namespace QuantLib;
33
34/*! base class for annuity mapping functions used in TSR models */
36public:
37 virtual ~AnnuityMapping() {}
38
39 /* E^A( P(t,T) / A(t) | S(t) ) */
40 virtual Real map(const Real S) const = 0;
41
42 /* first derivative of map, provides finite difference default implementation */
43 virtual Real mapPrime(const Real S) const;
44
45 /* second derivative of map, provides finite difference default implementation */
46 virtual Real mapPrime2(const Real S) const;
47
48 /* returns true if mapPrime2 == 0 for all arguments */
49 virtual bool mapPrime2IsZero() const = 0;
50
51protected:
52 // step size used for finite difference derivatives
53 double h_ = 1E-6;
54};
55
56/*! base class for annuity mapping builders for use in actual pricers */
57class AnnuityMappingBuilder : public Observable, public Observer {
58public:
60 virtual QuantLib::ext::shared_ptr<AnnuityMapping> build(const Date& valuationDate, const Date& optionDate,
61 const Date& paymentDate, const VanillaSwap& underlying,
62 const Handle<YieldTermStructure>& discountCurve) = 0;
63 void update() override;
64};
65
66} // namespace QuantExt
virtual QuantLib::ext::shared_ptr< AnnuityMapping > build(const Date &valuationDate, const Date &optionDate, const Date &paymentDate, const VanillaSwap &underlying, const Handle< YieldTermStructure > &discountCurve)=0
virtual bool mapPrime2IsZero() const =0
virtual Real map(const Real S) const =0
virtual Real mapPrime2(const Real S) const
virtual Real mapPrime(const Real S) const