Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
optiondata.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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 ored/portfolio/optiondata.hpp
20 \brief trade option data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
30
31#include <ql/cashflow.hpp>
32#include <ql/exercise.hpp>
33#include <ql/time/date.hpp>
34
35namespace ore {
36namespace data {
37
38//! Serializable object holding option data
39/*!
40 \ingroup tradedata
41*/
43public:
44 //! Default constructor
46 //! Constructor
47 OptionData(string longShort, string callPut, string style, bool payoffAtExpiry, vector<string> exerciseDates,
48 string settlement = "Cash", string settlementMethod = "", const PremiumData& premiumData = {},
49 vector<double> exerciseFees = vector<Real>(), vector<double> exercisePrices = vector<Real>(),
50 string noticePeriod = "", string noticeCalendar = "", string noticeConvention = "",
51 const vector<string>& exerciseFeeDates = vector<string>(),
52 const vector<string>& exerciseFeeTypes = vector<string>(), string exerciseFeeSettlementPeriod = "",
54 string payoffType = "", string payoffType2 = "",
55 const boost::optional<bool>& automaticExercise = boost::none,
56 const boost::optional<OptionExerciseData>& exerciseData = boost::none,
57 const boost::optional<OptionPaymentData>& paymentData = boost::none)
67
68 //! \name Inspectors
69 //@{
70 const string& longShort() const { return longShort_; }
71 const string& callPut() const { return callPut_; }
72 const string& payoffType() const { return payoffType_; }
73 const string& payoffType2() const { return payoffType2_; }
74 const string& style() const { return style_; }
75 const bool& payoffAtExpiry() const { return payoffAtExpiry_; }
76 const vector<string>& exerciseDates() const { return exerciseDates_; }
78 const string& noticePeriod() const { return noticePeriod_; }
79 const string& noticeCalendar() const { return noticeCalendar_; }
80 const string& noticeConvention() const { return noticeConvention_; }
81 const string& settlement() const { return settlement_; }
82 const string& settlementMethod() const { return settlementMethod_; }
83 const PremiumData& premiumData() const { return premiumData_; }
84 const vector<double>& exerciseFees() const { return exerciseFees_; }
85 const vector<string>& exerciseFeeDates() const { return exerciseFeeDates_; }
86 const vector<string>& exerciseFeeTypes() const { return exerciseFeeTypes_; }
90 const vector<double>& exercisePrices() const { return exercisePrices_; }
91 boost::optional<bool> automaticExercise() const { return automaticExercise_; }
92 const boost::optional<OptionExerciseData>& exerciseData() const { return exerciseData_; }
93 const boost::optional<OptionPaymentData>& paymentData() const { return paymentData_; }
94 //@}
95
96 //! \name Setters
97 //@{
98 void setExerciseDates(const std::vector<std::string>& exerciseDates) { exerciseDates_ = exerciseDates; }
102 void setCallPut(const string& callPut) { callPut_ = callPut; }
103 void setLongShort(const std::string& longShort) { longShort_ = longShort; }
104 void setStyle(const std::string& style) { style_ = style; }
107 void setSettlement(const std::string& settlement) { settlement_ = settlement; }
108 //@}
109
110 //! \name Serialisation
111 //@{
112 virtual void fromXML(XMLNode* node) override;
113 virtual XMLNode* toXML(XMLDocument& doc) const override;
114 //@}
115
116 //! Automatic exercise assumed false if not explicitly provided.
118
119private:
120 string longShort_; // long or short
121 string callPut_; // call or put
122 string payoffType_; // Accumulator, Decumulator, TargetExact, TargetFull, TargetTruncated, Asian, AveragePrice ...
123 string payoffType2_; // Geometric, Arithmetic
124 string style_; // European, Bermudan, American
125 bool payoffAtExpiry_; // Y or N
127 vector<string> exerciseDates_;
131 string settlement_; // Cash or Physical, default Cash.
132 string settlementMethod_; // QuantLib::Settlement::Method, default empty
134 vector<double> exerciseFees_;
135 vector<string> exerciseFeeDates_;
136 vector<string> exerciseFeeTypes_;
140 vector<double> exercisePrices_;
141 boost::optional<bool> automaticExercise_;
142 boost::optional<OptionExerciseData> exerciseData_;
143 boost::optional<OptionPaymentData> paymentData_;
144};
145
146// Helper class to build an exercise instance for Bermudan swaptions and related instruments from given option data.
147
149public:
150 /*! TODO removeNoticeDatesAfterLastAccrualStart is only there for backwards compatibility, we should remove it at
151 some point and handle such notice dates in the callling code as appropriate. If the exercise style is American
152 the flag is set to false always internally. */
153 ExerciseBuilder(const OptionData& optionData, const std::vector<QuantLib::Leg> legs,
154 bool removeNoticeDatesAfterLastAccrualStart = true);
155
156 // null if exercsied or no alive exercise dates
157 QuantLib::ext::shared_ptr<QuantLib::Exercise> exercise() const { return exercise_; }
158 // exercise dates associated to alive notice dates, for American style -> only start, end exercise date
159 const std::vector<QuantLib::Date>& exerciseDates() const { return exerciseDates_; }
160 /* alive notice dates (w.r.t. global eval date), for American style -> only start, end notice date */
161 const std::vector<QuantLib::Date>& noticeDates() const { return noticeDates_; }
162
163 // true if exercised
164 bool isExercised() const { return isExercised_; }
165 // only for exercised option: The applicable exercise date
166 const QuantLib::Date& exerciseDate() const { return exerciseDate_; }
167 // only for exercised options: cash settlement amount or null
168 QuantLib::ext::shared_ptr<QuantLib::CashFlow> cashSettlement() const { return cashSettlement_; }
169 // only for exercised options: exercise fee amount or null
170 QuantLib::ext::shared_ptr<QuantLib::CashFlow> feeSettlement() const { return feeSettlement_; }
171
172private:
173 QuantLib::ext::shared_ptr<QuantLib::Exercise> exercise_;
174
175 std::vector<QuantLib::Date> exerciseDates_;
176 std::vector<QuantLib::Date> noticeDates_;
177
178 bool isExercised_ = false;
179 QuantLib::Date exerciseDate_;
180 QuantLib::ext::shared_ptr<QuantLib::CashFlow> cashSettlement_;
181 QuantLib::ext::shared_ptr<QuantLib::CashFlow> feeSettlement_;
182
183 // index in all exercise date vector if exercised
184 Size exerciseDateIndex_ = QuantLib::Null<QuantLib::Size>();
185};
186
187} // namespace data
188} // namespace ore
const std::vector< QuantLib::Date > & exerciseDates() const
Definition: optiondata.hpp:159
const QuantLib::Date & exerciseDate() const
Definition: optiondata.hpp:166
QuantLib::ext::shared_ptr< QuantLib::Exercise > exercise() const
Definition: optiondata.hpp:157
QuantLib::Date exerciseDate_
Definition: optiondata.hpp:179
QuantLib::ext::shared_ptr< QuantLib::Exercise > exercise_
Definition: optiondata.hpp:173
QuantLib::ext::shared_ptr< QuantLib::CashFlow > cashSettlement() const
Definition: optiondata.hpp:168
const std::vector< QuantLib::Date > & noticeDates() const
Definition: optiondata.hpp:161
QuantLib::ext::shared_ptr< QuantLib::CashFlow > feeSettlement() const
Definition: optiondata.hpp:170
std::vector< QuantLib::Date > noticeDates_
Definition: optiondata.hpp:176
QuantLib::ext::shared_ptr< QuantLib::CashFlow > feeSettlement_
Definition: optiondata.hpp:181
QuantLib::ext::shared_ptr< QuantLib::CashFlow > cashSettlement_
Definition: optiondata.hpp:180
std::vector< QuantLib::Date > exerciseDates_
Definition: optiondata.hpp:175
Serializable object holding option data.
Definition: optiondata.hpp:42
vector< string > exerciseFeeDates_
Definition: optiondata.hpp:135
void setPaymentData(const OptionPaymentData &paymentData)
Definition: optiondata.hpp:101
string exerciseFeeSettlementPeriod_
Definition: optiondata.hpp:137
const string & exerciseFeeSettlementPeriod() const
Definition: optiondata.hpp:87
void setAutomaticExercise(bool automaticExercise)
Definition: optiondata.hpp:100
const string & settlementMethod() const
Definition: optiondata.hpp:82
const string & callPut() const
Definition: optiondata.hpp:71
boost::optional< OptionPaymentData > paymentData_
Definition: optiondata.hpp:143
boost::optional< OptionExerciseData > exerciseData_
Definition: optiondata.hpp:142
boost::optional< bool > automaticExercise() const
Definition: optiondata.hpp:91
const string & payoffType2() const
Definition: optiondata.hpp:73
void setExerciseDates(const std::vector< std::string > &exerciseDates)
Definition: optiondata.hpp:98
const string & payoffType() const
Definition: optiondata.hpp:72
const string & noticeConvention() const
Definition: optiondata.hpp:80
string exerciseFeeSettlementCalendar_
Definition: optiondata.hpp:138
string exerciseFeeSettlementConvention_
Definition: optiondata.hpp:139
void setCallPut(const string &callPut)
Definition: optiondata.hpp:102
const string & longShort() const
Definition: optiondata.hpp:70
const string & exerciseFeeSettlementCalendar() const
Definition: optiondata.hpp:88
const string & style() const
Definition: optiondata.hpp:74
const vector< double > & exercisePrices() const
Definition: optiondata.hpp:90
const string & noticeCalendar() const
Definition: optiondata.hpp:79
const string & settlement() const
Definition: optiondata.hpp:81
virtual void fromXML(XMLNode *node) override
Definition: optiondata.cpp:32
vector< string > exerciseFeeTypes_
Definition: optiondata.hpp:136
void setPayoffAtExpiry(const bool payoffAtExpiry)
Definition: optiondata.hpp:105
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: optiondata.cpp:86
void setLongShort(const std::string &longShort)
Definition: optiondata.hpp:103
const vector< string > & exerciseFeeTypes() const
Definition: optiondata.hpp:86
OptionData(string longShort, string callPut, string style, bool payoffAtExpiry, vector< string > exerciseDates, string settlement="Cash", string settlementMethod="", const PremiumData &premiumData={}, vector< double > exerciseFees=vector< Real >(), vector< double > exercisePrices=vector< Real >(), string noticePeriod="", string noticeCalendar="", string noticeConvention="", const vector< string > &exerciseFeeDates=vector< string >(), const vector< string > &exerciseFeeTypes=vector< string >(), string exerciseFeeSettlementPeriod="", string exerciseFeeSettlementCalendar="", string exerciseFeeSettlementConvention="", string payoffType="", string payoffType2="", const boost::optional< bool > &automaticExercise=boost::none, const boost::optional< OptionExerciseData > &exerciseData=boost::none, const boost::optional< OptionPaymentData > &paymentData=boost::none)
Constructor.
Definition: optiondata.hpp:47
void setExerciseDates(const ScheduleData &exerciseDatesSchedule)
Definition: optiondata.hpp:99
void setNoticePeriod(const std::string &noticePeriod)
Definition: optiondata.hpp:106
boost::optional< bool > automaticExercise_
Definition: optiondata.hpp:141
const ScheduleData & exerciseDatesSchedule() const
Definition: optiondata.hpp:77
const bool & payoffAtExpiry() const
Definition: optiondata.hpp:75
bool isAutomaticExercise() const
Automatic exercise assumed false if not explicitly provided.
Definition: optiondata.hpp:117
const boost::optional< OptionPaymentData > & paymentData() const
Definition: optiondata.hpp:93
const boost::optional< OptionExerciseData > & exerciseData() const
Definition: optiondata.hpp:92
vector< string > exerciseDates_
Definition: optiondata.hpp:127
OptionData()
Default constructor.
Definition: optiondata.hpp:45
const vector< string > & exerciseFeeDates() const
Definition: optiondata.hpp:85
PremiumData premiumData_
Definition: optiondata.hpp:133
void setStyle(const std::string &style)
Definition: optiondata.hpp:104
const PremiumData & premiumData() const
Definition: optiondata.hpp:83
ScheduleData exerciseDatesSchedule_
Definition: optiondata.hpp:126
vector< double > exercisePrices_
Definition: optiondata.hpp:140
const string & exerciseFeeSettlementConvention() const
Definition: optiondata.hpp:89
const vector< double > & exerciseFees() const
Definition: optiondata.hpp:84
void setSettlement(const std::string &settlement)
Definition: optiondata.hpp:107
const vector< string > & exerciseDates() const
Definition: optiondata.hpp:76
const string & noticePeriod() const
Definition: optiondata.hpp:78
vector< double > exerciseFees_
Definition: optiondata.hpp:134
Serializable object holding premium data.
Definition: premiumdata.hpp:37
Serializable schedule data.
Definition: schedule.hpp:202
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
option exercise data model and serialization
option payment data model and serialization
premium data
trade schedule data model and serialization