Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityapo.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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/instruments/commodityapo.hpp
20 \brief Swaption class
21*/
22
23#ifndef quantext_instruments_commodityapo_hpp
24#define quantext_instruments_commodityapo_hpp
25
26#include <ql/instruments/barriertype.hpp>
27#include <ql/instruments/swaption.hpp>
28#include <ql/option.hpp>
29#include <ql/exercise.hpp>
30#include <ql/termstructures/volatility/volatilitytype.hpp>
31#include <ql/termstructures/yieldtermstructure.hpp>
34
35namespace QuantExt {
36using namespace QuantLib;
37
38//! Commodity Average Price Option
39/*! \ingroup instruments
40 */
41class CommodityAveragePriceOption : public Option {
42public:
43 class arguments;
44 class engine;
45 CommodityAveragePriceOption(const QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow>& flow,
46 const ext::shared_ptr<Exercise>& exercise, const Real quantity, const Real strikePrice,
47 Option::Type type, Settlement::Type delivery = Settlement::Physical,
48 Settlement::Method settlementMethod = Settlement::PhysicalOTC,
49 const Real barrierLevel = Null<Real>(),
50 Barrier::Type barrierType = Barrier::Type::DownIn,
51 Exercise::Type barrierStyle = Exercise::American,
52 const QuantLib::ext::shared_ptr<FxIndex>& fxIndex= nullptr);
53
54 //! \name Instrument interface
55 //@{
56 bool isExpired() const override;
57 void setupArguments(PricingEngine::arguments*) const override;
58 //@}
59
60 //! \name Inspectors
61 //@{
62 Settlement::Type settlementType() const { return settlementType_; }
63 Settlement::Method settlementMethod() const { return settlementMethod_; }
64 const QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow>& underlyingFlow() const { return flow_; }
65
66 const QuantLib::ext::shared_ptr<FxIndex>& fxIndex() const { return fxIndex_; }
67 Real barrierLevel() const { return barrierLevel_; }
68 Barrier::Type barrierType() const { return barrierType_; }
69 Exercise::Type barrierStyle() const { return barrierStyle_; }
70 Real effectiveStrike() const;
71 Real accrued(const Date& refDate) const;
72 //@}
73
74private:
75 // arguments
76 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> flow_;
79 Option::Type type_;
80 QuantLib::Settlement::Type settlementType_;
81 QuantLib::Settlement::Method settlementMethod_;
82 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
84 Barrier::Type barrierType_;
85 Exercise::Type barrierStyle_;
86};
87
88//! %Arguments for commodity APO calculation
89class CommodityAveragePriceOption::arguments : public Option::arguments {
90public:
91 arguments();
92 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> flow;
95 Real accrued;
97 Option::Type type;
98 QuantLib::ext::shared_ptr<FxIndex> fxIndex;
99 Settlement::Type settlementType;
100 Settlement::Method settlementMethod;
102 Barrier::Type barrierType;
103 Exercise::Type barrierStyle;
104 void validate() const override;
105};
106
107//! base class for APO engines
109 : public GenericEngine<CommodityAveragePriceOption::arguments, CommodityAveragePriceOption::results> {};
110
111} // namespace QuantExt
112
113#endif
Arguments for commodity APO calculation
QuantLib::ext::shared_ptr< FxIndex > fxIndex
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > flow
Commodity Average Price Option.
Real accrued(const Date &refDate) const
QuantLib::Settlement::Type settlementType_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
void setupArguments(PricingEngine::arguments *) const override
Settlement::Type settlementType() const
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > flow_
QuantLib::Settlement::Method settlementMethod_
const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > & underlyingFlow() const
Exercise::Type barrierStyle() const
Settlement::Method settlementMethod() const
Cash flow dependent on the average commodity spot price or future's settlement price over a period....
Cash flow dependent on a single commodity spot price or future's settlement price.