Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
aposurface.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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/termstructures/aposurface.hpp
20 \brief Average future price option surface derived from future option surface
21 \ingroup termstructures
22 */
23
24#ifndef quantext_apo_surface_hpp
25#define quantext_apo_surface_hpp
26
27#include <boost/optional.hpp>
28#include <ql/patterns/lazyobject.hpp>
29#include <ql/quotes/simplequote.hpp>
30#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
36
37namespace QuantExt {
38
39//! Average future price option (APO) surface derived from a future option surface
40class ApoFutureSurface : public QuantLib::LazyObject, public QuantLib::BlackVolatilityTermStructure {
41
42public:
43 ApoFutureSurface(const QuantLib::Date& referenceDate, const std::vector<QuantLib::Real>& moneynessLevels,
44 const QuantLib::ext::shared_ptr<CommodityIndex>& index,
45 const QuantLib::Handle<PriceTermStructure>& pts,
46 const QuantLib::Handle<QuantLib::YieldTermStructure>& yts,
47 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& expCalc,
48 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& baseVts,
49 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseExpCalc, QuantLib::Real beta = 0.0,
50 bool flatStrikeExtrapolation = true,
51 const boost::optional<QuantLib::Period>& maxTenor = boost::none);
52
53 //! \name TermStructure interface
54 //@{
55 QuantLib::Date maxDate() const override;
56 //@}
57
58 //! \name VolatilityTermStructure interface
59 //@{
60 QuantLib::Real minStrike() const override;
61 QuantLib::Real maxStrike() const override;
62
63 //! \name Visitability
64 //@{
65 void accept(QuantLib::AcyclicVisitor& v) override;
66 //@}
67
68 //! \name Observer interface
69 //@{
70 void update() override;
71 //@}
72
73 //! \name LazyObject interface
74 //@{
75 void performCalculations() const override;
76 //@}
77
78 //! \name Inspectors
79 //@{
80 const QuantLib::ext::shared_ptr<BlackVarianceSurfaceMoneyness>& vts() const;
81 //@}
82
83protected:
84 //! \name BlackVolatilityTermStructure
85 //@{
86 QuantLib::Volatility blackVolImpl(QuantLib::Time t, QuantLib::Real strike) const override;
87 //@}
88
89private:
90 QuantLib::ext::shared_ptr<CommodityIndex> index_;
91 QuantLib::ext::shared_ptr<FutureExpiryCalculator> baseExpCalc_;
92
93 //! The APO schedule dates.
94 std::vector<QuantLib::Date> apoDates_;
95
96 //! This will keep a handle on the APO vol quotes that are calculated.
97 std::vector<std::vector<QuantLib::ext::shared_ptr<QuantLib::SimpleQuote> > > vols_;
98
99 //! The surface that is created to do the work.
100 QuantLib::ext::shared_ptr<BlackVarianceSurfaceMoneyness> vts_;
101
102 //! The engine for valuing the APOs
103 QuantLib::ext::shared_ptr<CommodityAveragePriceOptionBaseEngine> apoEngine_;
104};
105
106} // namespace QuantExt
107
108#endif
Black volatility surface based on forward moneyness.
Average future price option (APO) surface derived from a future option surface.
Definition: aposurface.hpp:40
std::vector< std::vector< QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > > > vols_
This will keep a handle on the APO vol quotes that are calculated.
Definition: aposurface.hpp:97
void performCalculations() const override
Definition: aposurface.cpp:131
QuantLib::Volatility blackVolImpl(QuantLib::Time t, QuantLib::Real strike) const override
Definition: aposurface.cpp:186
void accept(QuantLib::AcyclicVisitor &v) override
Definition: aposurface.cpp:119
QuantLib::ext::shared_ptr< BlackVarianceSurfaceMoneyness > vts_
The surface that is created to do the work.
Definition: aposurface.hpp:100
QuantLib::Real minStrike() const override
Definition: aposurface.cpp:115
const QuantLib::ext::shared_ptr< BlackVarianceSurfaceMoneyness > & vts() const
Definition: aposurface.cpp:184
QuantLib::ext::shared_ptr< CommodityIndex > index_
Definition: aposurface.hpp:90
QuantLib::Date maxDate() const override
Definition: aposurface.cpp:113
std::vector< QuantLib::Date > apoDates_
The APO schedule dates.
Definition: aposurface.hpp:94
QuantLib::Real maxStrike() const override
Definition: aposurface.cpp:117
QuantLib::ext::shared_ptr< CommodityAveragePriceOptionBaseEngine > apoEngine_
The engine for valuing the APOs.
Definition: aposurface.hpp:103
QuantLib::ext::shared_ptr< FutureExpiryCalculator > baseExpCalc_
Definition: aposurface.hpp:91
commodity average price option engine
commodity index class for holding commodity spot and futures price histories and forwarding.
Base class for classes that perform date calculations for future contracts.
Term structure of prices.