Skip to content

Commit

Permalink
Merge branch 'github-231' into 'master'
Browse files Browse the repository at this point in the history
Github 231

See merge request qs/ore-github!44
  • Loading branch information
mgroncki committed May 21, 2024
2 parents b6eaa44 + 0db3194 commit 1bc2537
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Docs/UserGuide/parameterisation/curveconfig.tex
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ \subsubsection{FX Volatility Structures}
<DayCounter>A365</DayCounter>
<Calendar>US,JP</Calendar>
<Conventions>USD-JPY-FXOPTION</Conventions>
<SmileExtrapolation>UseInterpolator</SmileExtrapolation>
</FXVolatility>
\end{minted}
\caption{FX option volatility configuration Smile / Delta}
Expand Down Expand Up @@ -273,6 +274,10 @@ \subsubsection{FX Volatility Structures}
data input. See \ref{sss:fx_option_conv} for more details.
\item BaseVolatility1: For `ATMTriangulated' this denotes one of the surfaces we want to triangulate from
\item BaseVolatility2: For `ATMTriangulated' this denotes one of the surfaces we want to triangulate from
\item SmileExtrapolation [Optional]: Applicable only in case of SmileType Delta. Indicates the extrapolation in the
smile direction. The allowable values are None, UseInterpolator (or Linear) and Flat. Both Flat and None give flat
extrapolation. UseInterpolator indicates that the configured interpolation should be continued in the strike
direction in order to extrapolate. Default if not provided value is Flat.
\end{itemize}

