Skip to content

Commit 718f485

Browse files
author
sebastien.bouvard
committed
QPR-12830 Fix Merge Conflict
2 parents fd2578f + 97043d3 commit 718f485

126 files changed

Lines changed: 19476 additions & 11811 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Docs/UserGuide/curve_configurations/yieldcurves.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ \subsubsection*{Direct Segment}
160160
or discount factor. The \lstinline!Conventions! node contains the ID of a node in the {\tt conventions.xml} file
161161
described in section \ref{sec:conventions}. The \lstinline!Conventions! node associates conventions with the quotes.
162162
163-
For \emph{Discount} type segments, the quotes can be given using a wildcard. Any valid and matching quotes will then be loaded from the provided market data. An example wildcard is:
163+
For both \emph{Zero} and \emph{Discount} type segments, the quotes can be given using a wildcard. Any valid and matching quotes will then be loaded from the provided market data. Example wildcards are:
164164
\begin{itemize}
165-
\item {DISCOUNT/RATE/EUR/EUR3M/*}
165+
\item {ZERO/RATE/EUR/*} - matches all EUR zero rate quotes
166+
\item {DISCOUNT/RATE/EUR/EUR3M/*} - matches all EUR discount factor quotes for the EUR3M curve
166167
\end{itemize}
167168
168169
\begin{listing}[H]

Docs/UserGuide/examples/examples.tex

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,11 @@ \subsection{Exposure}\label{example:exposure}
10711071
\item Flip View, switch perspectives easily for XVA: {\tt python run\_flipview.py}
10721072
\end{itemize}
10731073
1074+
Parameter calibration for exposure simulation model:
1075+
\begin{itemize}
1076+
\item HW n-factor historical calibration: {\tt python run\_hwhistoricalcalibration.py}
1077+
\end{itemize}
1078+
10741079
All cases are discussed in the following subsections.
10751080
10761081
\subsubsection{Swap with flat yield curve}\label{example:exposure_swapflat}
@@ -1805,6 +1810,30 @@ \subsubsection{Flip View}\label{example:exposure_flipview}
18051810
demonstrates how ORE can be used to quickly switch perspectives in XVA calculations with minimal changes in the {\tt ore.xml}
18061811
file only. In particular it avoids manipulating the portfolio input or the netting set.
18071812
1813+
\subsubsection{HW n-Factor Historical Calibration}\label{example:exposure_hwhistoricalcalibration}
1814+
1815+
Calling
1816+
1817+
\medskip
1818+
\centerline{\tt python run\_hwhistoricalcalibration.py }
1819+
\medskip
1820+
1821+
demonstrates how ORE provides functionality to calibrate the mean reversion speed($\kappa$) and volatility($\sigma$) parameters for the Hull-White $n$-factor model using historical market data. Two approaches are available:
1822+
1823+
\begin{enumerate}
1824+
\item Full Calibration Using Historical Data
1825+
\begin{itemize}
1826+
\item ORE performs Principal Component Analysis (PCA) on historical interest rate curves and FX spot data.
1827+
\item Based on PCA results, ORE will use eigenvalues and eigenvectors to calibrate constant parameters for the HW $n$-factor model, including $\kappa$ and $\sigma$.
1828+
\end{itemize}
1829+
1830+
\item Mean Reversion Calibration Only
1831+
\begin{itemize}
1832+
\item Users can provide their own eigenvalues and eigenvectors for each curve.
1833+
\item ORE will then perform mean reversion calibration using these inputs without recalculating PCA.
1834+
\end{itemize}
1835+
\end{enumerate}
1836+
18081837
18091838
\subsection{Netting Set Exposure and Collateral}\label{example:exposurewithcollateral}
18101839

Docs/UserGuide/parameterisation/ore.tex

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,30 +446,91 @@ \subsubsection{Simulation and Model Calibration}
446446
i.e. to calibrate the simulation model and output the calibrated model data such that it can be used to initialize
447447
a subsequent simulation without recalibration.
448448

449+
Both CAM and HW model are supported for {\tt calibration} 'analytics'. When setting model to CAM, ORE use the following inputs.
450+
449451
\begin{listing}[H]
450452
%\hrule\medskip
451453
\begin{minted}[fontsize=\footnotesize]{xml}
452454
<Analytics>
453455
<Analytic type="calibration">
454456
<Parameter name="active">Y</Parameter>
457+
<Parameter name="model">CAM</Parameter>
455458
<Parameter name="configFile">simulation.xml</Parameter>
456459
<Parameter name="outputFileName">calibration.csv</Parameter>
457460
</Analytic>
458461
</Analytics>
459462
\end{minted}
460-
\caption{ORE analytic: calibration}
461-
\label{lst:ore_calibration}
463+
\caption{ORE analytic: CAM calibration}
464+
\label{lst:ore_calibration_CAM}
462465
\end{listing}
463466

464-
Output is the Cross Asset Model data written to {\tt calibration.xml} in the usual output directory, which contains the calibration
467+
See {\tt Example\_8} for a demonstration.
468+
469+
When setting model to HW, ORE use the following inputs.
470+
471+
\begin{listing}[H]
472+
%\hrule\medskip
473+
\begin{minted}[fontsize=\footnotesize]{xml}
474+
<Analytics>
475+
<Analytic type="calibration">
476+
<Parameter name="active">Y</Parameter>
477+
<Parameter name="model">HW</Parameter>
478+
<Parameter name="mode">historical</Parameter>
479+
<Parameter name="foreignCurrencies">EUR,GBP</Parameter>
480+
<Parameter name="curveTenors">1Y,2Y,3Y,5Y,10Y,15Y,20Y,30Y</Parameter>
481+
<Parameter name="useForwardOrZeroRate">zero</Parameter>
482+
<Parameter name="pcaCalibration">Y</Parameter>
483+
<Parameter name="scenarioInputFile">scenario.csv</Parameter>
484+
<Parameter name="startDate">2019-09-29</Parameter>
485+
<Parameter name="endDate">2022-09-27</Parameter>
486+
<Parameter name="lambda">1</Parameter>
487+
<Parameter name="varianceRetained">0.90</Parameter>
488+
<Parameter name="pcaOutputFileName">pca.csv</Parameter>
489+
<Parameter name="pcaInputFileName">pca_USD.csv,pca_EUR.csv,pca_GBP.csv</Parameter>
490+
<Parameter name="meanReversionCalibration">Y</Parameter>
491+
<Parameter name="basisFunctionNumber">2</Parameter>
492+
<Parameter name="kappaUpperBound">5.0</Parameter>
493+
<Parameter name="haltonMaxGuess">500</Parameter>
494+
<Parameter name="meanReversionOutputFileName">meanReversion.csv</Parameter>
495+
</Analytic>
496+
</Analytics>
497+
\end{minted}
498+
\caption{ORE analytic: HW calibration}
499+
\label{lst:ore_calibration_HW}
500+
\end{listing}
501+
The parameters have the following interpretation:
502+
503+
\begin{itemize}
504+
\item {\tt model:} The model for Calibration, can be either {\tt CAM} or {\tt HW}, default to {\tt CAM} when left blank or omitted.
505+
\item {\tt mode:} The calibration mode, must be {\tt historical} for now. Will be ignored if {\tt model} node set to {\tt CAM}.
506+
\item {\tt foreignCurrencies:} The list of foreign currencies that need the calibration. Will be ignored if {\tt model} node set to {\tt CAM}.
507+
\item {\tt curveTenors:} The list of tenors for each IR curve when providing historical discount factors or the tenor list of each value in eigenvectors. Will be ignored if {\tt model} node set to {\tt CAM}.
508+
\item {\tt useForwardOrZeroRate:} When {\tt pcaCalibration} set to {\tt true}, this means whether zero rate or forward rate will be used to calculate the covariance matrix for PCA calibration. When {\tt pcaCalibration} set to {\tt false}, this means whether zero rate or forward rate should be used to parse the provided PCA eigenvectors for mean reversion calibration.
509+
\item {\tt pcaCalibration:} When set to {\tt true}, ORE will read the historical discount factors and perform PCA calibration. Will be ignored if {\tt model} node set to {\tt CAM}.
510+
\item {\tt scenarioInputFile:} The path to the file which contains the historical discount factors and historical FX spot rates. Must be in the scenario.csv ORE format. Only needed when {\tt pcaCalibration} set to {\tt true}.
511+
\item {\tt startDate:} Start date of the historical data that will be used in calibration. Only needed when {\tt pcaCalibration} set to {\tt true}.
512+
\item {\tt endDate:} End date of the historical data that will be used in calibration. Only needed when {\tt pcaCalibration} set to {\tt true}.
513+
\item {\tt lambda:} The lambda used on exponentially-weighted historical rates diffs when computing the covariance matrix. The covariance matrix will be equally weighted when {\tt lambda} is set to {\tt 1}. Only needed when {\tt pcaCalibration} set to {\tt true}.
514+
\item {\tt varianceRetained:} The ratio between the combined variance of retained principal components and total variance. This decides how many principal components will be retained. Only needed when {\tt pcaCalibration} set to {\tt true}.
515+
\item {\tt pcaOutputFileName:} The output file name of eigenvalues and eigenvectors retained for each currency.
516+
\item {\tt pcaInputFileName:} The list of file names where eigenvalues and eigenvectors are provided for mean reversion calibration. The files should be one curve per file. Only needed when {\tt pcaCalibration} is set to {\tt false} and {\tt meanReversionCalibration} is set to {\tt true}.
517+
\item {\tt meanReversionCalibration:} When set to {\tt true}, ORE will perform mean reversion calibration on principal components retained either from previous pca calibration step or from input files.
518+
\item {\tt basisFunctionNumber:} Number of basis functions used in mean reversion calibration.
519+
\item {\tt kappaUpperBound:} The upper bound of kappa during mean reversion calibration.
520+
\item {\tt haltonMaxGuess:} Number of max guess in optimization in mean reversion calibration.
521+
\item {\tt meanReversionOutputFileName:} The output file name for kappa and v for each curve.
522+
\end{itemize}
523+
524+
For both CAM and HW model calibration, output is the Cross Asset Model data written to {\tt calibration.xml} in the usual output directory, which contains the calibration
465525
results in place of the initial values for all parametrizations covered so far (IR, FX, EQ, INF, COM). In a subsequent run one could replace
466526
the {\tt CrossAssetModel} section in {\tt simulation.xml} with the output in {\tt calibration.xml} to re-run without re-calibration.
467527
Note that the {\tt Calibrate} flags in the output Cross Asset Model data are set to {\tt false}.
468528

469529
Additionally, the Cross Asset Model XML is written as a single XML string to the calibration report {\tt calibration.csv}, also held in
470530
memory for further processing e.g. via ORE's Python interface.
471531

472-
See {\tt Example\_8} for a demonstration.
532+
For HW model, there is an additional output {\tt calibration\_StatisticalWithRiskNeutralVolatility.xml} which is used for multi-factor sigma risk neutral calibration. Similarly, {\tt calibration\_StatisticalWithRiskNeutralVolatility.csv} is also outputted.
533+
473534

474535
\subsubsection{Scenario Generation}
475536

Docs/UserGuide/pricing/pricingengines.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,10 @@ \subsection{Product Type: IndexCreditDefaultSwap}
18231823
\item Curve: Index, Underlying
18241824
\item SensitivityDecomposition: Underlying, NotionalWeighted, LossWeighted, DeltaWeighted
18251825
\item SensitivityTemplate [optional]: the sensitivity template to use
1826+
\item CalibrateUnderlyingCurves [optional]: Only applies when Curve is set to Underlying.
1827+
If true, it apply a spread to the the individual constituent curves to match the index CDS spread.
1828+
This ensures that pricing the index CDS using underlying curves produces the same NPV as pricing with the index curve directly. Defaults to false.
1829+
(See Calibration of default curves for index tranches for details.)
18261830
\end{itemize}
18271831

18281832
\begin{longlisting}
@@ -1835,6 +1839,7 @@ \subsection{Product Type: IndexCreditDefaultSwap}
18351839
<Parameter name="Curve">Index</Parameter>
18361840
<Parameter name="SensitivityDecomposition">DeltaWeighted</Parameter>
18371841
<Parameter name="SensitivityTemplate">IR_Analytical</Parameter>
1842+
<Parameter name="CalibrateUnderlyingCurves">false</Parameter>
18381843
</EngineParameters>
18391844
</Product>
18401845
\end{minted}
@@ -1867,6 +1872,10 @@ \subsection{Product Type: IndexCreditDefaultSwapOption}
18671872
\item FepCurve: Index, Underlying
18681873
\item SensitivityDecomposition: Underlying, NotionalWeighted, LossWeighted, DeltaWeighted
18691874
\item SensitivityTemplate [optional]: the sensitivity template to use
1875+
\item CalibrateUnderlyingCurves [optional]: Only applies when Curve or FepCurve is set to Underlying.
1876+
If true, it apply a spread to the the individual constituent curves to match the index CDS spread.
1877+
This ensures that pricing the index CDS using underlying curves produces the same NPV as pricing with the index curve directly. Defaults to false.
1878+
(See Calibration of default curves for index tranches for details.)
18701879
\end{itemize}
18711880

18721881
\begin{longlisting}
@@ -1898,6 +1907,10 @@ \subsection{Product Type: IndexCreditDefaultSwapOption}
18981907
\item FepCurve: Index, Underlying
18991908
\item SensitivityDecomposition: Underlying, NotionalWeighted, LossWeighted, DeltaWeighted
19001909
\item SensitivityTemplate [optional]: the sensitivity template to use
1910+
\item CalibrateUnderlyingCurves [optional]: Only applies when Curve or FepCurve is set to Underlying.
1911+
If true, it apply a spread to the the individual constituent curves to match the index CDS spread.
1912+
This ensures that pricing the index CDS using underlying curves produces the same NPV as pricing with the index curve directly. Defaults to false.
1913+
(See Calibration of default curves for index tranches for details.)
19011914
\end{itemize}
19021915

19031916
\begin{longlisting}

Docs/UserGuide/tradedata/extendedfxforwardswap.tex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ \subsubsection{Extended Fx Forward Swap}
22

33
Extended Fx Forward Swap are represented as scripted trades, refer to appendix A for an introduction. Listing \ref{lst:extendedfxforwardswap} shows the structure of an example.
44

5+
An Extended Fx Forward Swap is like an FxAccumulator with regular and conditional observation and settlement dates. After the regular observation dates a European barrier is applied on the Extension Decision Date. If the barrier is hit the trade terminates, otherwise the trade continues with cashflows generated on the conditional observation dates.
6+
57
\begin{listing}[H]
68
\begin{minted}[fontsize=\footnotesize]{xml}
79
<Trade id="ExtendedForward">
@@ -63,6 +65,13 @@ \subsubsection{Extended Fx Forward Swap}
6365
<Date>2020-03-31</Date>
6466
<Date>2020-04-30</Date>
6567
<Date>2020-05-29</Date>
68+
\end{minted}
69+
\caption{Extended Fx Forward Swap Representation}
70+
\label{lst:extendedfxforwardswap}
71+
\end{listing}
72+
73+
\begin{listing}[H]
74+
\begin{minted}[fontsize=\footnotesize]{xml}
6675
<Date>2020-06-30</Date>
6776
<Date>2020-07-31</Date>
6877
<Date>2020-08-31</Date>
@@ -115,8 +124,8 @@ \subsubsection{Extended Fx Forward Swap}
115124
</ScriptedTradeData>
116125
</Trade>
117126
\end{minted}
118-
\caption{Extended Fx Forward Swap Representation}
119-
\label{lst:extendedfxforwardswap}
127+
\caption{Extended Fx Forward Swap Representation, continued}
128+
\label{lst:extendedfxforwardswap2}
120129
\end{listing}
121130
122131
The meanings and allowable values of the elements in the \verb+Extended Fx Forward Swap+ representation follow below.

Docs/UserGuide/tradedata/totalReturnSwap.tex

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ \subsubsection{Generic Total Return Swap / Contract for Difference (CFD)}
5555
\item CBO: See \ref{ss:CBOData}, the trade data is given in a CBOData sub node.
5656
\item CommodityPosition: See \ref{ss:commodity_position}, the trade data is given in a CommodityPositionData sub node.
5757
\item ConvertibleBond: See \ref{ss:convertible_bond}, the trade data is given in a ConvertibleBondData sub
58-
node. When using reference data, a TRS on a convertible bond can also be captured as a TRS on a bond, i.e. there is
59-
no need to distinguish between a TRS on a Bond and a TRS on a convertible Bond in this case, the pricer will figure
58+
node. When using reference data, a TRS on a Convertible Bond can also be captured as a TRS on a Bond, i.e. there is
59+
no need to distinguish between a TRS on a Bond and a TRS on a Convertible Bond in this case, the pricer will figure
6060
out which underlying to set up based on the type of reference data that is set up for the ISIN referenced in the
6161
security id field.
62+
\item CallableBond: See \ref{ss:callable_bond}, the trade data is given in a CallableBond sub node. When using reference data,
63+
a TRS on a Callable Bond can also be captured as a TRS on a bond, i.e. there is no need to distinguish between a TRS on a Bond and a TRS on a Callable Bond.
64+
The pricer will figure out which underlying to set up based on the type of reference data that is set up for the ISIN referenced in the security id field.
6265
\item EquityPosition: See \ref{ss:equity_position}, the trade data is given in a EquityPositionData sub
6366
node. Notice that the equities given in the basket must be available as quoted market data. To represent a TRS on an Equity Futures position, one or multiple EquityPosition underlyings are used, where the equity positions cover the underlying equity of the futures position.
6467

@@ -324,6 +327,32 @@ \subsubsection{Generic Total Return Swap / Contract for Difference (CFD)}
324327
\label{lst:trsdata}
325328
\end{listing}
326329

330+
331+
\begin{listing}[H]
332+
%\hrule\medskip
333+
\begin{minted}[fontsize=\footnotesize]{xml}
334+
<TotalReturnSwapData>
335+
<UnderlyingData>
336+
<Trade>
337+
<TradeType>CallableBond</TradeType>
338+
<CallableBondData>
339+
<BondData>
340+
<SecurityId>ISIN:XS0123456789</SecurityId>
341+
<BondNotional>100000000</BondNotional>
342+
</BondData>
343+
</CallableBondData>
344+
</Trade>
345+
</UnderlyingData>
346+
<!-- omitting ReturnData, FundingData, AdditionalCashflowData -->
347+
</TotalReturnSwapData>
348+
</Trade>
349+
\end{minted}
350+
\caption{Generic Total Return Swap with Callable Bond underlying}
351+
\label{lst:trsdata15}
352+
\end{listing}
353+
354+
355+
327356
\begin{listing}[H]
328357
%\hrule\medskip
329358
\begin{minted}[fontsize=\footnotesize]{xml}

0 commit comments

Comments
 (0)