Skip to content

Commit def9cb2

Browse files
mgronckijenkins
authored andcommitted
QPR-12130 fix wrong error msg and clean up
1 parent 6f46a3e commit def9cb2

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

Docs/UserGuide/tradecomponents/underlying.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ \subsubsection{Underlying}
244244
Allowable values: See Table \ref{tab:calendar}. Defaults to the null calendar if left blank or omitted, and \lstinline!Type!: is \emph{Commodity}.
245245

246246
\item \lstinline!FutureContractMonth! [Optional]:
247-
Only valid when \lstinline!Type! is \emph{Commodity}, \lstinline!PriceType! is FutureSettlement and there is no \lstinline!FutureExpiryDate! node. It specifies the underlying future contract month in the format \emph{Mon-YYYY}, for example Nov-2023.
247+
Only valid when \lstinline!Type! is \emph{Commodity}, \lstinline!PriceType! is FutureSettlement and there is no \lstinline!FutureExpiryDate! node. It specifies the underlying future contract month in the format \emph{MonYYYY}, for example Nov2023.
248248

249249
\item \lstinline!FutureExpiryDate! [Optional]:
250250
Only valid when \lstinline!Type! is \emph{Commodity}, \lstinline!PriceType! is FutureSettlement and there is no \lstinline!FutureContractMonth! node. This gives the expiration date of the underlying commodity future contract.

OREData/ored/portfolio/commodityposition.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,23 @@ void CommodityPosition::build(const boost::shared_ptr<ore::data::EngineFactory>&
6565
ConventionsBasedFutureExpiry feCalc(*convention);
6666
Date expiry = Settings::instance().evaluationDate();
6767
Size nOffset = u.futureMonthOffset() == Null<Size>() ? 0 : u.futureMonthOffset();
68+
if (u.deliveryRollDays() != Null<Size>()) {
69+
auto cal =
70+
u.deliveryRollCalendar().empty() ? convention->calendar() : parseCalendar(u.deliveryRollCalendar());
71+
expiry = cal.advance(expiry, u.deliveryRollDays() * Days, convention->businessDayConvention());
72+
}
73+
expiry = feCalc.nextExpiry(true, expiry, nOffset);
6874
if (!u.futureContractMonth().empty()) {
6975
QL_REQUIRE(u.futureContractMonth().size() == 7,
70-
"FutureContractMonth has invalid format, please use Mon-YYYY, where 'Mon' is a 3 letter "
76+
"FutureContractMonth has invalid format, please use MonYYYY, where 'Mon' is a 3 letter "
7177
"month abbreviation.");
7278
auto month = parseMonth(u.futureContractMonth().substr(0, 3));
7379
auto year = parseInteger(u.futureContractMonth().substr(3, 4));
7480
Date contractDate(1, month, year);
7581
expiry = feCalc.expiryDate(contractDate, nOffset, false);
7682
} else if (!u.futureExpiryDate().empty()) {
7783
expiry = parseDate(u.futureExpiryDate());
78-
expiry = feCalc.nextExpiry(true,expiry, nOffset, false);
79-
} else {
80-
if (u.deliveryRollDays() != Null<Size>()) {
81-
auto cal = u.deliveryRollCalendar().empty() ? convention->calendar()
82-
: parseCalendar(u.deliveryRollCalendar());
83-
expiry = cal.advance(expiry, u.deliveryRollDays() * Days, convention->businessDayConvention());
84-
}
85-
expiry = feCalc.nextExpiry(true, expiry, nOffset);
84+
expiry = feCalc.nextExpiry(true, expiry, nOffset, false);
8685
}
8786
index = index->clone(expiry, pts);
8887
}

0 commit comments

Comments
 (0)