|
42 | 42 | #include <ored/utilities/indexnametranslator.hpp> |
43 | 43 | #include <ored/utilities/log.hpp> |
44 | 44 | #include <ored/utilities/to_string.hpp> |
| 45 | +#include <ored/utilities/marketdata.hpp> |
45 | 46 |
|
46 | 47 | #include <qle/indexes/equityindex.hpp> |
47 | 48 | #include <qle/indexes/fxindex.hpp> |
|
51 | 52 | #include <qle/termstructures/pricetermstructureadapter.hpp> |
52 | 53 |
|
53 | 54 | #include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp> |
| 55 | +#include <ql/termstructures/yield/zerospreadedtermstructure.hpp> |
54 | 56 |
|
55 | 57 | #include <boost/lexical_cast.hpp> |
56 | 58 |
|
@@ -174,8 +176,18 @@ ScriptedTradeEngineBuilder::engine(const std::string& id, const ScriptedTrade& s |
174 | 176 |
|
175 | 177 | // 12 get the t0 curves for each model ccy |
176 | 178 |
|
| 179 | + std::string externalDiscountCurve = scriptedTrade.envelope().additionalField("discount_curve", false); |
| 180 | + std::string externalSecuritySpread = scriptedTrade.envelope().additionalField("security_spreads", false); |
177 | 181 | for (auto const& c : modelCcys_) { |
178 | | - modelCurves_.push_back(market_->discountCurve(c, configuration(MarketContext::pricing))); |
| 182 | + // for base ccy we account for an external discount curve and security spread if given |
| 183 | + Handle<YieldTermStructure> yts = |
| 184 | + externalDiscountCurve.empty() || c != baseCcy_ |
| 185 | + ? market_->discountCurve(c, configuration(MarketContext::pricing)) |
| 186 | + : indexOrYieldCurve(market_, externalDiscountCurve, configuration(MarketContext::pricing)); |
| 187 | + if (!externalSecuritySpread.empty() && c == baseCcy_) |
| 188 | + yts = Handle<YieldTermStructure>(boost::make_shared<ZeroSpreadedTermStructure>( |
| 189 | + yts, market_->securitySpread(externalSecuritySpread, configuration(MarketContext::pricing)))); |
| 190 | + modelCurves_.push_back(yts); |
179 | 191 | DLOG("curve for " << c << " added."); |
180 | 192 | } |
181 | 193 |
|
|
0 commit comments