Skip to content

Commit a4d28e5

Browse files
author
jenkins
committed
git subrepo pull (merge) ore
subrepo: subdir: "ore" merged: "7c25545a1b" upstream: origin: "git@gitlab.acadiasoft.net:qs/ore.git" branch: "master" commit: "e30d0bd607" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb"
2 parents 20c868a + e30d0bd commit a4d28e5

4 files changed

Lines changed: 56 additions & 13 deletions

File tree

Docs/UserGuide/tradecomponents/optiondata.tex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ \subsubsection{Option Data}
2929
<ExerciseDate>2019-04-20</ExerciseDate>
3030
<ExerciseDate>2020-04-20</ExerciseDate>
3131
</ExerciseDates>
32+
<!-- Alternative format for exercise dates using Schedule format -->
33+
<ExerciseSchedule>
34+
<Rules>
35+
<StartDate>2019-04-20</StartDate>
36+
<EndDate>2024-04-20</EndDate>
37+
<Tenor>3M</Tenor>
38+
</Rules>
39+
</ExerciseSchedule>
3240
<Premiums>
3341
<Premium>
3442
<Amount>100000</Amount>
@@ -195,11 +203,16 @@ \subsubsection{Option Data}
195203
Allowable values: See Table \ref{tab:convention} Roll Convention.
196204
197205
\item ExerciseDates: This node contains child elements of type
198-
\lstinline!ExerciseDate!. Options of style \emph{European} or
206+
\lstinline!ExerciseDate!. Options of style \emph{European} or
199207
\emph{American} require a single exercise date expressed by one
200208
single \lstinline!ExerciseDate! child element. \emph{Bermudan}
201209
style options must have two or more \lstinline!ExerciseDate! child
202-
elements.
210+
elements. One can alternatively use \lstinline!ExerciseSchedule! to
211+
specify the option exercise dates.
212+
213+
\item ExerciseSchedule [Optional]: This node can be provided instead of \lstinline!ExerciseDates! and
214+
should be specified in the same format as a Schedule (see Section \ref{ss:schedule_data}), e.g.\ for
215+
a list of Bermudan exercise dates.
203216
204217
\item Premiums [Optional]: Option premium amounts paid by the option buyer to the option seller.
205218