\subsubsection{Equity Curve Structures}
Expand Down
12 changes: 9 additions & 3 deletions OREData/ored/configuration/fxvolcurveconfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (C) 2016 Quaternion Risk Management Ltd
Copyright (C) 2024 Skandinaviska Enskilda Banken AB (publ)
All rights reserved.
This file is part of ORE, a free-software/open-source library
Expand Down Expand Up @@ -33,11 +34,11 @@ FXVolatilityCurveConfig::FXVolatilityCurveConfig(const string& curveID, const st
const string& fxForeignCurveID, const string& fxDomesticCurveID,
const DayCounter& dayCounter, const Calendar& calendar,
const SmileInterpolation& interp, const string& conventionsID,
const std::vector<Size>& smileDelta)
const std::vector<Size>& smileDelta, const string& smileExtrapolation)
: CurveConfig(curveID, curveDescription), dimension_(dimension), expiries_(expiries), dayCounter_(dayCounter),
calendar_(calendar), fxSpotID_(fxSpotID), fxForeignYieldCurveID_(fxForeignCurveID),
fxDomesticYieldCurveID_(fxDomesticCurveID), conventionsID_(conventionsID), smileDelta_(smileDelta),
smileInterpolation_(interp) {
smileInterpolation_(interp), smileExtrapolation_(smileExtrapolation) {
populateRequiredCurveIds();
}

Expand Down Expand Up @@ -134,14 +135,17 @@ void FXVolatilityCurveConfig::fromXML(XMLNode* node) {
smileDelta_ = parseListOfValues<Size>(sDelta, &parseInteger);
} else if (smileType == "Delta") {
dimension_ = Dimension::SmileDelta;
// only read smile interpolation method if dimension is smile.
// only read smile interpolation and extrapolation method if dimension is smile.
if (smileInterp == "" || smileInterp == "Linear") {
smileInterpolation_ = SmileInterpolation::Linear;
} else if (smileInterp == "Cubic") {
smileInterpolation_ = SmileInterpolation::Cubic;
} else {
QL_FAIL("SmileInterpolation " << smileInterp << " not supported");
}

smileExtrapolation_ = XMLUtils::getChildValue(node, "SmileExtrapolation", false, "Flat");

deltas_ = XMLUtils::getChildrenValuesAsStrings(node, "Deltas", true);

// check that these are valid deltas
Expand Down Expand Up @@ -235,6 +239,8 @@ XMLNode* FXVolatilityCurveConfig::toXML(XMLDocument& doc) {
} else {
QL_FAIL("Unknown SmileInterpolation in FXVolatilityCurveConfig::toXML()");
}
if (!smileExtrapolation_.empty())
XMLUtils::addChild(doc, node, "SmileExtrapolation", smileExtrapolation_);
XMLUtils::addChild(doc, node, "Conventions", to_string(conventionsID_));
XMLUtils::addGenericChildAsList(doc, node, "Deltas", deltas_);
} else if (dimension_ == Dimension::SmileBFRR) {
Expand Down
7 changes: 6 additions & 1 deletion OREData/ored/configuration/fxvolcurveconfig.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (C) 2016 Quaternion Risk Management Ltd
Copyright (C) 2024 Skandinaviska Enskilda Banken AB (publ)
All rights reserved.
This file is part of ORE, a free-software/open-source library
Expand Down Expand Up @@ -72,7 +73,8 @@ class FXVolatilityCurveConfig : public CurveConfig {
const DayCounter& dayCounter = QuantLib::Actual365Fixed(),
const Calendar& calendar = QuantLib::TARGET(),
const SmileInterpolation& interp = SmileInterpolation::VannaVolga2,
const string& conventionsID = "", const std::vector<Size>& smileDelta = {25});
const string& conventionsID = "", const std::vector<Size>& smileDelta = {25},
const string& smileExtrapolation = "Flat");

FXVolatilityCurveConfig(const string& curveID, const string& curveDescription, const Dimension& dimension,
const string& baseVolatility1, const string& baseVolatility2,
Expand All @@ -98,6 +100,7 @@ class FXVolatilityCurveConfig : public CurveConfig {
const string& fxForeignYieldCurveID() const { return fxForeignYieldCurveID_; }
const string& fxDomesticYieldCurveID() const { return fxDomesticYieldCurveID_; }
const SmileInterpolation& smileInterpolation() const { return smileInterpolation_; }
const std::string& smileExtrapolation() const { return smileExtrapolation_; }
const string& conventionsID() const { return conventionsID_; }
const std::vector<Size>& smileDelta() const { return smileDelta_; }
const vector<string>& quotes() override;
Expand All @@ -111,6 +114,7 @@ class FXVolatilityCurveConfig : public CurveConfig {
//@{
Dimension& dimension() { return dimension_; }
SmileInterpolation& smileInterpolation() { return smileInterpolation_; }
string& smileExtrapolation() { return smileExtrapolation_; }
vector<string>& deltas() { return deltas_; }
DayCounter& dayCounter() { return dayCounter_; }
Calendar& calendar() { return calendar_; }
Expand Down Expand Up @@ -140,6 +144,7 @@ class FXVolatilityCurveConfig : public CurveConfig {
std::vector<Size> smileDelta_;
std::set<string> requiredYieldCurveIDs_;
SmileInterpolation smileInterpolation_;
string smileExtrapolation_;
string baseVolatility1_;
string baseVolatility2_;
string fxIndexTag_;
Expand Down
16 changes: 15 additions & 1 deletion OREData/ored/marketdata/fxvolcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ void FXVolCurve::buildSmileDeltaCurve(Date asof, FXVolatilityCurveSpec spec, con
QL_FAIL("Delta FX vol surface: invalid interpolation, expected Linear, Cubic");
}

bool flatExtrapolation = true;
auto smileExtrapType = parseExtrapolation(config->smileExtrapolation());
if (smileExtrapType == Extrapolation::UseInterpolator) {
DLOG("Smile extrapolation switched to using interpolator.");
flatExtrapolation = false;
} else if (smileExtrapType == Extrapolation::None) {
DLOG("Smile extrapolation cannot be turned off on its own so defaulting to flat.");
} else if (smileExtrapType == Extrapolation::Flat) {
DLOG("Smile extrapolation has been set to flat.");
} else {
DLOG("Smile extrapolation " << smileExtrapType << " not expected so defaulting to flat.");
}

// daycounter used for interpolation in time.
// TODO: push into conventions or config
DayCounter dc = config->dayCounter();
Expand All @@ -227,7 +240,8 @@ void FXVolCurve::buildSmileDeltaCurve(Date asof, FXVolatilityCurveSpec spec, con
[](const std::pair<Real, string>& x) { return x.first; });
vol_ = boost::make_shared<QuantExt::BlackVolatilitySurfaceDelta>(
asof, dates, putDeltasNum, callDeltasNum, hasATM, blackVolMatrix, dc, cal, fxSpot_, domYts_, forYts_,
deltaType_, atmType_, boost::none, switchTenor_, longTermDeltaType_, longTermAtmType_, boost::none, interp);
deltaType_, atmType_, boost::none, switchTenor_, longTermDeltaType_, longTermAtmType_, boost::none, interp,
flatExtrapolation);

vol_->enableExtrapolation();
}
Expand Down
1 change: 1 addition & 0 deletions xsd/curveconfig.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<xs:element type="xs:string" name="BaseVolatility1" minOccurs="0" maxOccurs="1"/>
<xs:element type="xs:string" name="BaseVolatility2" minOccurs="0" maxOccurs="1"/>
<xs:element type="reportConfiguration" name="Report" minOccurs="0"/>
<xs:element type="extrapolationType" name="SmileExtrapolation" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>

Expand Down

0 comments on commit 1bc2537

Please sign in to comment.