Skip to content

Commit 5e65730

Browse files
author
sebastien.bouvard
committed
QPR-13661 Fix Merge Conflict
2 parents b6c6893 + 2443759 commit 5e65730

122 files changed

Lines changed: 5813 additions & 1822 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.

Docker/Dockerfile-Test

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ FROM ${DOCKER_REPO}debian:${DEBIAN_TAG}
44

55
RUN apt-get update \
66
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
7-
ca-certificates dos2unix python3 python3-pip python3-venv python3-dev libxml2-utils xsltproc \
7+
ca-certificates dos2unix gnupg python3 python3-pip python3-venv python3-dev libxml2-utils xsltproc curl git \
88
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
99
&& update-ca-certificates \
1010
&& apt-get clean \
1111
&& rm -rf /var/lib/apt/lists/*
1212

13+
RUN sh -c 'curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg' \
14+
&& sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null' \
15+
&& apt-get update \
16+
&& apt-get install -f -y docker-ce-cli \
17+
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/*
1320

1421
# Create and activate virtual environment
1522
RUN python3 -m venv /venv
1623
ENV PATH="/venv/bin:$PATH"
1724

1825
# Install Python packages inside the virtual environment
1926
RUN pip3 install --break-system-packages \
20-
matplotlib pandas pytest pytest-xdist pytest-timeout datacompy jsondiff lxml xmldiff jupyter xmldiff numpy scipy ipywidgets papermill \
27+
matplotlib pandas pytest pytest-xdist pytest-timeout pytest-rerunfailures datacompy jsondiff lxml jupyter xmldiff numpy scipy ipywidgets papermill python-dotenv requests xmlschema clang-format openpyxl \
2128
&& rm -rf ~/.cache/pip
2229

2330
CMD bash

Docs/UserGuide/tradedata/scriptedtrades.tex

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,110 @@ \subsubsection{Floating Strike Forward Starting Option}
11031103
Allowable values: See Table \ref{tab:currency} for allowable currency codes.
11041104
\end{itemize}
11051105
1106+
\subsubsection{ACR Option}
1107+
1108+
% we only have a scripted trade representation for this at the moment
1109+
1110+
An ACR Option is represented as {\em acr option}, refer to Section
1111+
\ref{app:scriptedtrade} for an introduction.
1112+
1113+
\begin{minted}[fontsize=\footnotesize]{xml}
1114+
<Trade id="ArcOption">
1115+
<TradeType>ScriptedTrade</TradeType>
1116+
<Envelope>
1117+
<CounterParty>CPTY_A</CounterParty>
1118+
<NettingSetId>CPTY_A</NettingSetId>
1119+
<AdditionalFields/>
1120+
</Envelope>
1121+
<ArcOptionData>
1122+
<LongShort type="longShort">Short</LongShort>
1123+
<SettlementDate type="event">2020-07-20</SettlementDate>
1124+
<Notional type="number">100000000</Notional>
1125+
<StrikeFactor type="number">0.9950</StrikeFactor>
1126+
<BarrierFactor type="number">0.9840</StrikeFactor>
1127+
<CapRate type="number">0.02</CapRate>
1128+
<Offset type="number">0.0628</Offset>
1129+
<ValuationSchedule type="event">
1130+
<ScheduleData>
1131+
<Rules>
1132+
<StartDate>2020-01-15</StartDate>
1133+
<EndDate>2020-07-10</EndDate>
1134+
<Tenor>1M</Tenor>
1135+
<Calendar>US</Calendar>
1136+
<Convention>Following</Convention>
1137+
<TermConvention>Following</TermConvention>
1138+
<Rule>Forward</Rule>
1139+
</Rules>
1140+
</ScheduleData>
1141+
</ValuationSchedule>
1142+
<Underlying type="index">FX-ECB-JPY-USD</Underlying>
1143+
<PayCcy type="currency">JPY</PayCcy>
1144+
<Expiry type="event">2020-07-15</Expiry>
1145+
</ArcOptionData>
1146+
</Trade>
1147+
\end{minted}
1148+
1149+
The script referenced in the trade above is shown in Listing \ref{lst:arc_option}.
1150+
1151+
\begin{listing}[hbt]
1152+
\begin{minted}[fontsize=\footnotesize]{Basic}
1153+
NUMBER d, effectiveExchangeRate, netAccAmount, currPrice, pay;
1154+
NUMBER payoff, strike, sr1, sr2, sr3, itm, K, expectedN, settlementAmount;
1155+
1156+
netAccAmount = 0;
1157+
1158+
FOR d IN (2, SIZE(ValuationSchedule), 1) DO
1159+
sr2 = Underlying(ValuationSchedule[d]);
1160+
sr1 = Underlying(ValuationSchedule[d-1]);
1161+
K = sr1*StrikeFactor;
1162+
IF sr2 < sr1*BarrierFactor THEN
1163+
itm = Notional*((1/sr2)-(1/K));
1164+
ELSE
1165+
itm = 0;
1166+
END;
1167+
netAccAmount = netAccAmount + itm;
1168+
END;
1169+
1170+
expectedN = SIZE(ValuationSchedule) - 1;
1171+
sr3 = Underlying(ValuationSchedule[expectedN]);
1172+
1173+
effectiveExchangeRate = Notional / ((Notional/sr3)-netAccAmount);
1174+
1175+
IF effectiveExchangeRate >= CapRate THEN
1176+
settlementAmount = Notional/(CapRate + Offset);
1177+
ELSE
1178+
settlementAmount = Notional/(effectiveExchangeRate + Offset);
1179+
END;
1180+
1181+
pay = PAY(settlementAmount, Expiry, SettlementDate, PayCcy);
1182+
Option = pay;
1183+
\end{minted}
1184+
\caption{Payoff script for an Arc Option.}
1185+
\label{lst:arc_option}
1186+
\end{listing}
1187+
1188+
The meanings and allowable values in the \lstinline!ArcOptionData! node below.
1189+
1190+
\begin{itemize}
1191+
\item{}[index] \lstinline!Underlying!: Underlying index. \\
1192+
Allowable values: See Section \ref{data_index} for allowable values.
1193+
\item{}[longShort] \lstinline!LongShort!: Own party position in the option. \\
1194+
Allowable values: \emph{Long, Short}.
1195+
\item{}[number] \lstinline!StrikeFactor!: The strike factor used within ITM computation.
1196+
\item{}[number] \lstinline!BarrierFactor!: The barrier factor used within the condition for the ITM computation.
1197+
\item{}[number] \lstinline!Notional!: Notional amount. \\
1198+
Allowable values: Any non-negative number.
1199+
\item{}[number] \lstinline!CapRate!: Rate used to compute the settlement amount.
1200+
\item{}[number] \lstinline!Offset!: Offset used to compute the settlement amount.
1201+
\item{}[event] \lstinline!SettlementDate!: Settlement date. \\
1202+
Allowable values: See \lstinline!Date! in Table \ref{tab:allow_stand_data}.
1203+
\item{}[currency] \lstinline!SettlementCurrency!: The payment currency. For FX, where the underlying is provided
1204+
in the form \lstinline!FX-SOURCE-CCY1-CCY2! (see Table \ref{tab:fxindex_data}) this should
1205+
be \lstinline!CCY2!. If \lstinline!CCY1! or the currency of the underlying (for EQ and
1206+
COMM underlyings), this will result in a quanto payoff. Notice section \ref{sss:payccy_st}. \\
1207+
Allowable values: See Table \ref{tab:currency} for allowable currency codes.
1208+
\end{itemize}
1209+
11061210
\subsubsection{Forward Starting Swaption}
11071211
11081212
% we only have a scripted trade representation for this at the moment
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#TradeId,TradeType,Maturity,MaturityTime,NPV,NpvCurrency,NPV(Base),BaseCurrency,Notional,NotionalCurrency,Notional(Base),NettingSet,CounterParty
2+
BasisSwap,CommoditySwap,2026-03-09,0.468493,-9253250.000000,USD,-9253250.000000,USD,105090000.00,USD,105090000.00,1234,ABC
3+
Option,CommodityOption,2025-10-09,0.054795,19972500.000000,USD,19972500.000000,USD,0.00,USD,0.00,1234,ABC
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#TradeId,IsPar,Factor_1,ShiftSize_1,Factor_2,ShiftSize_2,Currency,Base NPV,Delta,Gamma,Currency(Trade),Base NPV(Trade),Delta(Trade),Gamma(Trade)
2+
BasisSwap,false,DiscountCurve/USD/0/6M,0.000000,,0.000000,USD,-9253250.00,311.48,-0.01,USD,-9253250.00,311.48,-0.01
3+
BasisSwap,false,CommodityCurve/NaturalGasBasis/20/21D,1.862500,,0.000000,USD,-9253250.00,-288687.50,0.00,USD,-9253250.00,-288687.50,0.00
4+
BasisSwap,false,CommodityCurve/NaturalGasBasis/53/54D,1.862500,,0.000000,USD,-9253250.00,-279375.00,0.00,USD,-9253250.00,-279375.00,0.00
5+
BasisSwap,false,CommodityCurve/NaturalGasBasis/82/83D,1.862500,,0.000000,USD,-9253250.00,-288687.50,0.00,USD,-9253250.00,-288687.50,0.00
6+
BasisSwap,false,CommodityCurve/NaturalGasBasis/101/102D,1.862500,,0.000000,USD,-9253250.00,-288687.50,0.00,USD,-9253250.00,-288687.50,0.00
7+
Option,false,DiscountCurve/USD/0/6M,0.000000,,0.000000,USD,19972500.00,-109.44,0.00,USD,19972500.00,-109.44,0.00
8+
Option,false,CommodityCurve/NaturalGas/41/42D,1.862500,,0.000000,USD,19972500.00,55875.00,0.00,USD,19972500.00,55875.00,0.00
9+
Option,false,CommodityCurve/NaturalGasBasis/41/42D,1.862500,,0.000000,USD,19972500.00,55875.00,0.00,USD,19972500.00,55875.00,0.00
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#TradeId,ScenarioLabel,Base NPV,Scenario NPV,Sensitivity
2+
BasisSwap,basis_stress,-9253250.000000,-29593000.000000,-20339750.000000
3+
Option,base_stress,19972500.000000,20977500.000000,1005000.000000
4+
Option,basis_stress,19972500.000000,20973000.000000,1000500.000000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<CalendarAdjustments>
3+
<Calendar name="ICE_FuturesUS">
4+
<BaseCalendar>WeekendsOnly</BaseCalendar>
5+
<AdditionalHolidays>
6+
<Date>2023-07-04</Date>
7+
<Date>2023-09-04</Date>
8+
<Date>2024-09-02</Date>
9+
<Date>2024-09-03</Date>
10+
<Date>2025-01-01</Date>
11+
<Date>2025-04-18</Date>
12+
<Date>2025-12-25</Date>
13+
</AdditionalHolidays>
14+
<AdditionalBusinessDays />
15+
</Calendar>
16+
<Calendar name="WeekendsOnly">
17+
<BaseCalendar>WeekendsOnly</BaseCalendar>
18+
<AdditionalHolidays>
19+
<Date>1999-01-01</Date>
20+
</AdditionalHolidays>
21+
<AdditionalBusinessDays />
22+
</Calendar>
23+
</CalendarAdjustments>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<Conventions>
3+
<Zero>
4+
<Id>USD-ZERO-TENOR-BASED</Id>
5+
<TenorBased>true</TenorBased>
6+
<DayCounter>A365</DayCounter>
7+
<Compounding>Continuous</Compounding>
8+
<CompoundingFrequency>Daily</CompoundingFrequency>
9+
<TenorCalendar>US</TenorCalendar>
10+
<SpotLag>2</SpotLag>
11+
<SpotCalendar>US</SpotCalendar>
12+
<RollConvention>Following</RollConvention>
13+
<EOM>false</EOM>
14+
</Zero>
15+
<CommodityFuture>
16+
<Id>NaturalGas</Id>
17+
<AnchorDay>
18+
<DayOfMonth>14</DayOfMonth>
19+
</AnchorDay>
20+
<ContractFrequency>Monthly</ContractFrequency>
21+
<Calendar>ICE_FuturesUS</Calendar>
22+
<ExpiryCalendar>ICE_FuturesUS</ExpiryCalendar>
23+
<ExpiryMonthLag>0</ExpiryMonthLag>
24+
<OffsetDays>2</OffsetDays>
25+
<BusinessDayConvention>Preceding</BusinessDayConvention>
26+
<AdjustBeforeOffset>false</AdjustBeforeOffset>
27+
<IsAveraging>false</IsAveraging>
28+
<OptionExpiryOffset>5</OptionExpiryOffset>
29+
<BalanceOfTheMonthPricingCalendar>ICE_FuturesUS</BalanceOfTheMonthPricingCalendar>
30+
</CommodityFuture>
31+
<CommodityFuture>
32+
<Id>NaturalGasBasis</Id>
33+
<AnchorDay>
34+
<DayOfMonth>14</DayOfMonth>
35+
</AnchorDay>
36+
<ContractFrequency>Monthly</ContractFrequency>
37+
<Calendar>ICE_FuturesUS</Calendar>
38+
<ExpiryCalendar>ICE_FuturesUS</ExpiryCalendar>
39+
<ExpiryMonthLag>0</ExpiryMonthLag>
40+
<OffsetDays>2</OffsetDays>
41+
<BusinessDayConvention>Preceding</BusinessDayConvention>
42+
<AdjustBeforeOffset>false</AdjustBeforeOffset>
43+
<IsAveraging>false</IsAveraging>
44+
<OptionExpiryOffset>5</OptionExpiryOffset>
45+
<BalanceOfTheMonthPricingCalendar>ICE_FuturesUS</BalanceOfTheMonthPricingCalendar>
46+
</CommodityFuture>
47+
</Conventions>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<CurveConfiguration>
3+
<FXSpots />
4+
<FXVolatilities>
5+
</FXVolatilities>
6+
<SwaptionVolatilities>
7+
</SwaptionVolatilities>
8+
<CapFloorVolatilities>
9+
</CapFloorVolatilities>
10+
<CDSVolatilities />
11+
<DefaultCurves>
12+
</DefaultCurves>
13+
<YieldCurves>
14+
<YieldCurve>
15+
<CurveId>USD-DUMMY</CurveId>
16+
<CurveDescription>USD discount=1 curve</CurveDescription>
17+
<Currency>USD</Currency>
18+
<DiscountCurve />
19+
<Segments>
20+
<Direct>
21+
<Type>Discount</Type>
22+
<Quotes>
23+
<Quote>DISCOUNT/RATE/USD/USD-DUMMY/1D</Quote>
24+
<Quote>DISCOUNT/RATE/USD/USD-DUMMY/50Y</Quote>
25+
</Quotes>
26+
<Conventions>USD-ZERO-TENOR-BASED</Conventions>
27+
</Direct>
28+
</Segments>
29+
<InterpolationVariable>Discount</InterpolationVariable>
30+
<InterpolationMethod>LogLinear</InterpolationMethod>
31+
<YieldCurveDayCounter>A365</YieldCurveDayCounter>
32+
<Tolerance>0.000000000001</Tolerance>
33+
</YieldCurve>
34+
</YieldCurves>
35+
<InflationCurves />
36+
<InflationCapFloorVolatilities />
37+
<EquityCurves />
38+
<EquityVolatilities />
39+
<Securities />
40+
<BaseCorrelations />
41+
<CommodityCurves>
42+
<CommodityCurve>
43+
<CurveId>NaturalGas</CurveId>
44+
<CurveDescription>NaturalGas</CurveDescription>
45+
<Currency>USD</Currency>
46+
<Quotes>
47+
<Quote>COMMODITY_FWD/PRICE/NaturalGas/*</Quote>
48+
</Quotes>
49+
<DayCounter>A365</DayCounter>
50+
<InterpolationMethod>BackwardFlat</InterpolationMethod>
51+
<Extrapolation>true</Extrapolation>
52+
</CommodityCurve>
53+
<CommodityCurve>
54+
<CurveId>NaturalGasBasis</CurveId>
55+
<CurveDescription>NaturalGasBasis</CurveDescription>
56+
<Currency>USD</Currency>
57+
<BasisConfiguration>
58+
<BasePriceCurve>NaturalGas</BasePriceCurve>
59+
<BasePriceConventions>NaturalGas</BasePriceConventions>
60+
<BasisQuotes>
61+
<Quote>COMMODITY_FWD/PRICE/NaturalGasBasis/*</Quote>
62+
</BasisQuotes>
63+
<BasisConventions>NaturalGas</BasisConventions>
64+
<DayCounter>A365</DayCounter>
65+
<InterpolationMethod>BackwardFlat</InterpolationMethod>
66+
<AddBasis>false</AddBasis>
67+
<AverageBase>true</AverageBase>
68+
<PriceAsHistoricalFixing>true</PriceAsHistoricalFixing>
69+
<!-- <MonthOffset>-1</MonthOffset> -->
70+
</BasisConfiguration>
71+
<Extrapolation>true</Extrapolation>
72+
</CommodityCurve>
73+
74+
</CommodityCurves>
75+
<CommodityVolatilities>
76+
<CommodityVolatility>
77+
<CurveId>NaturalGasBasis</CurveId>
78+
<CurveDescription>NaturalGasBasis</CurveDescription>
79+
<Currency>USD</Currency>
80+
<VolatilityConfig>
81+
<StrikeSurface>
82+
<QuoteType>ImpliedVolatility</QuoteType>
83+
<VolatilityType>Normal</VolatilityType>
84+
<ExerciseType>European</ExerciseType>
85+
<Strikes>*</Strikes>
86+
<Expiries>*</Expiries>
87+
<TimeInterpolation>Linear</TimeInterpolation>
88+
<StrikeInterpolation>Cubic</StrikeInterpolation>
89+
<Extrapolation>true</Extrapolation>
90+
<TimeExtrapolation>Linear</TimeExtrapolation>
91+
<StrikeExtrapolation>Flat</StrikeExtrapolation>
92+
</StrikeSurface>
93+
</VolatilityConfig>
94+
<DayCounter>A365</DayCounter>
95+
<Calendar>ICE_FuturesUS</Calendar>
96+
<FutureConventions>NaturalGas</FutureConventions>
97+
<PriceCurveId>Commodity/USD/NaturalGasBasis</PriceCurveId>
98+
<YieldCurveId>Yield/USD/USD-DUMMY</YieldCurveId>
99+
</CommodityVolatility>
100+
</CommodityVolatilities>
101+
<Correlations />
102+
<YieldVolatilities />
103+
</CurveConfiguration>

Examples/MarketRisk/Input/Curvealgebra/fixings.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)