Skip to content

Commit daf93d3

Browse files
damienbarkerjenkins
authored andcommitted
QPR-11308 catch equity option currency error with improved warning
1 parent 711bbd3 commit daf93d3

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

OREData/ored/portfolio/equityoption.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ void EquityOption::build(const boost::shared_ptr<EngineFactory>& engineFactory)
4747

4848
// check the equity currency
4949
underlyingCurrency_ =
50-
market->equityCurve(assetName_, engineFactory->configuration(MarketContext::pricing))->currency().code();
50+
market->equityCurve(assetName_, engineFactory->configuration(MarketContext::pricing))->currency();
5151
QL_REQUIRE(!underlyingCurrency_.empty(), "No equity currency in equityCurve for equity " << assetName_ << ".");
5252

5353
// Set the strike currency - if we have a minor currency, convert the strike
5454
if (!strikeCurrency_.empty())
5555
strike_.setCurrency(strikeCurrency_);
5656
else if (strike_.currency().empty()) {
5757
// If payoff currency and underlying currency are equivalent (and payoff currency could be a minor currency)
58-
if (ccy == parseCurrency(underlyingCurrency_)) {
58+
if (ccy == underlyingCurrency_) {
5959
TLOG("Setting strike currency to payoff currency " << ccy << " for trade " << id() << ".");
6060
strike_.setCurrency(ccy.code());
6161
} else {
@@ -67,15 +67,15 @@ void EquityOption::build(const boost::shared_ptr<EngineFactory>& engineFactory)
6767

6868
// Quanto payoff condition, i.e. currency_ != underlyingCurrency_, will be checked in VanillaOptionTrade::build()
6969
// Build the trade using the shared functionality in the base class.
70-
if (strike_.currency() != underlyingCurrency_) {
70+
if (strike_.currency() != underlyingCurrency_.code()) {
7171

7272
// We have a composite EQ Trade
7373

7474
Currency strikeCcy = parseCurrencyWithMinors(strikeCurrency_);
7575
QL_REQUIRE(ccy == strikeCcy, "Equity composite option requires pay ccy ("
7676
<< ccy.code() << ") to match strike ccy (" << strikeCcy.code()
7777
<< "), quanto composite options are not supported (underlying currency is "
78-
<< underlyingCurrency_ << ")");
78+
<< underlyingCurrency_.code() << ")");
7979

8080
Option::Type type = parseOptionType(option_.callPut());
8181
boost::shared_ptr<StrikedTypePayoff> payoff(new PlainVanillaPayoff(type, strike_.value()));
@@ -133,7 +133,7 @@ void EquityOption::build(const boost::shared_ptr<EngineFactory>& engineFactory)
133133
// TODO cast and set pricing engine
134134

135135
auto compositeBuilder = boost::dynamic_pointer_cast<EquityEuropeanCompositeEngineBuilder>(builder);
136-
vanilla->setPricingEngine(compositeBuilder->engine(assetName_, parseCurrency(underlyingCurrency_),
136+
vanilla->setPricingEngine(compositeBuilder->engine(assetName_, underlyingCurrency_,
137137
parseCurrency(strike_.currency()), expiryDate_));
138138

139139
string configuration = Market::defaultConfiguration;

OREData/ored/portfolio/vanillaoption.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void VanillaOptionTrade::build(const boost::shared_ptr<ore::data::EngineFactory>
2929

3030
// If underlying currency is empty, then set to payment currency by default.
3131
// If non-empty, then check if the currencies are different for a Quanto payoff
32-
Currency underlyingCurrency = underlyingCurrency_.empty() ? ccy : parseCurrencyWithMinors(underlyingCurrency_);
32+
Currency underlyingCurrency = underlyingCurrency_.empty() ? ccy : underlyingCurrency_;
3333
bool sameCcy = underlyingCurrency == ccy;
3434

3535
if (strike_.currency().empty())

OREData/ored/portfolio/vanillaoption.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class VanillaOptionTrade : public Trade {
7171
OptionData option_;
7272
string assetName_;
7373
string currency_;
74-
string underlyingCurrency_ = "";
74+
Currency underlyingCurrency_;
7575
double quantity_;
7676
TradeStrike strike_;
7777

0 commit comments

Comments
 (0)