Skip to content

Commit c02866e

Browse files
author
sebastien.bouvard
committed
Fix MC
2 parents 96f5beb + 00b29ab commit c02866e

44 files changed

Lines changed: 568 additions & 139 deletions

Some content is hidden

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

Docker/Dockerfile-ORE-Dependencies

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,23 @@ RUN apt-get update \
2323
swig \
2424
lld \
2525
python3-dev \
26+
python3-pip \
27+
python3-venv \
28+
curl \
2629
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
2730
&& apt-get clean \
2831
&& rm -rf /var/lib/apt/lists/* \
2932
&& mv /usr/bin/ld /usr/bin/ld.backup \
30-
&& ln -s /usr/bin/lld /usr/bin/ld
33+
&& ln -s /usr/bin/lld /usr/bin/ld
34+
35+
RUN \
36+
curl -sSL https://get.docker.com -o install-docker.sh && \
37+
sh install-docker.sh --version 28
38+
39+
RUN python3 -m venv /venv
40+
ENV PATH="/venv/bin:$PATH"
41+
42+
RUN \
43+
pip3 install cibuildwheel==3.2.1 && \
44+
rm -rf ~/.cache/pip
45+

Docker/Dockerfile-Wheels-Boost

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
ARG WHEEL_IMG
3+
FROM ${WHEEL_IMG}
4+
5+
RUN \
6+
curl -O -L https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.gz && \
7+
tar xfz boost_1_83_0.tar.gz && \
8+
cd boost_1_83_0 && \
9+
./bootstrap.sh --with-libraries=date_time,filesystem,iostreams,log,regex,serialization,system,thread,timer && \
10+
./b2 install
11+

Docker/Dockerfile-Wheels-CIBW

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
FROM ${DOCKER_REPO}ore-build-dependencies:${ORE_BUILD_VERSION}
3+
4+
ARG WHEEL_ARCH
5+
ARG WHEEL_IMAGE
6+
7+
ENV PATH="/venv/bin:$PATH"
8+
9+
ENV CIBW_BUILD="cp310-manylinux_${WHEEL_ARCH} cp312-manylinux_${WHEEL_ARCH}"
10+
ENV CIBW_MANYLINUX_X86_64_IMAGE=${WHEEL_IMAGE}
11+
ENV CIBW_MANYLINUX_AARCH64_IMAGE=${WHEEL_IMAGE}
12+
ENV CIBW_BEFORE_BUILD="chmod +x ORE-SWIG/Wheels-gitlab/before_all_linux.sh && ORE-SWIG/Wheels-gitlab/before_all_linux.sh"
13+
14+
WORKDIR /builds/qs/oreplus/ore
15+
RUN cibuildwheel --output-dir wheelhouse ORE-SWIG
16+
17+
COPY wheelhouse /wheelhouse
18+

Docker/Dockerfile-Wheels-ORE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
ARG WHEEL_IMG
3+
FROM ${WHEEL_IMG}
4+
5+
ARG CMAKE_BUILD_TYPE=Release
6+
ARG NUM_CORES=16
7+
8+
COPY CMakeLists.txt /ore/CMakeLists.txt
9+
COPY QuantLib /ore/QuantLib
10+
COPY QuantExt /ore/QuantExt
11+
COPY OREData /ore/OREData
12+
COPY OREAnalytics /ore/OREAnalytics
13+
COPY ThirdPartyLibs /ore/ThirdPartyLibs
14+
COPY cmake /ore/cmake
15+
16+
RUN \
17+
dnf -y install clang && \
18+
dnf -y install ccache && \
19+
dnf -y install ninja-build
20+
21+
ENV PATH="/usr/lib/ccache:$PATH"
22+
ENV CCACHE_DIR="/ccache"
23+
ENV CCACHE_MAXSIZE="10G"
24+
25+
WORKDIR /ore
26+
RUN \
27+
mkdir build && \
28+
cd build && \
29+
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_CXX_FLAGS="-D BOOST_ENABLE_ASSERT_HANDLER $([ "$(uname -m)" = "x86_64" ] && echo "-mavx2")" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF -DQL_ENABLE_PARALLEL_UNIT_TEST_RUNNER=ON -DQL_ENABLE_SESSIONS=ON -DORE_BUILD_APP=OFF -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_SWIG=OFF -DORE_BUILD_TESTS=OFF -DORE_ENABLE_OPENCL=OFF -DORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER=ON -DORE_PYTHON_INTEGRATION=OFF
30+
31+
WORKDIR /ore/build
32+
RUN --mount=type=cache,target=/ccache/ ccache -z && \
33+
cmake --build . -- -j ${NUM_CORES} install && \
34+
ccache -s
35+

Docs/UserGuide/allowablevalues.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ \subsection{Allowable Values}
258258
\emph{Actual/365 (No Leap), Act/365 (NL), NL/365, Actual/365 (JGB)} & Actual 365 Fixed (No Leap Year)\\ \hline
259259
\emph{Act/365 (Canadian Bond)} & Actual 365 Fixed (Canadian Bond)\\ \hline
260260
\emph{T360, 30/360, ACT/nACT, 30/360 US, 30/360 (US), 30U/360, 30US/360} & Thirty 360 (US) \\ \hline
261+
\emph{30/360 NASD} & Thirty 360 (NASD) \\ \hline
261262
\emph{30/360 (Bond Basis)} & Thirty 360 (Bond Basis) \\ \hline
262263
\emph{30E/360 (Eurobond Basis), 30E/360, 30/360 AIBD (Euro), 30E/360.ICMA, 30E/360 ICMA} & Thirty 360 (European) \\ \hline
263264
\emph{30E/360E, 30E/360 ISDA, 30E/360.ISDA, 30/360 German, 30/360 (German)} & Thirty 360 (German) \\ \hline

Docs/UserGuide/parameterisation/conventions.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ \subsubsection{Inflation Swap Conventions}
641641
<AdjustInflationObservationDates>false</AdjustInflationObservationDates>
642642
<InflationCalendar>TARGET</InflationCalendar>
643643
<InflationConvention>MF</InflationConvention>
644+
<StartDelay>2</StartDelay>
645+
<StartDelayConvention>Following</StartDelayConvention>
644646
</InflationSwap>
645647
\end{minted}
646648
\caption{Inflation swap conventions}
@@ -659,6 +661,8 @@ \subsubsection{Inflation Swap Conventions}
659661
\item \lstinline!AdjustInflationObservationDates!: Flag indicating whether index observation dates should be adjusted or not.
660662
\item \lstinline!InflationCalendar!: The calendar for the inflation leg of the swap.
661663
\item \lstinline!InflationConvention!: The rolling convention for the inflation leg of the swap.
664+
\item \lstinline!StartDelay!: [Optional] The inflation swap starts n business days after today, defaults to zero if omitted.
665+
\item \lstinline!StartDelayConvention!: [Optional] BusinessDayConvention to adjust the start day, defaults to Following if omitted.
662666

663667
\item \lstinline!PublicationRoll!:
664668
This is an optional node taking the values \lstinline!None!, \lstinline!OnPublicationDate! or \lstinline!AfterPublicationDate!. If omitted, the value \lstinline!None! is used. Currently, our only known use case for a value other than \lstinline!None! is for Australian zero coupon inflation indexed swaps (ZCIIS). Here, the index is published quarterly on the last Wednesday of the month following the end of the reference quarter. The start date and maturity date of the market quoted ZCIIS roll to the next quarterly date after the publication date of the index. For example, the AU CPI value for Q3 2020, i.e.\ 1 Jul 2020 to 30 Sep 2020 was released on 28 Oct 2020. On 27 Oct 2020, before the index publication date, the market 5Y ZCIIS would start on 15 Sep 2020 and end on 15 Sep 2025 and reference the Q2 inflation index value. On 29 Oct 2020, after the index publication date, the market 5Y ZCIIS would start on 15 Dec 2020 and end on 15 Dec 2025 and reference the Q3 inflation index value. On the release date, i.e. 28 Oct 2020, the market ZCIIS that is set up is determined by whether the \lstinline!PublicationRoll! value is \lstinline!OnPublicationDate! or \lstinline!AfterPublicationDate!. If it is set to \lstinline!OnPublicationDate!, the swap rolls on this date and hence the market 5Y ZCIIS would start on 15 Dec 2020 and end on 15 Dec 2025 and reference the Q3 inflation index value. If it is set to \lstinline!AfterPublicationDate!, the swap does not roll on the publication date and instead rolls on the next day, and hence the market 5Y ZCIIS would start on 15 Sep 2020 and end on 15 Sep 2025 and reference the Q2 inflation index value. The publication schedule for the index must be provided in the \lstinline!PublicationSchedule! node if \lstinline!PublicationRoll! is not \lstinline!None!. An example of the AU CPI conventions set up is given in Listing \ref{lst:aucpi_inflation_conventions}.

ORE-SWIG/OREAnalytics-SWIG/SWIG/orea_app.i

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ public:
208208
// Setters for stress testing
209209
void setStressThreshold(Real r);
210210
void setStressSimMarketParams(const std::string& xml);
211-
void setStressScenarioData(const std::string& xml);
211+
void setStressScenarioData(const std::string& xml);
212+
void setStressScenarioData(const ext::shared_ptr<StressTestScenarioData>& stressScenarioData);
212213
void setStressPricingEngine(const std::string& xml);
213214
void setStressPricingEngine(const ext::shared_ptr<EngineData>& engineData);
214215
// Setters for VaR

ORE-SWIG/OREAnalytics-SWIG/SWIG/orea_scenario.i

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class StressTestScenarioData : public XMLSerializable {
8282
public:
8383
struct CurveShiftData {
8484
ShiftType shiftType;
85-
vector<Real> shifts;
86-
vector<Period> shiftTenors;
85+
std::vector<Real> shifts;
86+
std::vector<Period> shiftTenors;
8787
};
8888

8989
struct SpotShiftData {
@@ -93,8 +93,8 @@ class StressTestScenarioData : public XMLSerializable {
9393

9494
struct VolShiftData {
9595
ShiftType shiftType;
96-
vector<Period> shiftExpiries;
97-
vector<Real> shifts;
96+
std::vector<Period> shiftExpiries;
97+
std::vector<Real> shifts;
9898
};
9999

100100
struct FXVolShiftData {
@@ -104,35 +104,35 @@ class StressTestScenarioData : public XMLSerializable {
104104
Weighted
105105
};
106106
ShiftType shiftType;
107-
vector<Period> shiftExpiries;
108-
vector<Real> shifts;
109-
vector<Period> weightTenors;
110-
vector<Real> weights;
107+
std::vector<Period> shiftExpiries;
108+
std::vector<Real> shifts;
109+
std::vector<Period> weightTenors;
110+
std::vector<Real> weights;
111111
AtmShiftMode mode = AtmShiftMode::Explicit;
112112
};
113113

114114
struct CapFloorVolShiftData {
115115
ShiftType shiftType;
116-
vector<Period> shiftExpiries;
117-
vector<double> shiftStrikes;
118-
std::map<Period, vector<Real>> shifts;
116+
std::vector<Period> shiftExpiries;
117+
std::vector<double> shiftStrikes;
118+
std::map<Period, std::vector<Real>> shifts;
119119
};
120120
struct SwaptionVolShiftData {
121121
ShiftType shiftType;
122122
Real parallelShiftSize;
123-
vector<Period> shiftExpiries;
124-
vector<Period> shiftTerms;
125-
map<pair<Period, Period>, Real> shifts;
123+
std::vector<Period> shiftExpiries;
124+
std::vector<Period> shiftTerms;
125+
std::map<std::pair<Period, Period>, Real> shifts;
126126
};
127127
struct CommodityVolShiftData {
128128
ShiftType shiftType;
129-
vector<Period> shiftExpiries;
130-
vector<Real> shiftMoneyness;
131-
vector<Real> shifts;
129+
std::vector<Period> shiftExpiries;
130+
std::vector<Real> shiftMoneyness;
131+
std::vector<Real> shifts;
132132
};
133133
struct StressTestData {
134134
~StressTestData() {}
135-
string label;
135+
std::string label;
136136
bool irCurveParShifts;
137137
bool irCapFloorParShifts;
138138
bool creditCurveParShifts;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
pip3 install docker setuptools
4+
cd ORE-SWIG
5+
cp Wheels-gitlab/oreanalytics-config .
6+
chmod +x oreanalytics-config
7+
python3 setup.py wrap
8+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
3+
# The dockerfile Dockerfile-Wheels-CIBW launches cibuildwheel like so:
4+
# WORKDIR /builds/qs/oreplus/ore
5+
# cibuildwheel --output-dir wheelhouse ORE-SWIG
6+
# This tells cibuildwheel to start in directory "ore" and run in directory "ORE-SWIG".
7+
# Then cibuildwheel runs docker, and copies its current directory ("ore")
8+
# into the container, into directory "/project":
9+
ORE="/project"
10+
11+
# On your system, the boost_thread lib may have a nonstandard name, e.g. boost_thread-mt.
12+
# If that is the case then set the BOOST_THREAD variable before calling this script, e.g:
13+
# export BOOST_THREAD=boost_thread-mt
14+
BOOST_THREAD="${BOOST_THREAD:=boost_thread}"
15+
16+
usage="\
17+
Usage: oreanalytics-config [--libs] [--cflags]"
18+
19+
if test $# -eq 0; then
20+
echo "${usage}" 1>&2
21+
exit 1
22+
fi
23+
24+
while test $# -gt 0; do
25+
case "$1" in
26+
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
27+
*) optarg= ;;
28+
esac
29+
30+
case $1 in
31+
--cflags)
32+
#echo -I${ORE}/build/QuantLib -I${ORE}/OREAnalytics -I${ORE}/OREData -I${ORE}/QuantExt -I${ORE}/QuantLib -I${BOOST_INC} -std=c++1z -DNDEBUG -Wno-free-nonheap-object -Wno-maybe-uninitialized -Wno-misleading-indentation
33+
# We must not specify any include directories, because we have already installed boost and ORE to system directories:
34+
echo -w
35+
;;
36+
--libs)
37+
#echo -L${ORE}/build/OREAnalytics/orea -lOREAnalytics -L${ORE}/build/OREData/ored -lOREData -L${ORE}/build/QuantExt/qle -lQuantExt -L${ORE}/build/QuantLib/ql -lQuantLib -L${BOOST_LIB} -l${BOOST_THREAD} -lboost_system -lboost_serialization -lboost_date_time -lboost_regex -lboost_filesystem -std=c++1z
38+
# We must not specify any library directories, because we have already installed boost and ORE to system directories:
39+
echo -lOREAnalytics -lOREData -lQuantExt -lQuantLib -l${BOOST_THREAD} -lboost_system -lboost_serialization -lboost_date_time -lboost_regex -lboost_filesystem
40+
;;
41+
*)
42+
echo "${usage}" 1>&2
43+
exit 1
44+
;;
45+
esac
46+
shift
47+
done
48+

0 commit comments

Comments
 (0)