OREData/ored/portfolio/optiondata.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ void OptionData::fromXML(XMLNode* node) {
5454
exerciseFeeSettlementCalendar_ = XMLUtils::getChildValue(node, "ExerciseFeeSettlementCalendar", false);
5555
exerciseFeeSettlementConvention_ = XMLUtils::getChildValue(node, "ExerciseFeeSettlementConvention", false);
5656
exercisePrices_ = XMLUtils::getChildrenValuesAsDoubles(node, "ExercisePrices", "ExercisePrice", false);
57-
exerciseDates_ = XMLUtils::getChildrenValues(node, "ExerciseDates", "ExerciseDate", false);
57+
58+
XMLNode* exDatesNode = XMLUtils::getChildNode(node, "ExerciseDates");
59+
XMLNode* exScheduleNode = XMLUtils::getChildNode(node, "ExerciseSchedule");
60+
QL_REQUIRE(!(exDatesNode && exScheduleNode),
61+
"Cannot specify both ExerciseDates and ExerciseSchedule. Only one must be used.");
62+
if (exDatesNode) {
63+
exerciseDates_ = XMLUtils::getChildrenValues(node, "ExerciseDates", "ExerciseDate");
64+
}
65+
if (exScheduleNode) {
66+
exerciseDatesSchedule_.fromXML(exScheduleNode);
67+
}
5868

5969
automaticExercise_ = boost::none;
6070
if (XMLNode* n = XMLUtils::getChildNode(node, "AutomaticExercise"))
@@ -104,7 +114,14 @@ XMLNode* OptionData::toXML(XMLDocument& doc) {
104114
if (exerciseFeeSettlementConvention_ != "")
105115
XMLUtils::addChild(doc, node, "ExerciseFeeSettlementConvention", exerciseFeeSettlementConvention_);
106116
XMLUtils::addChildren(doc, node, "ExercisePrices", "ExercisePrice", exercisePrices_);
107-
XMLUtils::addChildren(doc, node, "ExerciseDates", "ExerciseDate", exerciseDates_);
117+
118+
if (exerciseDatesSchedule_.hasData()) {
119+
XMLNode* scheduleDataNode = exerciseDatesSchedule_.toXML(doc);
120+
XMLUtils::setNodeName(doc, scheduleDataNode, "ExerciseSchedule");
121+
XMLUtils::appendNode(node, scheduleDataNode);
122+
} else {
123+
XMLUtils::addChildren(doc, node, "ExerciseDates", "ExerciseDate", exerciseDates_);
124+
}
108125

109126
if (automaticExercise_)
110127
XMLUtils::addChild(doc, node, "AutomaticExercise", *automaticExercise_);
@@ -146,8 +163,14 @@ ExerciseBuilder::ExerciseBuilder(const OptionData& optionData, const std::vector
146163
// build vector of sorted exercise dates
147164

148165
std::vector<QuantLib::Date> sortedExerciseDates;
149-
for (auto const& d : optionData.exerciseDates())
150-
sortedExerciseDates.push_back(parseDate(d));
166+
if (optionData.exerciseDatesSchedule().hasData()) {
167+
Schedule schedule = makeSchedule(optionData.exerciseDatesSchedule());
168+
sortedExerciseDates = schedule.dates();
169+
} else {
170+
// For backward compatibility
171+
for (auto const& d : optionData.exerciseDates())
172+
sortedExerciseDates.push_back(parseDate(d));
173+
}
151174
std::sort(sortedExerciseDates.begin(), sortedExerciseDates.end());
152175

153176
// build vector of alive exercise dates and corresponding native dates

OREData/ored/portfolio/optiondata.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class OptionData : public XMLSerializable {
7474
const string& style() const { return style_; }
7575
const bool& payoffAtExpiry() const { return payoffAtExpiry_; }
7676
const vector<string>& exerciseDates() const { return exerciseDates_; }
77+
const ScheduleData& exerciseDatesSchedule() const { return exerciseDatesSchedule_; }
7778
const string& noticePeriod() const { return noticePeriod_; }
7879
const string& noticeCalendar() const { return noticeCalendar_; }
7980
const string& noticeConvention() const { return noticeConvention_; }
@@ -95,6 +96,7 @@ class OptionData : public XMLSerializable {
9596
//! \name Setters
9697
//@{
9798
void setExerciseDates(const std::vector<std::string>& exerciseDates) { exerciseDates_ = exerciseDates; }
99+
void setExerciseDates(const ScheduleData& exerciseDatesSchedule) { exerciseDatesSchedule_ = exerciseDatesSchedule; }
98100
void setAutomaticExercise(bool automaticExercise) { automaticExercise_ = automaticExercise; }
99101
void setPaymentData(const OptionPaymentData& paymentData) { paymentData_ = paymentData; }
100102
void setCallPut(const string& callPut) { callPut_ = callPut; }
@@ -121,6 +123,7 @@ class OptionData : public XMLSerializable {
121123
string payoffType2_; // Geometric, Arithmetic
122124
string style_; // European, Bermudan, American
123125
bool payoffAtExpiry_; // Y or N
126+
ScheduleData exerciseDatesSchedule_;
124127
vector<string> exerciseDates_;
125128
string noticePeriod_;
126129
string noticeCalendar_;

xsd/instruments.xsd

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,7 @@
317317
<xs:element type="xs:string" name="ExerciseFeeSettlementPeriod" minOccurs="0"/>
318318
<xs:element type="xs:string" name="ExerciseFeeSettlementCalendar" minOccurs="0"/>
319319
<xs:element type="xs:string" name="ExerciseFeeSettlementConvention" minOccurs="0"/>
320-
<xs:element name="ExerciseDates" minOccurs="0">
321-
<xs:complexType>
322-
<xs:sequence>
323-
<xs:element type="date" name="ExerciseDate" minOccurs="0" maxOccurs="unbounded"/>
324-
</xs:sequence>
325-
</xs:complexType>
326-
</xs:element>
320+
<xs:element ref="exerciseDatesGroup" minOccurs="0" />
327321
<xs:element type="bool" name="AutomaticExercise" minOccurs="0"/>
328322
<xs:element type="optionExerciseData" name="ExerciseData" minOccurs="0"/>
329323
<xs:element type="optionPaymentData" name="PaymentData" minOccurs="0"/>
@@ -416,6 +410,16 @@
416410
</xs:all>
417411
</xs:complexType>
418412

413+
<xs:element name="exerciseDatesGroup" abstract="true" />
414+
<xs:element name="ExerciseDates" substitutionGroup="exerciseDatesGroup">
415+
<xs:complexType>
416+
<xs:sequence>
417+
<xs:element type="date" name="ExerciseDate" minOccurs="0" maxOccurs="unbounded"/>
418+
</xs:sequence>
419+
</xs:complexType>
420+
</xs:element>
421+
<xs:element name="ExerciseSchedule" type="scheduleData" substitutionGroup="exerciseDatesGroup" />
422+
419423
<xs:element name="legDataType" abstract="true"/>
420424
<xs:element name="CashflowData" substitutionGroup="legDataType">
421425
<xs:complexType>

0 commit comments

Comments
 (0)