├── OREAnalytics-SWIG ├── Python │ ├── Examples │ │ ├── Notebooks │ │ │ ├── Example_1 │ │ │ │ ├── Input │ │ │ │ │ ├── notes │ │ │ │ │ ├── fixings.txt │ │ │ │ │ ├── pricingengine.xml │ │ │ │ │ ├── ore.xml │ │ │ │ │ ├── portfolio.xml │ │ │ │ │ ├── market.txt │ │ │ │ │ └── todaysmarket.xml │ │ │ │ └── ore.py │ │ │ ├── Example_6 │ │ │ │ ├── Input │ │ │ │ │ ├── notes │ │ │ │ │ ├── fixings.txt │ │ │ │ │ ├── pricingengine.xml │ │ │ │ │ ├── ore.xml │ │ │ │ │ ├── portfolio.xml │ │ │ │ │ ├── market.txt │ │ │ │ │ └── todaysmarket.xml │ │ │ │ ├── run.py │ │ │ │ └── ore.py │ │ │ ├── Example_8 │ │ │ │ ├── riskclass.JPG │ │ │ │ ├── risktype.JPG │ │ │ │ └── log_structured.json │ │ │ ├── Example_7 │ │ │ │ ├── Readme.txt │ │ │ │ ├── Input │ │ │ │ │ ├── market.txt │ │ │ │ │ ├── pricingengine.xml │ │ │ │ │ ├── ore_SIMM2.4_1D.xml │ │ │ │ │ ├── ore_SIMM2.6_1D.xml │ │ │ │ │ ├── ore_SIMM2.4_10D.xml │ │ │ │ │ ├── ore_SIMM2.6_10D.xml │ │ │ │ │ ├── todaysmarket.xml │ │ │ │ │ └── crif.csv │ │ │ │ ├── run.py │ │ │ │ └── ore.py │ │ │ ├── Example_4 │ │ │ │ ├── Input │ │ │ │ │ ├── inputeigenvectors.csv │ │ │ │ │ ├── portfolio.xml │ │ │ │ │ ├── simulation.xml │ │ │ │ │ └── netting.xml │ │ │ │ └── pca.py │ │ │ ├── Example_5 │ │ │ │ ├── ore.py │ │ │ │ └── Input │ │ │ │ │ ├── pricingengine.xml │ │ │ │ │ ├── netting.xml │ │ │ │ │ └── todaysmarket.xml │ │ │ ├── Example_3 │ │ │ │ ├── ore_amc.py │ │ │ │ ├── ore_classic.py │ │ │ │ ├── Input │ │ │ │ │ ├── netting.xml │ │ │ │ │ ├── bak │ │ │ │ │ │ ├── netting.xml │ │ │ │ │ │ └── portfolio.xml │ │ │ │ │ ├── todaysmarket.xml │ │ │ │ │ ├── ore_amc.xml │ │ │ │ │ ├── ore_bermudans.xml │ │ │ │ │ ├── ore_classic.xml │ │ │ │ │ ├── ore_swaps.xml │ │ │ │ │ └── portfolio.xml │ │ │ │ └── progress.ipynb │ │ │ └── Example_2 │ │ │ │ ├── ore.py │ │ │ │ └── Input │ │ │ │ ├── netting_mpor.xml │ │ │ │ ├── netting.xml │ │ │ │ ├── netting_mta.xml │ │ │ │ ├── netting_dim.xml │ │ │ │ ├── netting_threshold.xml │ │ │ │ └── ore_external_im.xml │ │ ├── Input │ │ │ ├── caladj.xml │ │ │ ├── ore_market.xml │ │ │ ├── portfolio_swap.xml │ │ │ └── netting.xml │ │ ├── runExamples.sh │ │ ├── testAllNotebooks.sh │ │ ├── log.py │ │ ├── dates.py │ │ ├── market.py │ │ ├── portfolio.py │ │ └── commodityforward.py │ ├── test │ │ ├── testrunner.py │ │ ├── OREAnalyticsTestSuite.py │ │ └── test_marketdatum.py │ └── ORE │ │ └── __init__.py ├── Java │ ├── Manifest.txt │ └── Examples │ │ └── ORERunner.java ├── LICENSE.TXT ├── oreanalytics-config └── SWIG │ ├── orea.i │ └── oreanalytics.i ├── .gitmodules ├── CMakeLists.txt ├── runCmake.sh ├── Docker ├── docker-compose-oreswig.yml ├── docker-compose-oreswig-app.yml ├── DockerfileRunORE.sh ├── Dockerfile-ORESWIG └── Dockerfile-ORESWIG-App ├── runPythonTests.cmd ├── Wheels ├── README.md ├── oreanalytics-config.macos ├── before_all_linux.sh └── oreanalytics-config.linux ├── tutorials.00.index.md ├── News.txt ├── QuantExt-SWIG └── SWIG │ ├── qle_currencies.i │ ├── qle.i │ ├── qle_common.i │ ├── quantext.i │ ├── qle_averageoisratehelper.i │ ├── qle_ccyswap.i │ ├── qle_creditdefaultswap.i │ ├── qle_equityforward.i │ ├── qle_cashflows.i │ ├── qle_crossccyfixfloatswap.i │ └── qle_oiccbasisswap.i ├── OREData-SWIG └── SWIG │ ├── ored.i │ ├── ored_reports.i │ ├── ored_calendarAdjustmentConfig.i │ ├── oredata.i │ └── ored_loader.i ├── LICENSE.txt ├── runCmakeVS.cmd ├── tutorials.06.notebooks.md ├── .github └── workflows │ ├── macosx86_wheels.yml │ ├── macosARM64_wheels.yml │ ├── linux_manylinux_wheels_01.yml │ └── linux_manylinux_wheels_02.yml ├── tutorials.05.wheels.md ├── tutorials.01.install_windows.md └── tutorials.02.install_posix.md /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/notes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/notes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Java/Manifest.txt: -------------------------------------------------------------------------------- 1 | Class-Path: OREAnalyticsJava.jar 2 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/fixings.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/fixings.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "QuantLib-SWIG"] 2 | path = QuantLib-SWIG 3 | url = https://github.com/OpenSourceRisk/QuantLib-SWIG.git 4 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | QuantExt-SWIG is 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | project(ORE-SWIG) 4 | 5 | add_subdirectory(OREAnalytics-SWIG/Python) 6 | 7 | -------------------------------------------------------------------------------- /runCmake.sh: -------------------------------------------------------------------------------- 1 | cmake \ 2 | -D Python_ROOT_DIR=$PYTHON_ROOT_DIR \ 3 | -D ORE_USE_ZLIB=ON \ 4 | -D ORE=$ORE \ 5 | -D ORE_BUILD=$ORE_BUILD \ 6 | -G Ninja .. 7 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_8/riskclass.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenSourceRisk/ORE-SWIG/HEAD/OREAnalytics-SWIG/Python/Examples/Notebooks/Example_8/riskclass.JPG -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_8/risktype.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenSourceRisk/ORE-SWIG/HEAD/OREAnalytics-SWIG/Python/Examples/Notebooks/Example_8/risktype.JPG -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/test/testrunner.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import ORE 4 | import nose 5 | 6 | sys.modules["QuantLib"] = ORE 7 | 8 | if __name__=="__main__": 9 | nose.run() -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Readme.txt: -------------------------------------------------------------------------------- 1 | SIMM Calculator called with an external CRIF file 2 | 3 | The latest supported SIMM version is 2.6 (aka 2.5.6) 4 | 5 | For SIMM version >= 2.2 we provide both MPoR=10d and MPoR=1d versions. 6 | -------------------------------------------------------------------------------- /Docker/docker-compose-oreswig.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | env_ore_plus_swig: 5 | image: env_oreswig:${ORE_TAG} 6 | build: 7 | context: ../../ 8 | dockerfile: oreswig/Docker/Dockerfile-ORESWIG 9 | args: 10 | - ore_version=${ORE_TAG} -------------------------------------------------------------------------------- /Docker/docker-compose-oreswig-app.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | ore_plus_app: 5 | image: oreswig_app:${ORE_TAG} 6 | build: 7 | context: ../../ 8 | dockerfile: oreswig/Docker/Dockerfile-ORESWIG-App 9 | args: 10 | - ore_version=${ORE_TAG} 11 | - debian_tag=${DEBIAN_TAG} 12 | -------------------------------------------------------------------------------- /Docker/DockerfileRunORE.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose --env-file ore/Docker/.env -f oreswig/Docker/docker-compose-oreswig.yml build || exit 1 3 | COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose --env-file ore/Docker/.env -f oreswig/Docker/docker-compose-oreswig-app.yml build || exit 1 -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/pricingengine.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DiscountedCashflows 5 | 6 | DiscountingSwapEngineOptimised 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/pricingengine.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DiscountedCashflows 5 | 6 | DiscountingSwapEngineOptimised 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/market.txt: -------------------------------------------------------------------------------- 1 | 20191230 FX/RATE/EUR/CHF 1.125046 2 | 20191230 FX/RATE/EUR/GBP 0.811938 3 | 20191230 FX/RATE/EUR/JPY 128.15046 4 | 20191230 FX/RATE/EUR/SEK 9.657638 5 | 20191230 FX/RATE/EUR/USD 1.132337 6 | 20191230 FX/RATE/USD/GBP 1.394610179594994 7 | 20191230 FX/RATE/USD/CHF 1.006480623903378 8 | 9 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/pricingengine.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DiscountedCashflows 5 | 6 | DiscountingSwapEngineOptimised 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Input/caladj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2020-06-01 5 | 6 | 7 | 2020-05-05 8 | 9 | 10 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/runExamples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | status=0 3 | return_code=0 4 | for file in *.py; do 5 | if [ -f "$file" ]; then 6 | echo RUN $file 7 | python3 "$file" || status=1 8 | return_code=$? 9 | if [ $return_code -gt $status ]; then 10 | status=$return_code 11 | fi 12 | fi 13 | done 14 | exit $status 15 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/test/OREAnalyticsTestSuite.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2023 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | """ 5 | import sys 6 | import nose 7 | import ORE 8 | 9 | def test(): 10 | print('testing ORED ' + ORE.__version__) 11 | result = nose.run() 12 | if result == False: 13 | sys.exit(1) 14 | 15 | if __name__ == '__main__': 16 | test() 17 | 18 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_4/Input/inputeigenvectors.csv: -------------------------------------------------------------------------------- 1 | tenor,eigenvector_1,eigenvector_2 2 | 1,0.353553390593,-0.537955502871 3 | 2,0.353553390593,-0.374924478795 4 | 3,0.353553390593,-0.252916811525 5 | 5,0.353553390593,-0.087587539893 6 | 10,0.353553390593,0.12267800393 7 | 15,0.353553390593,0.240659435416 8 | 20,0.353553390593,0.339148675322 9 | 30,0.353553390593,0.552478951238 10 | -------------------------------------------------------------------------------- /runPythonTests.cmd: -------------------------------------------------------------------------------- 1 | set PYTHONPATH=%PYTHONPATH%;%~dp0\OREAnalytics-SWIG\Python\build;%~dp0\OREAnalytics-SWIG\Python\build\Release 2 | echo RUN ORE Python Testsuite 3 | cd %~dp0\OREAnalytics-SWIG\Python\Test 4 | python OREAnalyticsTestSuite.py 5 | pause 6 | 7 | echo RUN QuantLib Testsuite 8 | cd %~dp0\QuantLib-SWIG\Python\test 9 | python -c "import sys, ORE; sys.modules['QuantLib']=ORE;import QuantLibTestSuite;QuantLibTestSuite.test()" 10 | pause 11 | 12 | cd %~dp0\ -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_5/ore.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2018 Quaternion Risk Manaement Ltd 2 | # All rights reserved. 3 | 4 | from OREPlus import * 5 | 6 | print ("Loading parameters...") 7 | params = Parameters() 8 | print (" params is of type", type(params)) 9 | params.fromFile("Input/ore.xml") 10 | print (" setup/asofdate = " + params.get("setup","asofDate")) 11 | 12 | print ("Building ORE+ App...") 13 | ore = OREAppPlus(params) 14 | print (" ore is of type", type(ore)) 15 | 16 | print ("Running ORE process..."); 17 | # Run it all 18 | ore.run() 19 | 20 | print("Done") 21 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/testAllNotebooks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | status=0 3 | return_code=0 4 | for dir in $(find ./Notebooks -type d); do 5 | # Loop over all ipynb files in the current subdirectory 6 | for file in "$dir"/*.ipynb; do 7 | # Run nbconvert on the current ipynb file 8 | if test -f "$file"; then 9 | jupyter nbconvert --execute "$file" --to notebook --output-dir=./tmp 10 | return_code=$? 11 | if [ $return_code -gt $status ]; then 12 | status=$return_code 13 | fi 14 | fi 15 | done 16 | done 17 | exit $status -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | sys.path.append('../') 5 | from ore_examples_helper import OreExample 6 | 7 | oreex = OreExample(sys.argv[1] if len(sys.argv)>1 else False) 8 | 9 | orexmls = [ 10 | ("Input/ore_SIMM2.4_10D.xml", "2.4", "10"), 11 | ("Input/ore_SIMM2.4_1D.xml", "2.4", "1"), 12 | ("Input/ore_SIMM2.6_10D.xml", "2.6", "10"), 13 | ("Input/ore_SIMM2.6_1D.xml", "2.6", "1") 14 | ] 15 | for orexml in orexmls: 16 | oreex.print_headline(f"Run ORE SIMM; version={orexml[1]}; MPOR days={orexml[2]}") 17 | oreex.run(orexml[0]) 18 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_8/log_structured.json: -------------------------------------------------------------------------------- 1 | { "category": "Error", "group": "Curve", "message": "No security spread or bond price to imply the spread is given. Will proceed assuming a zero spread.", "sub_fields": [ { "name": "curveId", "value": "Security/ISIN:XS0983610930" }, { "name": "exceptionType", "value": "Missing security spread" } ] } 2 | { "category": "Error", "group": "Curve", "message": "No security spread or bond price to imply the spread is given. Will proceed assuming a zero spread.", "sub_fields": [ { "name": "curveId", "value": "Security/SECURITY_2" }, { "name": "exceptionType", "value": "Missing security spread" } ] } 3 | -------------------------------------------------------------------------------- /Wheels/README.md: -------------------------------------------------------------------------------- 1 | # ore-wheels 2 | 3 | | | macOS Intel | macOS Apple Silicon | Windows 64bit | Windows 32bit | manylinux
musllinux x86_64 | 4 | |----------------|----|-----|-----|-----|----| 5 | | CPython 3.7 | ✅ | N/A | N/A | N/A | ✅ | 6 | | CPython 3.8 | ✅ | ✅ |✅ | ✅ | ✅ | 7 | | CPython 3.9 | ✅ | ✅ | ✅ | ✅ | ✅ | 8 | | CPython 3.10 | ✅ | ✅ | ✅ | ✅ | ✅ | 9 | | CPython 3.11 | ✅ | ✅ |✅ | ✅ | ✅ | 10 | | CPython 3.12 | ✅ | ✅ | ✅ | ✅ | ✅ | 11 | | PyPy 3.7 v7.3 | ✅ | N/A | ✅ | N/A | ✅¹ | 12 | | PyPy 3.8 v7.3 | ✅ | N/A | ✅ | N/A | ✅¹ | 13 | | PyPy 3.9 v7.3 | ✅ | N/A | ✅ | N/A | ✅¹ | 14 | | PyPy 3.10 v7.3 | ✅ | N/A | ✅ | N/A | ✅¹ | 15 | 16 | ¹ PyPy is only supported for manylinux wheels, not musllinux.
-------------------------------------------------------------------------------- /tutorials.00.index.md: -------------------------------------------------------------------------------- 1 | 2 | # Tutorials Index 3 | 4 | This page serves as the index for a series of tutorials on using and building 5 | ORE python wrappers and wheels. 6 | 7 | [Installing ORE Python Libraries and Example Scripts on Windows](tutorials.01.install_windows.md) 8 | 9 | [Installing ORE Python Libraries and Example Scripts on Posix Systems (e.g. MacOS and Linux)](tutorials.02.install_posix.md) 10 | 11 | [Building ORE Python Wrappers on Windows](tutorials.03.build_windows.md) 12 | 13 | [Building ORE Python Wrappers on Posix Systems (e.g. MacOS and Linux)](tutorials.04.build_posix.md) 14 | 15 | [Managing Wheels](tutorials.05.wheels.md) 16 | 17 | [Run Jupyter Notebook Examples using the published ORE Python module](tutorials.06.notebooks.md) 18 | 19 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | sys.path.append('../') 5 | from ore_examples_helper import OreExample 6 | 7 | oreex = OreExample(sys.argv[1] if len(sys.argv)>1 else False) 8 | 9 | oreex.print_headline("Run ORE to produce NPV cube and exposures") 10 | oreex.run("Input/ore.xml") 11 | oreex.get_times("Output/log.txt") 12 | 13 | oreex.print_headline("Run ORE again to price European Swaptions") 14 | oreex.run("Input/ore_swaption.xml") 15 | 16 | oreex.print_headline("Plot results: Simulated exposures vs analytical swaption prices") 17 | 18 | oreex.setup_plot("swaptions") 19 | oreex.plot("exposure_trade_Swap_20y.csv", 2, 3, 'b', "Swap EPE") 20 | oreex.plot("exposure_trade_Swap_20y.csv", 2, 4, 'r', "Swap ENE") 21 | oreex.plot_npv("swaption_npv.csv", 6, 'g', "NPV Swaptions", marker='s') 22 | oreex.decorate_plot(title="Example 1 - Simulated exposures vs analytical swaption prices") 23 | oreex.save_plot_to_file() 24 | 25 | -------------------------------------------------------------------------------- /News.txt: -------------------------------------------------------------------------------- 1 | Changes for the 9th ORE release (1.8.9.0): 2 | ========================================== 3 | 4 | Extended the interface so that we can build all ORE inputs in memory 5 | and run ORE without loading from files 6 | 7 | 8 | Changes for the 8th ORE release (1.8.8.0): 9 | ========================================== 10 | 11 | Updates to work with QuantLib-SWIG 1.28 12 | 13 | 14 | Changes for the 7th ORE release (1.8.7.0): 15 | ========================================== 16 | 17 | Updates to work with QuantLib-SWIG 1.27 18 | Python test cases fixed, thanks to Farah Khashman 19 | Various additional ORE classes wrapped, thanks to Farah Khashman 20 | 21 | 22 | Changes for the 6th ORE release (1.8.6.0): 23 | ========================================== 24 | 25 | Updates to work with QuantLib-SWIG 1.22 26 | 27 | 28 | Changes for the 5th ORE release (1.8.5.0): 29 | ========================================== 30 | 31 | Update almost all interface files to work with QuantLib-SWIG 1.18 32 | and to use the SWIG wrapper of boost::shared_ptr. 33 | 34 | 35 | -------------------------------------------------------------------------------- /Wheels/oreanalytics-config.macos: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # On your system, the boost_thread lib may have a nonstandard name, e.g. boost_thread-mt. 4 | # If that is the case then set the BOOST_THREAD variable before calling this script, e.g: 5 | # export BOOST_THREAD=boost_thread-mt 6 | BOOST_THREAD="${BOOST_THREAD:=boost_thread}" 7 | 8 | usage="\ 9 | Usage: oreanalytics-config [--libs] [--cflags]" 10 | 11 | if test $# -eq 0; then 12 | echo "${usage}" 1>&2 13 | exit 1 14 | fi 15 | 16 | while test $# -gt 0; do 17 | case "$1" in 18 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 19 | *) optarg= ;; 20 | esac 21 | 22 | case $1 in 23 | --cflags) 24 | echo -I/usr/local/include 25 | ;; 26 | --libs) 27 | echo -L/usr/local/lib -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_regex -lboost_serialization -lboost_system -lboost_thread -lOREAnalytics -lOREData -lQuantExt -lQuantLib 28 | ;; 29 | *) 30 | echo "${usage}" 1>&2 31 | exit 1 32 | ;; 33 | esac 34 | shift 35 | done 36 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/ORE/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: iso-8859-1 -*- 2 | """ 3 | Copyright (C) 2018 Quaternion Risk Management Ltd 4 | All rights reserved. 5 | """ 6 | 7 | import sys 8 | if sys.version_info.major >= 3: 9 | from .ORE import * 10 | from .ORE import _ORE 11 | else: 12 | from ORE import * 13 | from ORE import _ORE 14 | del sys 15 | 16 | __author__ = 'Quaternion Risk Management' 17 | __email__ = 'ino@quaternion.com' 18 | 19 | if hasattr(_ORE,'__version__'): 20 | __version__ = _ORE.__version__ 21 | elif hasattr(_ORE.cvar,'__version__'): 22 | __version__ = _ORE.cvar.__version__ 23 | else: 24 | print('Could not find __version__ attribute') 25 | 26 | if hasattr(_ORE,'__hexversion__'): 27 | __hexversion__ = _ORE.__hexversion__ 28 | elif hasattr(_ORE.cvar,'__hexversion__'): 29 | __hexversion__ = _ORE.cvar.__hexversion__ 30 | else: 31 | print('Could not find __hexversion__ attribute') 32 | 33 | __license__ = """ 34 | COPYRIGHT AND PERMISSION NOTICE 35 | 36 | Copyright (c) 2018 Quaternion Risk Management Ltd 37 | All rights reserved. 38 | """ 39 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/ore_amc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | import sys, time 17 | from ORE import * 18 | 19 | print ("Loading parameters...") 20 | params = Parameters() 21 | params.fromFile("Input/ore_amc.xml") 22 | 23 | print ("Creating OREApp...") 24 | ore = OREApp(params) 25 | 26 | print ("Running ORE process...") 27 | ore.run() 28 | 29 | print ("ORE process done") 30 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/ore_classic.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | import sys, time 17 | from ORE import * 18 | 19 | print ("Loading parameters...") 20 | params = Parameters() 21 | params.fromFile("Input/ore_classic.xml") 22 | 23 | print ("Creating OREApp...") 24 | ore = OREApp(params, True) 25 | 26 | print ("Running ORE process...") 27 | ore.run() 28 | 29 | print ("ORE process done") 30 | -------------------------------------------------------------------------------- /Wheels/before_all_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 6 | echo "pwd" 7 | pwd 8 | echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 9 | 10 | CURRENT_DIR=$(pwd) 11 | 12 | #echo "XYZ BEGIN unpack eigen" 13 | #curl -O -L https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz 14 | #tar zxvf eigen-3.4.0.tar.gz 15 | #cd eigen-3.4.0 16 | #mkdir build 17 | #cd build 18 | #cmake .. 19 | #cd ../.. 20 | #echo "XYZ END unpack eigen" 21 | 22 | #echo "XYZ BEGIN unpack zlib" 23 | #curl -O -L https://www.zlib.net/zlib-1.3.1.tar.gz 24 | #tar xzvf zlib-1.3.1.tar.gz 25 | #cd zlib-1.3.1 26 | #./configure 27 | #make 28 | #cd .. 29 | #echo "XYZ END unpack zlib" 30 | 31 | echo "XYZ BEGIN unpack boost" 32 | # Setup Boost 33 | curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz 34 | tar xfz boost_1_80_0.tar.gz 35 | cd boost_1_80_0 36 | export Eigen3_DIR=$CURRENT_DIR/eigen-3.4.0 37 | ./bootstrap.sh --with-libraries=date_time,filesystem,iostreams,log,regex,serialization,system,thread,timer 38 | ./b2 install -sZLIB_SOURCE=$CURRENT_DIR/zlib-1.3.1 39 | cd .. 40 | echo "XYZ END unpack boost" -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/ore.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | import sys, time 17 | from ORE import * 18 | 19 | print ("Loading parameters...") 20 | params = Parameters() 21 | params.fromFile("Input/ore.xml") 22 | 23 | print ("Creating OREApp...") 24 | ore = OREApp(params) 25 | 26 | print ("Running ORE process...") 27 | ore.run() 28 | 29 | print("Run time: %.6f sec" % ore.getRunTime()) 30 | 31 | print ("ORE process done") 32 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/ore.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | #import sys, time 17 | from ORE import * 18 | 19 | print ("Loading parameters...") 20 | params = Parameters() 21 | params.fromFile("Input/ore_SIMM2.4_10D.xml") 22 | 23 | print ("Creating OREApp...") 24 | ore = OREApp(params, True) 25 | 26 | print ("Running ORE process..."); 27 | ore.run() 28 | 29 | print ("Running ORE process done"); 30 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/log.py: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) 2019 Quaternion Risk Manaement Ltd 3 | # All rights reserved. 4 | 5 | from ORE import * 6 | 7 | fileLogger = FileLogger("log.txt") 8 | Log.instance().registerLogger(fileLogger) 9 | 10 | mask = 7 11 | Log.instance().setMask(mask) 12 | assert mask == Log.instance().mask() 13 | 14 | Log.instance().switchOn() 15 | 16 | ALOG("Alert Message") 17 | CLOG("Critical Message") 18 | ELOG("Error Message") 19 | WLOG("Warning Message") 20 | LOG("Notice Message") 21 | DLOG("Debug Message") 22 | TLOG("Data Message") 23 | 24 | bufferLogger = BufferLogger(ORE_NOTICE) 25 | Log.instance().registerLogger(bufferLogger) 26 | mask = 255 27 | Log.instance().setMask(mask) 28 | msg_d = "This is a debug message." 29 | msg_w = "This is a warning message." 30 | msg_e = "This is an error message." 31 | DLOG(msg_d) 32 | WLOG(msg_w) 33 | ELOG(msg_e) 34 | #msg_d_buf = bufferLogger.next() filtered 35 | msg_w_buf = bufferLogger.next() 36 | msg_e_buf = bufferLogger.next() 37 | 38 | print("Printing log message ...") 39 | print(msg_w_buf) 40 | print(msg_e_buf) 41 | print("End of printing log message.") 42 | 43 | # FIFO 44 | assert msg_w in msg_w_buf 45 | assert msg_e in msg_e_buf 46 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/ore.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | import sys, time 17 | from OREAnalytics import * 18 | 19 | print ("Loading parameters...") 20 | params = Parameters() 21 | params.fromFile("Input/ore.xml") 22 | 23 | print ("Creating OREApp...") 24 | ore = OREApp(params) 25 | 26 | print ("Running ORE process...") 27 | ore.run() 28 | 29 | print("Run time: %.6f sec" % ore.getRunTime()) 30 | 31 | print ("ORE process done") 32 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_currencies.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_currencies_i 20 | #define qle_currencies_i 21 | 22 | %include currencies.i 23 | 24 | %{ 25 | using QuantLib::Currency; 26 | %} 27 | 28 | namespace QuantExt { 29 | //Metals 30 | class XAUCurrency : public Currency {}; 31 | class XAGCurrency : public Currency {}; 32 | class XPTCurrency : public Currency {}; 33 | class XPDCurrency : public Currency {}; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/oreanalytics-config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # On your system, the boost_thread lib may have a nonstandard name, e.g. boost_thread-mt. 4 | # If that is the case then set the BOOST_THREAD variable before calling this script, e.g: 5 | # export BOOST_THREAD=boost_thread-mt 6 | BOOST_THREAD="${BOOST_THREAD:=boost_thread}" 7 | 8 | usage="\ 9 | Usage: oreanalytics-config [--libs] [--cflags]" 10 | 11 | if test $# -eq 0; then 12 | echo "${usage}" 1>&2 13 | exit 1 14 | fi 15 | 16 | while test $# -gt 0; do 17 | case "$1" in 18 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 19 | *) optarg= ;; 20 | esac 21 | 22 | case $1 in 23 | --cflags) 24 | echo -I${ORE}/build/QuantLib -I${ORE}/OREAnalytics -I${ORE}/OREData -I${ORE}/QuantExt -I${ORE}/QuantLib -I${BOOST_INC} -std=c++1z 25 | ;; 26 | --libs) 27 | 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 28 | ;; 29 | *) 30 | echo "${usage}" 1>&2 31 | exit 1 32 | ;; 33 | esac 34 | shift 35 | done 36 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Java/Examples/ORERunner.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management 3 | All rights reserved. 4 | */ 5 | 6 | /*! Demo Java application */ 7 | 8 | package orerunner; 9 | 10 | import oreanalytics.*; 11 | import java.io.*; 12 | import java.nio.*; 13 | import java.util.*; 14 | 15 | public class ORERunner { 16 | 17 | /*! Load wrapper library */ 18 | 19 | static { 20 | System.loadLibrary("OREAnalyticsJava"); 21 | } 22 | 23 | /*! main method */ 24 | 25 | public static void main(String argv[]) { 26 | try { 27 | System.out.println("============================================"); 28 | System.out.println("ORE Java started..."); 29 | System.out.println("============================================"); 30 | 31 | if (argv.length < 1) { 32 | System.out.println("Usage: ORERunner path/to/ore.xml"); 33 | System.exit(0); 34 | } 35 | 36 | System.out.println("Load Application Parameters"); 37 | Parameters p = new Parameters(); 38 | p.fromFile(argv[0]); 39 | 40 | System.out.println("Initialize ORE App"); 41 | OREApp app = new OREApp(p); 42 | 43 | System.out.println("Done."); 44 | } 45 | catch(Exception e){ 46 | System.out.println("Exception caught: " + e.getMessage()); 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_4/Input/portfolio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swap 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Fixed 13 | false 14 | EUR 15 | 16 | 10000000.000000 17 | 18 | 30/360 19 | F 20 | 21 | 22 | 0.02 23 | 24 | 25 | 26 | 27 | 20151028 28 | 20351028 29 | 1Y 30 | TARGET 31 | F 32 | F 33 | Forward 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Docker/Dockerfile-ORESWIG: -------------------------------------------------------------------------------- 1 | # syntax = nexus3.acadiasoft.net:4445/docker/dockerfile:experimental 2 | ARG ore_version=latest 3 | FROM env_ore:${ore_version} 4 | 5 | MAINTAINER Quaternion Risk Management 6 | LABEL Description="Build OREPlus" 7 | 8 | # Argument for number of cores to use while building 9 | ARG num_cores 10 | 11 | # Install SWIG and python3 12 | RUN apt-get update && apt-get upgrade -y \ 13 | && apt-get install -f -y swig python3-dev \ 14 | && apt-get clean \ 15 | && rm -rf /var/lib/apt/lists/* 16 | 17 | WORKDIR /swig 18 | 19 | # Argument for number of cores to use while building 20 | ARG num_cores=1 21 | 22 | COPY ore/cmake ./cmake 23 | COPY oreswig/OREAnalytics-SWIG ./OREAnalytics-SWIG 24 | COPY oreswig/OREData-SWIG ./OREData-SWIG 25 | COPY oreswig/QuantExt-SWIG ./QuantExt-SWIG 26 | COPY oreswig/QuantLib-SWIG ./QuantLib-SWIG 27 | 28 | ENV PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/ \ 29 | PYTHON_INCLUDE_DIR=/usr/include/x86_64-linux-gnu/python3.9 30 | 31 | RUN find -regex ".*\.\(sh\|in\|ac\|am\)" -exec dos2unix {} ';' 32 | WORKDIR /swig/OREAnalytics-SWIG/Python 33 | RUN mkdir build.release 34 | WORKDIR /swig/OREAnalytics-SWIG/Python/build.release 35 | RUN cmake -DORE_ENABLE_OPENCL=ON -DORE=/swig .. 36 | RUN make -j ${num_cores} 37 | WORKDIR / 38 | RUN mkdir oreswig 39 | RUN mv /swig/OREAnalytics-SWIG/Python/build.release/ORE.py oreswig \ 40 | && mv /swig/OREAnalytics-SWIG/Python/build.release/_ORE.so oreswig 41 | 42 | ENV PYTHONPATH=/oreswig 43 | 44 | WORKDIR /swig/OREAnalytics-SWIG/Python/Examples -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_5/Input/pricingengine.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generic 5 | 6 | GaussianCam 7 | USD 8 | false 9 | 3M(1W),1Y(1M),5Y(3M),10Y(1Y),50Y(5Y) 10 | 0.0050 11 | 0.0050 12 | true 13 | true 14 | 15 | JY 16 | 17 | Generic 18 | 19 | MC 20 | 10000 21 | 4 22 | 24 23 | false 24 | 1.0 25 | false 26 | false 27 | 28 | 29 | 30 | true 31 | 32 | 33 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/ore.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2018-2023 Quaternion Risk Management Ltd 3 | 4 | This file is part of ORE, a free-software/open-source library 5 | for transparent pricing and risk analysis - http://opensourcerisk.org 6 | ORE is free software: you can redistribute it and/or modify it 7 | under the terms of the Modified BSD License. You should have received a 8 | copy of the license along with this program. 9 | The license is also available online at 10 | This program is distributed on the basis that it will form a useful 11 | contribution to risk analytics and model standardisation, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 14 | ''' 15 | 16 | import sys, time 17 | from ORE import * 18 | 19 | xml = "Input/ore.xml" 20 | params = Parameters() 21 | params.fromFile(xml) 22 | ore = OREApp(params) 23 | print ("Run ORE for", xml) 24 | ore.run() 25 | 26 | xml = "Input/ore_threshold.xml" 27 | params = Parameters() 28 | params.fromFile(xml) 29 | ore_threshold = OREApp(params) 30 | print ("Run ORE for", xml) 31 | ore_threshold.run() 32 | 33 | xml = "Input/ore_mta.xml" 34 | params = Parameters() 35 | params.fromFile(xml) 36 | ore_mta = OREApp(params) 37 | print ("Run ORE for", xml) 38 | ore_mta.run() 39 | 40 | xml = "Input/ore_mpor.xml" 41 | params = Parameters() 42 | params.fromFile(xml) 43 | ore_mpor = OREApp(params) 44 | print ("Run ORE for", xml) 45 | ore_mpor.run() 46 | 47 | print ("ORE process done") 48 | -------------------------------------------------------------------------------- /OREData-SWIG/SWIG/ored.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef ored_i 20 | #define ored_i 21 | 22 | %{ 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #ifdef BOOST_MSVC 36 | #include 37 | #endif 38 | 39 | #include 40 | 41 | %} 42 | 43 | 44 | %include ored_calendarAdjustmentConfig.i 45 | %include ored_conventions.i 46 | %include ored_loader.i 47 | %include ored_log.i 48 | %include ored_market.i 49 | %include ored_marketdatum.i 50 | %include ored_parsers.i 51 | %include ored_portfolio.i 52 | %include ored_reports.i 53 | %include ored_volcurves.i 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Input/ore_market.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market_20160205.txt 10 | fixings_20160205.txt 11 | Y 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | 17 | None 18 | 19 | 20 | libor 21 | libor 22 | libor 23 | libor 24 | libor 25 | 26 | 27 | 28 | Y 29 | default 30 | 240,1M 31 | curves.csv 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_i 20 | #define qle_i 21 | 22 | %{ 23 | #ifdef BOOST_MSVC 24 | #include 25 | #endif 26 | #include 27 | %} 28 | 29 | %include qle_common.i 30 | %include qle_calendars.i 31 | %include qle_cashflows.i 32 | %include qle_indexes.i 33 | %include qle_currencies.i 34 | %include qle_termstructures.i 35 | %include qle_crossccyfixfloatswap.i 36 | %include qle_instruments.i 37 | %include qle_ratehelpers.i 38 | %include qle_ccyswap.i 39 | %include qle_equityforward.i 40 | %include qle_averageois.i 41 | %include qle_tenorbasisswap.i 42 | %include qle_oiccbasisswap.i 43 | %include qle_creditdefaultswap.i 44 | %include qle_averageoisratehelper.i 45 | 46 | //%include qle_crossccyfixfloatswaphelper.i 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_common.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2023 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | #ifndef qle_common_i 19 | #define qle_common_i 20 | 21 | %{ 22 | #include 23 | %} 24 | 25 | 26 | #if defined(SWIGPYTHON) 27 | %typemap(in) boost::optional %{ 28 | if($input == Py_None) { 29 | $1 = boost::optional(); 30 | } 31 | else if($input == Py_True){ 32 | $1 = boost::optional(true); 33 | } else{ 34 | $1 = boost::optional(false); 35 | } 36 | %} 37 | 38 | %typemap(out) boost::optional %{ 39 | if($1) { 40 | $result = PyBool_FromBool(*$1); 41 | } 42 | else { 43 | $result = Py_None; 44 | Py_INCREF(Py_None); 45 | } 46 | %} 47 | 48 | %typecheck (QL_TYPECHECK_BOOL) boost::optional { 49 | if (PyBool_Check($input) || Py_None == $input) 50 | $1 = 1; 51 | else 52 | $1 = 0; 53 | } 54 | 55 | #endif 56 | 57 | #endif -------------------------------------------------------------------------------- /Wheels/oreanalytics-config.linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # On your system, the boost_thread lib may have a nonstandard name, e.g. boost_thread-mt. 4 | # If that is the case then set the BOOST_THREAD variable before calling this script, e.g: 5 | # export BOOST_THREAD=boost_thread-mt 6 | BOOST_THREAD="${BOOST_THREAD:=boost_thread}" 7 | 8 | usage="\ 9 | Usage: oreanalytics-config [--libs] [--cflags]" 10 | 11 | if test $# -eq 0; then 12 | echo "${usage}" 1>&2 13 | exit 1 14 | fi 15 | 16 | while test $# -gt 0; do 17 | case "$1" in 18 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 19 | *) optarg= ;; 20 | esac 21 | 22 | case $1 in 23 | --cflags) 24 | #echo -I${ORE}/OREAnalytics -I${ORE}/OREData -I${ORE}/QuantExt -I${ORE}/QuantLib -I${BOOST_INC} -std=c++1z 25 | #echo -I${ORE}/OREAnalytics -I${ORE}/OREData -I${ORE}/QuantExt -I${ORE}/QuantLib 26 | echo -I${ORE}/build/QuantLib -I${ORE}/OREAnalytics -I${ORE}/OREData -I${ORE}/QuantExt -I${ORE}/QuantLib 27 | ;; 28 | --libs) 29 | #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 30 | 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 -lboost_thread -lboost_system -lboost_serialization -lboost_date_time -lboost_regex -lboost_filesystem 31 | ;; 32 | *) 33 | echo "${usage}" 1>&2 34 | exit 1 35 | ;; 36 | esac 37 | shift 38 | done 39 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | ORE-SWIG is 2 | 3 | Copyright (C) 2018-2020 Quaternion Risk Management Ltd. 4 | Copyright (C) 2021-2022 Acadia Inc. 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met : 10 | 11 | Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | Neither the names of the copyright holders nor the names of the Open Source 19 | Risk Group or its contributors may be used to endorse or promote products 20 | derived from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/dates.py: -------------------------------------------------------------------------------- 1 | 2 | import ORE as ore 3 | 4 | startDateString = '2020-05-01' 5 | calendarString = 'Japan' 6 | tenorString = '1M' 7 | businessDayConventionString = 'F' 8 | calAdjXml = "Input/caladj.xml" 9 | 10 | startDate = ore.parseDate(startDateString) 11 | calendar = ore.parseCalendar(calendarString) 12 | tenor = ore.parsePeriod(tenorString) 13 | bdc = ore.parseBusinessDayConvention(businessDayConventionString) 14 | endOfMonth = False 15 | 16 | ## ADVANCE DATE -- pre adjustment 17 | endDate = calendar.advance(startDate, tenor, bdc, endOfMonth) 18 | print('---------------------------') 19 | print("advance start date by", tenorString) 20 | print("startDate", startDate.to_date()) 21 | print("endDate ", endDate.to_date()) 22 | 23 | ## EXPLORE QL/ORE JAPAN CALENDAR 24 | print('---------------------------') 25 | print('holidays (pre adjustment):') 26 | holidayList = calendar.holidayList(startDate, endDate) 27 | for idx in holidayList: 28 | print(idx.to_date()) 29 | 30 | ## MAKE USE OF CALENDAR ADJUSTMENT 31 | ## new holiday : 2020-06-01 32 | ## new business day (previously holiday) : 2020-05-05 33 | calAdj = ore.CalendarAdjustmentConfig() 34 | calAdj.fromFile(calAdjXml) 35 | 36 | print('---------------------------') 37 | print('holidays (post adjustment):') 38 | holidayList = calendar.holidayList(startDate, endDate) 39 | for idx in holidayList: 40 | print(idx.to_date()) 41 | 42 | ## ADVANCE DATE -- post adjustment 43 | endDate = calendar.advance(startDate, tenor, bdc, endOfMonth) 44 | print('---------------------------') 45 | print("advance start date by", tenorString) 46 | print("startDate", startDate.to_date()) 47 | print("endDate ", endDate.to_date()) 48 | print('---------------------------') 49 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/market.py: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) 2018 Quaternion Risk Manaement Ltd 3 | # All rights reserved. 4 | 5 | from ORE import * 6 | 7 | orexml = "Input/ore_market.xml" 8 | print ("Run ORE using", orexml) 9 | params = Parameters() 10 | params.fromFile(orexml) 11 | ore = OREApp(params) 12 | ore.run() 13 | 14 | # Get first analytic, there should be just one (MARKETDATA) 15 | for a in ore.getAnalyticTypes(): 16 | print ("Get analytic", a) 17 | analytic = ore.getAnalytic(a) 18 | print("Get market object from analytic", a) 19 | market = analytic.getMarket() 20 | break 21 | 22 | asof = market.asofDate(); 23 | print ("Market asof date", asof) 24 | 25 | ccy = "EUR" 26 | index = "EUR-EURIBOR-6M" 27 | print ("Get term structures for ccy ", ccy, "and index", index); 28 | 29 | discountCurve = market.discountCurve(ccy) 30 | print (" discount curve is of type", type(discountCurve)) 31 | 32 | iborIndex = market.iborIndex(index) 33 | print (" ibor index is of type", type(iborIndex)) 34 | 35 | forwardCurve = iborIndex.forwardingTermStructure() 36 | print (" forward curve is of type", type(forwardCurve)) 37 | 38 | print ("Evaluate term structures"); 39 | date = asof + 10*Years; 40 | zeroRateDc = Actual365Fixed() 41 | discount = discountCurve.discount(date) 42 | zero = discountCurve.zeroRate(date, zeroRateDc, Continuous) 43 | fwdDiscount = forwardCurve.discount(date) 44 | fwdZero = forwardCurve.zeroRate(date, zeroRateDc, Continuous) 45 | print (" 10y discount factor (discount curve) is", discount) 46 | print (" 10y discout factor (forward curve) is", fwdDiscount) 47 | print (" 10y zero rate (discount curve) is", zero) 48 | print (" 10y zero rate (forward curve) is", fwdZero) 49 | 50 | print("Done") 51 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/ore_SIMM2.4_1D.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2019-12-30 5 | Input 6 | Output/SIMM2.4_1D 7 | log.txt 8 | 255 9 | market.txt 10 | 11 | N 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | 17 | None 18 | 19 | 20 | default 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | Y 28 | 29 | 2.4 30 | crif.csv 31 | USD 32 | Y 33 | 1 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/ore_SIMM2.6_1D.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2019-12-30 5 | Input 6 | Output/SIMM2.6_1D 7 | log.txt 8 | 255 9 | market.txt 10 | 11 | N 12 | ../../Input/curveconfig.xml 13 | ../../Input/conventions.xml 14 | todaysmarket.xml 15 | ../../Input/pricingengine.xml 16 | 17 | None 18 | 19 | 20 | default 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | Y 28 | 29 | 2.6 30 | crif.csv 31 | USD 32 | Y 33 | 1 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/ore_SIMM2.4_10D.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2019-12-30 5 | Input 6 | Output/SIMM2.4_10D 7 | log.txt 8 | 255 9 | market.txt 10 | 11 | N 12 | ../../Input/curveconfig.xml 13 | ../../Input/conventions.xml 14 | todaysmarket.xml 15 | ../../Input/pricingengine.xml 16 | 17 | None 18 | 19 | 20 | default 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | Y 28 | 29 | 2.4 30 | crif.csv 31 | USD 32 | Y 33 | 10 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/ore_SIMM2.6_10D.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2019-12-30 5 | Input 6 | Output/SIMM2.6_10D 7 | log.txt 8 | 255 9 | market.txt 10 | 11 | N 12 | ../../Input/curveconfig.xml 13 | ../../Input/conventions.xml 14 | todaysmarket.xml 15 | ../../Input/pricingengine.xml 16 | 17 | None 18 | 19 | 20 | default 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | Y 28 | 29 | 2.6 30 | crif.csv 31 | USD 32 | Y 33 | 10 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/SWIG/orea.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef orea_i 20 | #define orea_i 21 | 22 | %{ 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | #ifdef BOOST_MSVC 37 | #include 38 | #define BOOST_LIB_NAME boost_regex 39 | #include 40 | #define BOOST_LIB_NAME boost_serialization 41 | #include 42 | #define BOOST_LIB_NAME boost_date_time 43 | #include 44 | #define BOOST_LIB_NAME boost_filesystem 45 | #include 46 | #define BOOST_LIB_NAME boost_system 47 | #include 48 | #endif 49 | 50 | %} 51 | 52 | %init %{ 53 | ore::analytics::initBuilders(); 54 | %} 55 | 56 | %include 57 | 58 | %include orea_app.i 59 | %include orea_cube.i 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /OREData-SWIG/SWIG/ored_reports.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2023 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef ored_reports_i 20 | #define ored_reports_i 21 | 22 | %include boost_shared_ptr.i 23 | 24 | %{ 25 | using ore::data::InMemoryReport; 26 | using ore::data::PlainInMemoryReport; 27 | %} 28 | 29 | %shared_ptr(PlainInMemoryReport) 30 | class PlainInMemoryReport { 31 | public: 32 | PlainInMemoryReport(const ext::shared_ptr& imReport); 33 | Size columns() const; 34 | std::string header(Size i); 35 | Size columnType(Size i) const; 36 | std::vector dataAsSize(Size i) const; 37 | std::vector dataAsReal(Size i) const; 38 | std::vector dataAsString(Size i) const; 39 | std::vector dataAsDate(Size i) const; 40 | std::vector dataAsPeriod(Size i) const; 41 | Size rows() const; 42 | int dataAsSize(Size j, Size i) const; 43 | Real dataAsReal(Size j, Size i) const; 44 | std::string dataAsString(Size j, Size i) const; 45 | QuantLib::Date dataAsDate(Size j, Size i) const; 46 | QuantLib::Period dataAsPeriod(Size j, Size i) const; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/todaysmarket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | xois_eur 5 | xois_eur 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /OREData-SWIG/SWIG/ored_calendarAdjustmentConfig.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2023 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef ored_CalendarAdjustmentConfig_i 20 | #define ored_CalendarAdjustmentConfig_i 21 | 22 | %{ 23 | 24 | using ore::data::CalendarAdjustmentConfig; 25 | using std::map; 26 | using std::set; 27 | using std::string; 28 | using std::vector; 29 | using QuantLib::DateGeneration; 30 | using QuantLib::Calendar; 31 | %} 32 | 33 | %shared_ptr(CalendarAdjustmentConfig) 34 | class CalendarAdjustmentConfig { 35 | public: 36 | 37 | CalendarAdjustmentConfig(); 38 | 39 | void addHolidays(const string& calname, const Date& d); 40 | 41 | void addBusinessDays(const string& calname, const Date& d); 42 | 43 | void addBaseCalendar(const string& calname, const string& d); 44 | 45 | const set& getHolidays(const string& calname); 46 | 47 | const set& getBusinessDays(const string& calname); 48 | 49 | set getCalendars() const; 50 | 51 | const string& getBaseCalendar(const string& calname); 52 | 53 | void append(const CalendarAdjustmentConfig& c); 54 | 55 | void fromFile(const std::string& name); 56 | 57 | }; 58 | 59 | 60 | #endif -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_4/pca.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | import csv 4 | 5 | def run_pca(): 6 | 7 | # these must match the yield curve tenors in simulation.xml 8 | curve_times = [1, 2, 3, 5, 10, 15, 20, 30] 9 | 10 | # load the scenariodump.csv into a dataframe 11 | data = pd.read_csv('Output/scenariodump.csv') 12 | 13 | # just keep the discount factors 14 | data = data.iloc[:, 3:] 15 | 16 | # convert to zero rates 17 | data = -np.log(data).div(curve_times) 18 | 19 | # take differences 20 | data = data.diff().iloc[1:,:] 21 | 22 | # subtract the means 23 | data = data - data.mean() 24 | 25 | # build the covariance matrix 26 | cov = 252.0 / len(data) * np.dot(data.T, data) 27 | 28 | # get the eigne vectors and values 29 | eigenvalues, eigenvectors = np.linalg.eig(cov) 30 | 31 | # output results 32 | with open('Output/eigenvalues.csv', 'w', newline='') as file1: 33 | writer = csv.writer(file1, delimiter=',') 34 | writer.writerow(['number', 'value']) 35 | no = 1 36 | for v in eigenvalues: 37 | writer.writerow([no, v]) 38 | no = no + 1 39 | 40 | with open('Output/eigenvectors.csv', 'w', newline='') as file2: 41 | writer = csv.writer(file2, delimiter=',') 42 | header = ['tenor'] 43 | no = 1 44 | for t in eigenvectors: 45 | header.append('eigenvector_' + str(no)) 46 | no = no +1 47 | writer.writerow(header) 48 | index = 0 49 | for v in eigenvectors: 50 | data = [curve_times[index]] + list(v) 51 | writer.writerow(data) 52 | index = index + 1 53 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/ore.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | Y 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio.xml 17 | None 18 | 19 | 20 | default 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | Y 28 | EUR 29 | npv.csv 30 | 31 | 32 | Y 33 | flows.csv 34 | 35 | 36 | Y 37 | default 38 | 240,1M 39 | curves.csv 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /runCmakeVS.cmd: -------------------------------------------------------------------------------- 1 | REM This scripts build ORE and ORE_SWIG 2 | REM Adjust paths 3 | SET GENERATOR="Visual Studio 17 2022" 4 | SET DEMO_BOOST_ROOT=C:\local\boost_1_72_0 5 | SET DEMO_BOOST_LIB=C:\local\boost_1_72_0\lib64-msvc-14.2 6 | SET DEMO_SWIG_DIR=C:\dev\swigwin-4.1.1 7 | SET DEMO_ORE_DIR=C:\dev\ore 8 | SET DEMO_ORE_SWIG_DIR=C:\dev\oreswig 9 | REM the next path is optional, but if not set, one need to set -DORE_USE_ZLIB=OFF 10 | SET DEMO_ZLIB_ROOT=C:\dev\vcpkg\packages\zlib_x64-windows 11 | REM SET VCPKG_ROOT=C:\dev\vcpkg 12 | REM If you use VCPKG for zlib and eigen, add -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake to the cmake command 13 | 14 | 15 | REM building ORE, one can skip this part, make sure to delete the build dir in the ORE_DIR if there is any 16 | REM it is recommended to install the eigen and zlib library on the system before building ORE 17 | ECHO BUILD ORE 18 | cd %DEMO_ORE_DIR% 19 | mkdir build 20 | cd %DEMO_ORE_DIR%\build 21 | SET BOOST_INCLUDEDIR=%DEMO_BOOST_ROOT% 22 | SET BOOST_LIBRARYDIR=%DEMO_BOOST_LIB% 23 | SET ZLIB_ROOT=%DEMO_ZLIB_ROOT% 24 | cmake -G %GENERATOR% -A x64 .. -DMSVC_LINK_DYNAMIC_RUNTIME=OFF -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_TESTS=OFF -DORE_BUILD_APP=OFF -DQL_BUILD_BENCHMARK=OFF -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF -DCMAKE_BUILD_TYPE=Release -DORE_USE_ZLIB=ON -DQL_ENABLE_SESSIONS=ON -DBoost_NO_SYSTEM_PATHS=ON 25 | 26 | cd %DEMO_ORE_DIR%\build 27 | cmake --build . --config Release 28 | 29 | ECHO BUILD ORESWIG 30 | cd %DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python 31 | mkdir build 32 | cd build 33 | SET BOOST_INCLUDEDIR=%DEMO_BOOST_ROOT% 34 | SET BOOST_LIBRARYDIR=%DEMO_BOOST_LIB% 35 | SET SWIG_ROOT=%DEMO_SWIG_DIR% 36 | SET ZLIB_ROOT=%DEMO_ZLIB_ROOT% 37 | cmake -Wno-dev -G %GENERATOR% -A x64 .. -DORE=%DEMO_ORE_DIR% -DMSVC_LINK_DYNAMIC_RUNTIME=OFF -DORE_USE_ZLIB=ON -DBoost_NO_SYSTEM_PATHS=ON 38 | cmake --build . --config Release 39 | 40 | REM now set your python path to build dir 41 | SET PYTHONPATH=%DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\build;%DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\build\Release 42 | 43 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/portfolio.py: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) 2018 Quaternion Risk Manaement Ltd 3 | # All rights reserved. 4 | 5 | from ORE import * 6 | import xml.etree.ElementTree as ET 7 | import os 8 | 9 | orexml = "Input/ore_market.xml" 10 | print ("Load parameters from", orexml) 11 | params = Parameters() 12 | params.fromFile(orexml) 13 | 14 | print ("Build ORE App...") 15 | ore = OREApp(params) 16 | print ("Run ORE to build inputs...") 17 | ore.run() 18 | inputs = ore.getInputs() 19 | 20 | print ("Get the portfolio from xml...") 21 | portfolioFile = os.path.join("Input","portfolio.xml") 22 | portfolioXml = ET.parse(portfolioFile).getroot() 23 | portfolioXmlStr = ET.tostring(portfolioXml,encoding="unicode") 24 | 25 | print ("Add the portfolio and request NPV...") 26 | inputs.setPortfolio(portfolioXmlStr) 27 | inputs.insertAnalytic("NPV") 28 | 29 | print ("Run ORE process...") 30 | ore.run() 31 | 32 | print ("Get NPV analytic...") 33 | analytic = ore.getAnalytic("NPV") 34 | print("Get the built portfolio from the NPV analytic") 35 | portfolio = analytic.portfolio(); 36 | 37 | portfolioSize = portfolio.size() 38 | #print("...portfolio.size() is of type", type(portfolioSize)) 39 | print("... portfolio size = ", str(portfolioSize)) 40 | ids = portfolio.ids(); 41 | for id in ids: 42 | print(id) 43 | trn = portfolio.get(id) 44 | #print(" trn is of type ", type(trn)) 45 | print(" trade id = ", trn.id()) 46 | print(" trade type is ", trn.tradeType()) 47 | print(" trade notional is ", trn.notional()) 48 | pgInst = trn.instrument() 49 | #print(" inst type is ", type(pgInst)) 50 | trnPv = pgInst.NPV() 51 | print(" instWrap pv = ", str(trnPv)) 52 | qlInst = pgInst.qlInstrument() 53 | #print(" qlInst is of type ", type(qlInst)) 54 | qlPv = qlInst.NPV() 55 | print(" qlInst pv = ", str(qlPv)) 56 | isExp = qlInst.isExpired() 57 | print(" is expired? = ", isExp) 58 | legPg = trn.legs() 59 | #print(" legsVec is of type ", type(legPg)) 60 | for leg in legPg: 61 | #print(" leg is of type ", type(leg)) 62 | for flow in leg: 63 | print(" flow as of ", flow.date().ISO(), " is ", flow.amount()) 64 | 65 | print("Done.") 66 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/quantext.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #if defined(SWIGRUBY) 20 | %module QuantExtc 21 | #elif defined(SWIGCSHARP) 22 | %module(directors="1") NQuantExtc 23 | #elif defined(SWIGJAVA) 24 | %module(directors="1") QuantExt 25 | #else 26 | %module QuantExt 27 | #endif 28 | 29 | %include exception.i 30 | 31 | %exception { 32 | try { 33 | $action 34 | } catch (std::out_of_range& e) { 35 | SWIG_exception(SWIG_IndexError,const_cast(e.what())); 36 | } catch (std::exception& e) { 37 | SWIG_exception(SWIG_RuntimeError,const_cast(e.what())); 38 | } catch (...) { 39 | SWIG_exception(SWIG_UnknownError,"unknown error"); 40 | } 41 | } 42 | 43 | #if defined(SWIGPYTHON) 44 | %{ 45 | #include 46 | const int __hexversion__ = OPEN_SOURCE_RISK_VERSION_NUM; 47 | const char* __version__ = OPEN_SOURCE_RISK_VERSION; 48 | %} 49 | 50 | const int __hexversion__; 51 | %immutable; 52 | const char* __version__; 53 | %mutable; 54 | #endif 55 | 56 | #if defined(JAVA_AUTOLOAD) 57 | // Automatically load the shared library for JAVA binding 58 | %pragma(java) jniclasscode=%{ 59 | /// Load the JNI library 60 | static { 61 | System.loadLibrary("QuantExtJNI"); 62 | } 63 | %} 64 | #endif 65 | 66 | //#if defined(SWIGPYTHON) 67 | //%feature("autodoc"); 68 | //#endif 69 | 70 | // include all quantlib .i's 71 | %include ql.i 72 | 73 | // include all quantext .i's 74 | %include qle.i 75 | -------------------------------------------------------------------------------- /OREData-SWIG/SWIG/oredata.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #if defined(SWIGRUBY) 20 | %module OREDatac 21 | #elif defined(SWIGCSHARP) 22 | %module(directors="1") NOREDatac 23 | #elif defined(SWIGJAVA) 24 | %module(directors="1") OREData 25 | #else 26 | %module OREData 27 | #endif 28 | 29 | %include exception.i 30 | 31 | %exception { 32 | try { 33 | $action 34 | } catch (std::out_of_range& e) { 35 | SWIG_exception(SWIG_IndexError,const_cast(e.what())); 36 | } catch (std::exception& e) { 37 | SWIG_exception(SWIG_RuntimeError,const_cast(e.what())); 38 | } catch (...) { 39 | SWIG_exception(SWIG_UnknownError,"unknown error"); 40 | } 41 | } 42 | 43 | #if defined(SWIGPYTHON) 44 | %{ 45 | #include 46 | const int __hexversion__ = OPEN_SOURCE_RISK_VERSION_NUM; 47 | const char* __version__ = OPEN_SOURCE_RISK_VERSION; 48 | %} 49 | 50 | const int __hexversion__; 51 | %immutable; 52 | const char* __version__; 53 | %mutable; 54 | #endif 55 | 56 | #if defined(JAVA_AUTOLOAD) 57 | // Automatically load the shared library for JAVA binding 58 | %pragma(java) jniclasscode=%{ 59 | /// Load the JNI library 60 | static { 61 | System.loadLibrary("OREDataJNI"); 62 | } 63 | %} 64 | #endif 65 | 66 | //#if defined(SWIGPYTHON) 67 | //%feature("autodoc"); 68 | //#endif 69 | 70 | // include all quantlib .i's 71 | %include ql.i 72 | 73 | // include all quantext .i's 74 | %include qle.i 75 | 76 | // include all OREData .i's 77 | %include ored.i 78 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/commodityforward.py: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) 2018 Quaternion Risk Manaement Ltd 3 | # All rights reserved. 4 | 5 | from ORE import * 6 | 7 | def formatPrice(p,digits=2): 8 | format = '%%.%df' % digits 9 | return format % p 10 | 11 | # global data 12 | calendar = TARGET() 13 | todaysDate = Date(4, October, 2018); 14 | Settings.instance().evaluationDate = todaysDate 15 | 16 | # instrument 17 | name = "Natural Gas"; 18 | currency = GBPCurrency(); 19 | strikePrice = 100.0; 20 | quantity = 1.0; 21 | position = Position.Long; 22 | 23 | maturityDate = Date(4, October, 2022); 24 | 25 | # market 26 | dates = [ Date(20,12,2018), 27 | Date(20, 3,2019), 28 | Date(19, 6,2019), 29 | Date(18, 9,2019), 30 | Date(18,12,2019), 31 | Date(19, 3,2020), 32 | Date(18, 6,2020), 33 | Date(17, 9,2020), 34 | Date(17,12,2020) ] 35 | 36 | quotes = [ QuoteHandle(SimpleQuote(100.0)), 37 | QuoteHandle(SimpleQuote(100.25)), 38 | QuoteHandle(SimpleQuote(100.75)), 39 | QuoteHandle(SimpleQuote(101.0)), 40 | QuoteHandle(SimpleQuote(101.25)), 41 | QuoteHandle(SimpleQuote(101.50)), 42 | QuoteHandle(SimpleQuote(101.75)), 43 | QuoteHandle(SimpleQuote(102.0)), 44 | QuoteHandle(SimpleQuote(102.25)) ] 45 | 46 | tsDayCounter = Actual365Fixed() 47 | currency = EURCurrency(); 48 | 49 | # price curve 50 | priceCurve = LinearInterpolatedPriceCurve(todaysDate, dates, quotes, tsDayCounter, currency); 51 | priceCurve.enableExtrapolation(); 52 | priceTermStructure = RelinkablePriceTermStructureHandle(); 53 | priceTermStructure.linkTo(priceCurve) 54 | 55 | # discount curve 56 | flatForward = FlatForward(todaysDate, 0.03, tsDayCounter); 57 | discountTermStructure = RelinkableYieldTermStructureHandle() 58 | discountTermStructure.linkTo(flatForward) 59 | 60 | engine = DiscountingCommodityForwardEngine(discountTermStructure) 61 | 62 | index = CommoditySpotIndex(name, calendar, priceTermStructure) 63 | instrument = CommodityForward(index, currency, position, quantity, maturityDate, strikePrice); 64 | 65 | instrument.setPricingEngine(engine) 66 | 67 | print("Commodity Forward, Name='" + name + "', NPV=" + formatPrice(instrument.NPV()) + " " + instrument.currency().code()) 68 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/ore.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1. Setup Node <--> 4 | 5 | 1.A Valuation Date <--> 6 | 2016-02-05 7 | 8 | 1.B Input/Ouptut Folders Name <--> 9 | Input 10 | Output 11 | 12 | 1.C Path of the 7 mandatory input files <--> 13 | market.txt 14 | fixings.txt 15 | curveconfig.xml 16 | conventions.xml 17 | todaysmarket.xml 18 | pricingengine.xml 19 | portfolio.xml 20 | 21 | 1.D Other Pricing Parameters <--> 22 | None 23 | log.txt 24 | 31 25 | Y 26 | 27 | 28 | 2. Markets Node <--> 29 | 30 | default 31 | default 32 | default 33 | default 34 | 35 | 36 | 3. Analytics Node <--> 37 | 38 | 39 | Y 40 | EUR 41 | npv.csv 42 | 43 | 44 | Y 45 | flows.csv 46 | 47 | 48 | Y 49 | default 50 | 240,1M 51 | curves.csv 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_averageoisratehelper.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_averageoisratehelper_i 20 | #define qle_averageoisratehelper_i 21 | 22 | %include instruments.i 23 | %include termstructures.i 24 | %include cashflows.i 25 | %include timebasket.i 26 | %include indexes.i 27 | %include qle_averageois.i 28 | 29 | %{ 30 | using QuantExt::AverageOISRateHelper; 31 | %} 32 | 33 | %shared_ptr(AverageOISRateHelper) 34 | class AverageOISRateHelper : public RateHelper { 35 | public: 36 | AverageOISRateHelper(const QuantLib::Handle& fixedRate, 37 | const QuantLib::Period& spotLagTenor, 38 | const QuantLib::Period& swapTenor, 39 | const QuantLib::Period& fixedTenor, 40 | const QuantLib::DayCounter& fixedDayCounter, 41 | const QuantLib::Calendar& fixedCalendar, 42 | QuantLib::BusinessDayConvention fixedConvention, 43 | QuantLib::BusinessDayConvention fixedPaymentAdjustment, 44 | ext::shared_ptr& overnightIndex, 45 | const QuantLib::Period& onTenor, 46 | const QuantLib::Handle& onSpread, 47 | QuantLib::Natural rateCutoff, 48 | const QuantLib::Handle& discountCurve = QuantLib::Handle()); 49 | QuantLib::Real onSpread() const; 50 | ext::shared_ptr averageOIS() const; 51 | }; 52 | 53 | #endif 54 | 55 | 56 | -------------------------------------------------------------------------------- /Docker/Dockerfile-ORESWIG-App: -------------------------------------------------------------------------------- 1 | #syntax = nexus3.acadiasoft.net:4445/docker/dockerfile:experimental 2 | 3 | ARG ore_version=latest 4 | ARG debian_tag=latest 5 | 6 | FROM env_oreswig:${ore_version} as env_oreswig 7 | FROM env_ore:${ore_version} as env_ore 8 | FROM debian:${debian_tag} 9 | 10 | RUN apt-get update \ 11 | && DEBIAN_FRONTEND=noninteractive apt-get install -y dos2unix python3 python3-pip vim \ 12 | && apt-get clean \ 13 | && rm -rf /var/lib/apt/lists/* 14 | 15 | RUN pip3 install matplotlib pandas nose nose_xunitmp datacompy jupyter jsondiff xmldiff numpy scipy ipywidgets 16 | 17 | WORKDIR / 18 | RUN mkdir /oreswig 19 | RUN mkdir /oreswig/pythonlib 20 | 21 | COPY --from=env_oreswig /oreswig/ORE.py /oreswig/pythonlib/ORE.py 22 | COPY --from=env_oreswig /oreswig/_ORE.so /oreswig/pythonlib/_ORE.so 23 | 24 | COPY --from=env_ore /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu 25 | 26 | RUN true 27 | 28 | COPY --from=env_ore /usr/local/lib /usr/local/lib 29 | 30 | ENV PYTHONPATH=/oreswig/pythonlib 31 | ENV LD_LIBRARY_PATH=/usr/local/lib 32 | 33 | RUN mkdir /oreswig/tests 34 | 35 | COPY oreswig/QuantLib-SWIG/Python/test /oreswig/tests/QuantLibTestSuite 36 | # Delete the init.py otherwise nosetest will not pick up all the tests 37 | RUN rm oreswig/tests/QuantLibTestSuite/__init__.py 38 | COPY oreswig/OREAnalytics-SWIG/Python/test /oreswig/tests/ORETestSuite 39 | COPY oreswig/OREAnalytics-SWIG/Python/Examples /oreswig/example_scripts 40 | # due to relative path imports in the notebooks, we need to copy utilities.py directly into the example folder 41 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_1 42 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_2 43 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_3 44 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_4 45 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_5 46 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_6 47 | RUN cp oreswig/example_scripts/Notebooks/utilities.py oreswig/example_scripts/Notebooks/Example_7 48 | COPY ore/Examples /oreswig/Examples 49 | COPY ore/Tools /oreswig/Tools 50 | # Set env variable to run the ore examples with the python interface instead of the executable 51 | ENV ORE_EXAMPLES_USE_PYTHON=1 52 | 53 | CMD bash -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Input/portfolio_swap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swap 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Fixed 13 | false 14 | EUR 15 | 16 | 10000000.000000 17 | 18 | 30/360 19 | F 20 | 21 | 22 | 0.02 23 | 24 | 25 | 26 | 27 | 20160301 28 | 20360301 29 | 1Y 30 | TARGET 31 | F 32 | F 33 | Forward 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Floating 42 | true 43 | EUR 44 | 45 | 10000000.000000 46 | 47 | A360 48 | MF 49 | 50 | EUR-EURIBOR-6M 51 | 52 | 0.000000 53 | 54 | false 55 | 2 56 | 57 | 58 | 59 | 20160301 60 | 20360301 61 | 6M 62 | TARGET 63 | MF 64 | MF 65 | Forward 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_ccyswap.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_ccyswap_i 20 | #define qle_ccyswap_i 21 | 22 | %include qle_currencies.i 23 | %include instruments.i 24 | %include termstructures.i 25 | %include money.i 26 | %include marketelements.i 27 | %include exchangerates.i 28 | 29 | %{ 30 | using QuantExt::CrossCcySwap; 31 | %} 32 | 33 | %shared_ptr(CrossCcySwap) 34 | class CrossCcySwap : public Swap { 35 | public: 36 | CrossCcySwap(const QuantLib::Leg& firstLeg, 37 | const QuantLib::Currency& firstLegCcy, 38 | const QuantLib::Leg& secondLeg, 39 | const QuantLib::Currency& secondLegCcy); 40 | CrossCcySwap(const std::vector& legs, 41 | const std::vector& payer, 42 | const std::vector& currencies); 43 | }; 44 | 45 | %{ 46 | using QuantExt::CrossCcySwapEngine; 47 | %} 48 | 49 | %shared_ptr(CrossCcySwapEngine) 50 | class CrossCcySwapEngine : public PricingEngine { 51 | public: 52 | CrossCcySwapEngine(const QuantLib::Currency& ccy1, 53 | const QuantLib::Handle& currency1DiscountCurve, 54 | const QuantLib::Currency& ccy2, 55 | const QuantLib::Handle& currency2DiscountCurve, 56 | const QuantLib::Handle& spotFX, 57 | boost::optional includeSettlementDateFlows = boost::none, 58 | const QuantLib::Date& settlementDate = QuantLib::Date(), 59 | const QuantLib::Date& npvDate = QuantLib::Date()); 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/portfolio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swap 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Fixed 13 | false 14 | EUR 15 | 16 | 10000000.000000 17 | 18 | A360 19 | MF 20 | 21 | 22 | 0.021 23 | 24 | 25 | 26 | 27 | 20160209 28 | 20360209 29 | 1Y 30 | TARGET 31 | MF 32 | MF 33 | Forward 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Floating 42 | true 43 | EUR 44 | 45 | 10000000.000000 46 | 47 | A360 48 | MF 49 | 50 | EUR-EURIBOR-6M 51 | 52 | 0.000000 53 | 54 | false 55 | 2 56 | 57 | 58 | 59 | 20160209 60 | 20360209 61 | 6M 62 | TARGET 63 | MF 64 | MF 65 | Forward 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_4/Input/simulation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5000,1D 5 | EUR 6 | MersenneTwister 7 | Simple 8 | 42 9 | 1 10 | Steps 11 | JoeKuoD7 12 | 13 | 14 | EUR 15 | 16 | EUR 17 | 18 | 0.0001 19 | Euler 20 | BA 21 | 22 | 23 | None 24 | 25 | N 26 | Constant 27 | 28 | 29 | 30 | 0.002474873734151,0,0,0 31 | 0,0,0.000706612189017,-0.00298902380928 32 | 33 | 34 | 35 | 36 | N 37 | Constant 38 | 39 | 40 | -0.000000048673,-0.24532070948,-0.056427887126,0.510590372873 41 | 42 | 43 | 44 | 45 | 46 | 47 | EUR 48 | None 49 | 50 | N 51 | Constant 52 | 53 | 0.1 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | EUR 62 | 63 | EUR 64 | 65 | 66 | 67 | 1Y,2Y,3Y,5Y,10Y,15Y,20Y,30Y 68 | LogLinear 69 | Y 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/portfolio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swap 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Fixed 13 | false 14 | EUR 15 | 16 | 10000000.000000 17 | 18 | A360 19 | MF 20 | 21 | 22 | 0.021 23 | 24 | 25 | 26 | 27 | 20160209 28 | 20360209 29 | 1Y 30 | TARGET 31 | MF 32 | MF 33 | Forward 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Floating 42 | true 43 | EUR 44 | 45 | 10000000.000000 46 | 47 | A360 48 | MF 49 | 50 | EUR-EURIBOR-6M 51 | 52 | 0.000000 53 | 54 | false 55 | 2 56 | 57 | 58 | 59 | 20160209 60 | 20360209 61 | 6M 62 | TARGET 63 | MF 64 | MF 65 | Forward 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/netting_mpor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | true 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 0 13 | 0 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | true 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 0 42 | 0 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/market.txt: -------------------------------------------------------------------------------- 1 | # Example of a minimal market data file 2 | 3 | # Single zero rate per yield curve (flat) 4 | 20160205 ZERO/RATE/EUR/EUR1D/A360/1Y 0.020 5 | 20160205 ZERO/RATE/EUR/EUR6M/A360/1Y 0.021 6 | 20160205 ZERO/RATE/GBP/GBP1D/A365F/1Y 0.025 7 | 20160205 ZERO/RATE/GBP/GBP6M/A365F/1Y 0.026 8 | 9 | # Single swaption volatility 10 | 20160205 SWAPTION/RATE_LNVOL/EUR/1Y/1Y/ATM 0.1 11 | 20160205 SWAPTION/RATE_NVOL/GBP/1Y/1Y/ATM 0.0015 12 | 13 | # FX Spot rate 14 | 20160205 FX/RATE/EUR/GBP 0.811938 15 | 16 | # FX Vol, need two points here (TODO:fix this) 17 | 20160205 FX_OPTION/RATE_LNVOL/EUR/GBP/1Y/ATM 0.129775 18 | 20160205 FX_OPTION/RATE_LNVOL/EUR/GBP/10Y/ATM 0.132277 19 | 20 | # Credit Curve (RR and CDS quote) 21 | 20160205 RECOVERY_RATE/RATE/BANK/SR/EUR 0.4 22 | 20160205 CDS/CREDIT_SPREAD/BANK/SR/EUR/1Y 0.01 23 | 24 | # Credit Curve with flat hazard rate (RR needed for XVA) 25 | 20160205 RECOVERY_RATE/RATE/CPTY_A/SR/EUR 0.4 26 | 20160205 HAZARD_RATE/RATE/CPTY_A/SR/EUR/1Y 0.01 27 | 28 | # 29 | 20160205 MM/RATE/USD/0D/1D 0.00448 30 | 20160205 IR_SWAP/RATE/USD/0D/1D/1D 0.004502 31 | 20160205 IR_SWAP/RATE/USD/2D/1D/1M 0.004458 32 | 20160205 IR_SWAP/RATE/USD/2D/1D/1W 0.004473 33 | 20160205 IR_SWAP/RATE/USD/0D/1D/2D 0.005616 34 | 20160205 IR_SWAP/RATE/USD/2D/1D/2M 0.00479 35 | 20160205 IR_SWAP/RATE/USD/2D/1D/2W 0.004587 36 | 20160205 IR_SWAP/RATE/USD/2D/1D/3M 0.004851 37 | 20160205 IR_SWAP/RATE/USD/2D/1D/3W 0.004491 38 | 20160205 IR_SWAP/RATE/USD/2D/1D/4M 0.004863 39 | 20160205 IR_SWAP/RATE/USD/2D/1D/5M 0.004999 40 | 20160205 IR_SWAP/RATE/USD/2D/1D/6M 0.005237 41 | 20160205 IR_SWAP/RATE/USD/2D/1D/7M 0.005175 42 | 20160205 IR_SWAP/RATE/USD/2D/1D/8M 0.005371 43 | 20160205 IR_SWAP/RATE/USD/2D/1D/9M 0.005471 44 | 20160205 IR_SWAP/RATE/USD/2D/1D/10M 0.005521 45 | 20160205 IR_SWAP/RATE/USD/2D/1D/11M 0.005605 46 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y 0.005614 47 | 20160205 IR_SWAP/RATE/USD/2D/1D/2Y 0.006433 48 | 20160205 IR_SWAP/RATE/USD/2D/1D/3Y 0.007101 49 | 20160205 IR_SWAP/RATE/USD/2D/1D/4Y 0.008264 50 | 20160205 IR_SWAP/RATE/USD/2D/1D/5Y 0.009269 51 | 20160205 IR_SWAP/RATE/USD/2D/1D/7Y 0.011035 52 | 20160205 IR_SWAP/RATE/USD/2D/1D/10Y 0.013318 53 | 20160205 IR_SWAP/RATE/USD/2D/1D/12Y 0.01459 54 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y3M 0.005857 55 | 20160205 IR_SWAP/RATE/USD/2D/1D/15Y 0.016029 56 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y6M 0.006054 57 | 20160205 IR_SWAP/RATE/USD/2D/1D/20Y 0.01734 58 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y9M 0.006097 59 | 20160205 IR_SWAP/RATE/USD/2D/1D/25Y 0.01804 60 | 20160205 IR_SWAP/RATE/USD/2D/1D/30Y 0.018326 61 | 20160205 IR_SWAP/RATE/USD/2D/1D/50Y 0.0182 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | false 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 50000 13 | 50000 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | true 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 5000000 42 | 5000000 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | false 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 50000 13 | 50000 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | false 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 5000000 42 | 5000000 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_4/Input/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | false 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 100000 11 | 100000 12 | 0 13 | 0 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 0W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | true 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 5000000 42 | 5000000 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/netting_mta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | true 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 1000000 13 | 1000000 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | true 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 1000000 42 | 1000000 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/bak/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | false 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 50000 13 | 50000 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | 31 | 32 | 33 | CPTY_B 34 | false 35 | 36 | Bilateral 37 | EUR 38 | EUR-EONIA 39 | 0 40 | 0 41 | 5000000 42 | 5000000 43 | 44 | 0 45 | FIXED 46 | 47 | 48 | 1D 49 | 1D 50 | 51 | 2W 52 | 0.00 53 | 0.00 54 | 55 | 56 | EUR 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/SWIG/oreanalytics.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | %begin %{ 20 | #ifdef _MSC_VER 21 | # define SWIG_PYTHON_INTERPRETER_NO_DEBUG 22 | # ifdef ORE_USE_ZLIB 23 | # define BOOST_LIB_NAME boost_iostreams 24 | # include "boost/config/auto_link.hpp" 25 | # define BOOST_LIB_NAME boost_zlib 26 | # include "boost/config/auto_link.hpp" 27 | # endif 28 | #endif 29 | %} 30 | 31 | #if defined(SWIGCSHARP) 32 | %module(directors="1") NOREAnalyticsc 33 | #elif defined(SWIGJAVA) 34 | %module(directors="1") OREAnalytics 35 | #else 36 | %module ORE 37 | #endif 38 | 39 | %include exception.i 40 | 41 | %exception { 42 | try { 43 | $action 44 | } catch (std::out_of_range& e) { 45 | SWIG_exception(SWIG_IndexError,const_cast(e.what())); 46 | } catch (std::exception& e) { 47 | SWIG_exception(SWIG_RuntimeError,const_cast(e.what())); 48 | } catch (...) { 49 | SWIG_exception(SWIG_UnknownError,"unknown error"); 50 | } 51 | } 52 | 53 | #if defined(SWIGPYTHON) 54 | %{ 55 | #include 56 | const int __hexversion__ = OPEN_SOURCE_RISK_VERSION_NUM; 57 | const char* __version__ = OPEN_SOURCE_RISK_VERSION; 58 | %} 59 | 60 | const int __hexversion__; 61 | %immutable; 62 | const char* __version__; 63 | %mutable; 64 | #endif 65 | 66 | #if defined(JAVA_AUTOLOAD) 67 | // Automatically load the shared library for JAVA binding 68 | %pragma(java) jniclasscode=%{ 69 | /// Load the JNI library 70 | static { 71 | System.loadLibrary("OREAnalyticsJNI"); 72 | } 73 | %} 74 | #endif 75 | 76 | //#if defined(SWIGPYTHON) 77 | //%feature("autodoc"); 78 | //#endif 79 | 80 | // include all quantlib .i's 81 | %include ql.i 82 | 83 | // include all quantext .i's 84 | %include qle.i 85 | 86 | // include all OREData .i's 87 | %include ored.i 88 | 89 | // include all OREAnalytics .i's 90 | %include orea.i 91 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_1/Input/todaysmarket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | default 6 | default 7 | 8 | 9 | 10 | Yield/EUR/EUR1D 11 | Yield/EUR/EUR1D 12 | 13 | 14 | 15 | Yield/EUR/EUR1D 16 | Yield/GBP/GBP1D 17 | Yield/USD/USD1D 18 | 19 | 20 | 21 | Yield/EUR/EUR6M 22 | Yield/EUR/EUR1D 23 | Yield/GBP/GBP1D 24 | Yield/GBP/GBP6M 25 | Yield/GBP/GBP6M 26 | 27 | 28 | 29 | 30 | EUR-EONIA 31 | 32 | 33 | EUR-EONIA 34 | 35 | 36 | GBP-SONIA 37 | 38 | 39 | GBP-SONIA 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | FX/EUR/GBP 51 | 52 | 53 | 54 | FXVolatility/EUR/GBP/EURGBP 55 | 56 | 57 | 58 | SwaptionVolatility/EUR/EUR_SWPTN 59 | SwaptionVolatility/GBP/GBP_SWPTN 60 | 61 | 62 | 63 | Default/EUR/BANK_SR_EUR 64 | Default/EUR/CPTY_A_SR_EUR 65 | Default/EUR/CPTY_A_SR_EUR 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/market.txt: -------------------------------------------------------------------------------- 1 | # Example of a minimal market data file 2 | 3 | # Single zero rate per yield curve (flat) 4 | 20160205 ZERO/RATE/EUR/EUR1D/A360/1Y 0.020 5 | 20160205 ZERO/RATE/EUR/EUR6M/A360/1Y 0.021 6 | 20160205 ZERO/RATE/GBP/GBP1D/A365F/1Y 0.025 7 | 20160205 ZERO/RATE/GBP/GBP6M/A365F/1Y 0.026 8 | 9 | # Single swaption volatility 10 | 20160205 SWAPTION/RATE_LNVOL/EUR/1Y/1Y/ATM 0.1 11 | 20160205 SWAPTION/RATE_NVOL/GBP/1Y/1Y/ATM 0.0015 12 | 13 | # FX Spot rate 14 | 20160205 FX/RATE/EUR/GBP 0.811938 15 | 16 | # FX Vol, need two points here (TODO:fix this) 17 | 20160205 FX_OPTION/RATE_LNVOL/EUR/GBP/1Y/ATM 0.129775 18 | 20160205 FX_OPTION/RATE_LNVOL/EUR/GBP/10Y/ATM 0.132277 19 | 20 | # Credit Curve (RR and CDS quote) 21 | 20160205 RECOVERY_RATE/RATE/BANK/SR/EUR 0.4 22 | 20160205 CDS/CREDIT_SPREAD/BANK/SR/EUR/1Y 0.01 23 | 24 | # Credit Curve with flat hazard rate (RR needed for XVA) 25 | 20160205 RECOVERY_RATE/RATE/CPTY_A/SR/EUR 0.4 26 | 20160205 HAZARD_RATE/RATE/CPTY_A/SR/EUR/1Y 0.01 27 | 28 | # 29 | 20160205 MM/RATE/USD/0D/1D 0.00448 30 | 20160205 IR_SWAP/RATE/USD/0D/1D/1D 0.004502 31 | 20160205 IR_SWAP/RATE/USD/2D/1D/1M 0.004458 32 | 20160205 IR_SWAP/RATE/USD/2D/1D/1W 0.004473 33 | 20160205 IR_SWAP/RATE/USD/0D/1D/2D 0.005616 34 | 20160205 IR_SWAP/RATE/USD/2D/1D/2M 0.00479 35 | 20160205 IR_SWAP/RATE/USD/2D/1D/2W 0.004587 36 | 20160205 IR_SWAP/RATE/USD/2D/1D/3M 0.004851 37 | 20160205 IR_SWAP/RATE/USD/2D/1D/3W 0.004491 38 | 20160205 IR_SWAP/RATE/USD/2D/1D/4M 0.004863 39 | 20160205 IR_SWAP/RATE/USD/2D/1D/5M 0.004999 40 | 20160205 IR_SWAP/RATE/USD/2D/1D/6M 0.005237 41 | 20160205 IR_SWAP/RATE/USD/2D/1D/7M 0.005175 42 | 20160205 IR_SWAP/RATE/USD/2D/1D/8M 0.005371 43 | 20160205 IR_SWAP/RATE/USD/2D/1D/9M 0.005471 44 | 20160205 IR_SWAP/RATE/USD/2D/1D/10M 0.005521 45 | 20160205 IR_SWAP/RATE/USD/2D/1D/11M 0.005605 46 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y 0.005614 47 | 20160205 IR_SWAP/RATE/USD/2D/1D/2Y 0.006433 48 | 20160205 IR_SWAP/RATE/USD/2D/1D/3Y 0.007101 49 | 20160205 IR_SWAP/RATE/USD/2D/1D/4Y 0.008264 50 | 20160205 IR_SWAP/RATE/USD/2D/1D/5Y 0.009269 51 | 20160205 IR_SWAP/RATE/USD/2D/1D/7Y 0.011035 52 | 20160205 IR_SWAP/RATE/USD/2D/1D/10Y 0.013318 53 | 20160205 IR_SWAP/RATE/USD/2D/1D/12Y 0.01459 54 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y3M 0.005857 55 | 20160205 IR_SWAP/RATE/USD/2D/1D/15Y 0.016029 56 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y6M 0.006054 57 | 20160205 IR_SWAP/RATE/USD/2D/1D/20Y 0.01734 58 | 20160205 IR_SWAP/RATE/USD/2D/1D/1Y9M 0.006097 59 | 20160205 IR_SWAP/RATE/USD/2D/1D/25Y 0.01804 60 | 20160205 IR_SWAP/RATE/USD/2D/1D/30Y 0.018326 61 | 20160205 IR_SWAP/RATE/USD/2D/1D/50Y 0.0182 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Input/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | CPTY_A 6 | false 7 | 8 | Bilateral 9 | EUR 10 | EUR-EONIA 11 | 100000 12 | 100000 13 | 0 14 | 0 15 | 16 | 0 17 | FIXED 18 | 19 | 20 | 1D 21 | 1D 22 | 23 | 0W 24 | 0.00 25 | 0.00 26 | 27 | 28 | EUR 29 | 30 | 31 | 32 | 33 | 34 | CPTY_B 35 | CPTY_B 36 | true 37 | 38 | Bilateral 39 | EUR 40 | EUR-EONIA 41 | 0 42 | 0 43 | 5000000 44 | 5000000 45 | 46 | 0 47 | FIXED 48 | 49 | 50 | 1D 51 | 1D 52 | 53 | 2W 54 | 0.00 55 | 0.00 56 | 57 | 58 | EUR 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /tutorials.06.notebooks.md: -------------------------------------------------------------------------------- 1 | # Run Jupyter Notebook examples using the ORE Python wheels 2 | 3 | This tutorial is aimed at the user who wants to install the pre-built ORE 4 | Python module and use it to execute example Jupyter notebooks provided in 5 | [the notebooks directory](https://github.com/OpenSourceRisk/ORE-SWIG/tree/master/OREAnalytics-SWIG/Python/Examples/Notebooks). No compilation is necessary. 6 | 7 | [Back to tutorials index](tutorials.00.index.md) 8 | 9 | **Please note** that (as of October 2023) the published ORE Python wheels are 10 | available for Python versions 3.8 up to 3.11 for Windows, Linux and macOS arm64, 11 | and Python versions up to 3.10 for Intel Mac users. 12 | 13 | We assume below that the python executable points to a permissible Python 3 version. You can check your system's default python version with 14 | 15 | python --version 16 | 17 | ## Quick Set Up and First Run 18 | 19 | Please note that these steps must be executed sequentially in a single command prompt/shell. The working directory, for ease, should be OREAnalytics-SWIG/Python/Examples/Notebooks. 20 | 21 | 1. Create a virtual environment: 22 | 23 | ``` python -m venv venv ``` 24 | 25 | 2. Activate the virtual environment: 26 | 27 | (Windows): ```.\venv\Scripts\activate.bat ``` 28 | 29 | (Linux, Mac): ```source "$(pwd)/venv/bin/activate" ``` 30 | 31 | 3. Install required Python modules. The notebook examples require Jupyter, the ORE Python module and a few additional packages for e.g. plotting. To install these in the virtual environment please make sure to execute this **after** activating the virtual environment as above. 32 | 33 | ``` python -m pip install open-source-risk-engine matplotlib pandas plotly jupyter_server==2.8.0 jupyter ``` 34 | 35 | 4. Launch Jupyter! This opens a browser window that shows the list of Example folders on the left hand side. Double click to change into any of the Example folders and then double click the Jupyter notebook to open. 36 | 37 | ``` python -m jupyterlab ``` 38 | 39 | ## Normal Usage 40 | 41 | After the first time run, you simply need to activate the virtual environment and run jupyter lab. 42 | 43 | (Windows): ```.\venv\Scripts\activate.bat ``` 44 | 45 | (Linux, Mac): ```source "$(pwd)/venv/bin/activate" ``` 46 | 47 | python -m jupyterlab 48 | 49 | ## Exit the virtual environment 50 | 51 | To deactivate the virtual environment you can simply close the command prompt/terminal window. Othewise you can run the relevant deactivation script (assuming that the working directory is the Notebooks directory: 52 | 53 | (Windows): ```.\venv\Scripts\deactivate.bat ``` 54 | 55 | (Linux, Mac): ```source "$(pwd)/venv/bin/deactivate" ``` 56 | 57 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_6/Input/todaysmarket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | default 6 | default 7 | 8 | 9 | 10 | Yield/EUR/EUR1D 11 | Yield/EUR/EUR1D 12 | 13 | 14 | 15 | Yield/EUR/EUR1D 16 | Yield/GBP/GBP1D 17 | Yield/USD/USD1D 18 | 19 | 20 | 21 | Yield/EUR/EUR6M 22 | Yield/EUR/EUR1D 23 | Yield/GBP/GBP1D 24 | Yield/GBP/GBP6M 25 | Yield/GBP/GBP6M 26 | 27 | 28 | 29 | 30 | EUR-EONIA 31 | 32 | 33 | EUR-EONIA 34 | 35 | 36 | GBP-SONIA 37 | 38 | 39 | GBP-SONIA 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | FX/EUR/GBP 51 | 52 | 53 | 54 | FXVolatility/EUR/GBP/EURGBP 55 | 56 | 57 | 58 | SwaptionVolatility/EUR/EUR_SWPTN 59 | SwaptionVolatility/GBP/GBP_SWPTN 60 | 61 | 62 | 63 | Default/EUR/BANK_SR_EUR 64 | Default/EUR/CPTY_A_SR_EUR 65 | Default/EUR/CPTY_A_SR_EUR 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_5/Input/netting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | false 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 100000 11 | 100000 12 | 0 13 | 0 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 0W 23 | 0.00 24 | 0.00 25 | 26 | 27 | EUR 28 | 29 | 30 | false 31 | 32 | 33 | 34 | CPTY_B 35 | true 36 | 37 | Bilateral 38 | EUR 39 | EUR-EONIA 40 | 0 41 | 0 42 | 5000000 43 | 5000000 44 | 45 | 0 46 | FIXED 47 | 48 | 49 | 1D 50 | 1D 51 | 52 | 2W 53 | 0.00 54 | 0.00 55 | 56 | 57 | EUR 58 | 59 | 60 | true 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/netting_dim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | true 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 0 11 | 0 12 | 0 13 | 0 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.0010 24 | 0.0010 25 | 26 | 27 | EUR 28 | 29 | 30 | true 31 | 32 | 33 | 34 | CPTY_B 35 | true 36 | 37 | Bilateral 38 | EUR 39 | EUR-EONIA 40 | 2000000 41 | 2000000 42 | 1000000 43 | 1000000 44 | 45 | 0 46 | FIXED 47 | 48 | 49 | 1D 50 | 1D 51 | 52 | 2W 53 | 0.00 54 | 0.00 55 | 56 | 57 | EUR 58 | 59 | 60 | true 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/progress.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "extensions": { 8 | "jupyter_dashboards": { 9 | "version": 1, 10 | "views": { 11 | "grid_default": { 12 | "hidden": true 13 | }, 14 | "report_default": { 15 | "hidden": true 16 | } 17 | } 18 | } 19 | }, 20 | "scrolled": true 21 | }, 22 | "outputs": [], 23 | "source": [ 24 | "import os, time, sys; sys.path.append('..'); import utilities" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 11, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "name": "stdout", 34 | "output_type": "stream", 35 | "text": [ 36 | " Building cube 100 out of 100 steps (100%) completed\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "from IPython.display import clear_output\n", 42 | "value = True\n", 43 | "while (value):\n", 44 | " clear_output(wait=False)\n", 45 | " os.system(\"grep progress Output/log.txt| cut -d':' -f5- | tail -1\")\n", 46 | " time.sleep(0.5)\n", 47 | " value = False" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [] 56 | } 57 | ], 58 | "metadata": { 59 | "anaconda-cloud": {}, 60 | "extensions": { 61 | "jupyter_dashboards": { 62 | "activeView": "report_default", 63 | "version": 1, 64 | "views": { 65 | "grid_default": { 66 | "cellMargin": 10, 67 | "defaultCellHeight": 20, 68 | "maxColumns": 12, 69 | "name": "grid", 70 | "type": "grid" 71 | }, 72 | "report_default": { 73 | "name": "report", 74 | "type": "report" 75 | } 76 | } 77 | } 78 | }, 79 | "kernelspec": { 80 | "display_name": "Python 3 (ipykernel)", 81 | "language": "python", 82 | "name": "python3" 83 | }, 84 | "language_info": { 85 | "codemirror_mode": { 86 | "name": "ipython", 87 | "version": 3 88 | }, 89 | "file_extension": ".py", 90 | "mimetype": "text/x-python", 91 | "name": "python", 92 | "nbconvert_exporter": "python", 93 | "pygments_lexer": "ipython3", 94 | "version": "3.11.2" 95 | }, 96 | "widgets": { 97 | "state": { 98 | "706c717787fc48baacd29c35c5b92bba": { 99 | "views": [ 100 | { 101 | "cell_index": 13 102 | } 103 | ] 104 | } 105 | }, 106 | "version": "1.2.0" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 4 111 | } 112 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_5/Input/todaysmarket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | inccy 5 | 6 | 7 | 8 | Yield/EUR/EUR-IN-USD 9 | 10 | 11 | Yield/EUR/EUR-IN-USD 12 | Yield/USD/USD-SOFR 13 | 14 | 15 | Yield/EUR/EUR-EONIA 16 | Yield/USD/USD-SOFR 17 | 18 | 19 | Yield/EUR/EUR-EONIA 20 | Yield/EUR/EUR-ESTER 21 | Yield/EUR/EUR-EURIBOR-3M 22 | Yield/EUR/EUR-EURIBOR-6M 23 | Yield/USD/USD-FedFunds 24 | Yield/USD/USD-LIBOR-3M 25 | Yield/USD/USD-SOFR 26 | 27 | 28 | 29 | EUR-EONIA 30 | 31 | 32 | EUR-EONIA 33 | 34 | 35 | USD-FedFunds 36 | 37 | 38 | USD-FedFunds 39 | 40 | 41 | USD-SOFR 42 | 43 | 44 | USD-SOFR 45 | 46 | 47 | 48 | FX/USD/EUR 49 | 50 | 51 | FXVolatility/EUR/USD/EURUSD 52 | 53 | 54 | SwaptionVolatility/EUR/EUR 55 | SwaptionVolatility/USD/USD 56 | 57 | 58 | Default/USD/BANK_SR_USD 59 | Default/USD/CPTY_A_SR_USD 60 | 61 | 62 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/netting_threshold.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CPTY_A 5 | true 6 | 7 | Bilateral 8 | EUR 9 | EUR-EONIA 10 | 2000000 11 | 2000000 12 | 1000000 13 | 1000000 14 | 15 | 0 16 | FIXED 17 | 18 | 19 | 1D 20 | 1D 21 | 22 | 2W 23 | 0.0010 24 | 0.0010 25 | 26 | 27 | EUR 28 | 29 | 30 | true 31 | 32 | 33 | 34 | CPTY_B 35 | true 36 | 37 | Bilateral 38 | EUR 39 | EUR-EONIA 40 | 2000000 41 | 2000000 42 | 1000000 43 | 1000000 44 | 45 | 0 46 | FIXED 47 | 48 | 49 | 1D 50 | 1D 51 | 52 | 2W 53 | 0.00 54 | 0.00 55 | 56 | 57 | EUR 58 | 59 | 60 | true 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_7/Input/crif.csv: -------------------------------------------------------------------------------- 1 | TradeID,PortfolioID,ProductClass,RiskType,Qualifier,Bucket,Label1,Label2,AmountCurrency,Amount,collect_regulations,post_regulations 2 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,10y,Libor3m,USD,-1991.02,"ESA,USPR","SEC,CFTC" 3 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,10y,OIS,USD,-304.84,"ESA,USPR","SEC,CFTC" 4 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,15y,Libor3m,USD,-611.3,"ESA,USPR","SEC,CFTC" 5 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,15y,OIS,USD,-510.15,"ESA,USPR","SEC,CFTC" 6 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,1y,Libor3m,USD,-0.09,"ESA,USPR","SEC,CFTC" 7 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,1y,OIS,USD,-0.38,"ESA,USPR","SEC,CFTC" 8 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,20y,Libor3m,USD,-5926.95,"ESA,USPR","SEC,CFTC" 9 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,20y,OIS,USD,-660.82,"ESA,USPR","SEC,CFTC" 10 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,2w,Libor3m,USD,11.18,"ESA,USPR","SEC,CFTC" 11 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,2w,OIS,USD,-0.93,"ESA,USPR","SEC,CFTC" 12 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,2y,Libor3m,USD,-0.23,"ESA,USPR","SEC,CFTC" 13 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,2y,OIS,USD,-2.93,"ESA,USPR","SEC,CFTC" 14 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,30y,Libor3m,USD,-1894.5,"ESA,USPR","SEC,CFTC" 15 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,30y,OIS,USD,-62.5,"ESA,USPR","SEC,CFTC" 16 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,3m,Libor3m,USD,0.05,"ESA,USPR","SEC,CFTC" 17 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,3m,OIS,USD,-3.28,"ESA,USPR","SEC,CFTC" 18 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,3y,Libor3m,USD,-1.05,"ESA,USPR","SEC,CFTC" 19 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,3y,OIS,USD,-6.63,"ESA,USPR","SEC,CFTC" 20 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,5y,Libor3m,USD,-1431.81,"ESA,USPR","SEC,CFTC" 21 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,5y,OIS,USD,-71.68,"ESA,USPR","SEC,CFTC" 22 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,6m,Libor3m,USD,-0.03,"ESA,USPR","SEC,CFTC" 23 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRCurve,USD,1,6m,OIS,USD,2.01,"ESA,USPR","SEC,CFTC" 24 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRVol,USD,,10y,,USD,498253.14,"ESA,USPR","SEC,CFTC" 25 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRVol,USD,,15y,,USD,163454.34,"ESA,USPR","SEC,CFTC" 26 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRVol,USD,,3y,,USD,2813.27,"ESA,USPR","SEC,CFTC" 27 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_IRVol,USD,,5y,,USD,264121.38,"ESA,USPR","SEC,CFTC" 28 | IR_Bermudan,CRIF_20191230,RatesFX,Risk_FX,USD,,,,USD,13186.84,"ESA,USPR","SEC,CFTC" 29 | -------------------------------------------------------------------------------- /.github/workflows/macosx86_wheels.yml: -------------------------------------------------------------------------------- 1 | name: MacOS x86 Wheels 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | tags: 7 | - 'v*' 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | jobs: 13 | wheels-macos: 14 | runs-on: macos-11 15 | steps: 16 | - name: Checkout ORE-SWIG 17 | uses: actions/checkout@v4 18 | - name: get QuantLib-SWIG 19 | run: | 20 | git submodule update --init 21 | - name: Checkout ORE 22 | uses: actions/checkout@v4 23 | with: 24 | repository: OpenSourceRisk/Engine 25 | path: './ORE' 26 | fetch-depth: 0 27 | - name: get QuantLib 28 | run: | 29 | cd ORE 30 | git submodule update --init 31 | - name: Install Boost 32 | run: | 33 | curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz 34 | tar xfz boost_1_80_0.tar.gz 35 | cd boost_1_80_0 36 | ./bootstrap.sh 37 | ./b2 toolset=clang-darwin target-os=darwin architecture=x86 cxxflags="-arch x86_64" cflags="-arch x86_64" linkflags="-arch x86_64" abi=sysv binary-format=mach-o install 38 | - name: Build ORE CMake 39 | run: | 40 | cd ORE 41 | mkdir build 42 | cd build 43 | cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64 -DORE_USE_ZLIB=ON -DBUILD_SHARED_LIBS=false -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_TESTS=OFF -DORE_BUILD_APP=OFF -DQL_BUILD_BENCHMARK=OFF -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF -DQL_ENABLE_SESSIONS=ON -DCMAKE_BUILD_TYPE=Release .. 44 | cmake --build . -j4 45 | cmake --install . 46 | - name: Wrap ORE-SWIG 47 | run: | 48 | pwd 49 | python -m pip install setuptools 50 | cp wheels/oreanalytics-config.macos OREAnalytics-SWIG/oreanalytics-config 51 | cd OREAnalytics-SWIG/SWIG 52 | chmod +x oreanalytics.i 53 | cd .. 54 | cd Python 55 | pwd 56 | python setup.py wrap 57 | - name: Build Wheels 58 | uses: pypa/cibuildwheel@v2.17 59 | env: 60 | CIBW_SKIP: cp36-* 61 | CIBW_ARCHS_MACOS: x86_64 62 | MACOSX_DEPLOYMENT_TARGET: "11.7" 63 | CXXFLAGS: -std=c++17 -g0 -O3 -mmacosx-version-min=11 64 | CIBW_BUILD_VERBOSITY: 2 65 | CIBW_REPAIR_WHEEL_COMMAND_MACOS: > 66 | DYLD_LIBRARY_PATH=/usr/local/lib delocate-listdeps {wheel} && 67 | DYLD_LIBRARY_PATH=/usr/local/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} 68 | with: 69 | package-dir: /Users/runner/work/ORE-SWIG/ORE-SWIG/OREAnalytics-SWIG/Python 70 | - name: Save wheels as artifacts 71 | uses: actions/upload-artifact@v4 72 | with: 73 | name: wheels-macos-x86_64 74 | path: ./wheelhouse/*.whl 75 | -------------------------------------------------------------------------------- /.github/workflows/macosARM64_wheels.yml: -------------------------------------------------------------------------------- 1 | name: MacOS ARM64 Wheels 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | tags: 7 | - 'v*' 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | jobs: 13 | wheels-macos: 14 | runs-on: macos-11 15 | steps: 16 | - name: Checkout ORE-SWIG 17 | uses: actions/checkout@v4 18 | - name: get QuantLib-SWIG 19 | run: | 20 | git submodule update --init 21 | - name: Checkout ORE 22 | uses: actions/checkout@v4 23 | with: 24 | repository: OpenSourceRisk/Engine 25 | path: './ORE' 26 | fetch-depth: 0 27 | - name: get QuantLib 28 | run: | 29 | cd ORE 30 | git submodule update --init 31 | - name: Install Eigen 32 | run: | 33 | brew install eigen 34 | - name: Install Boost 35 | run: | 36 | curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz 37 | tar xfz boost_1_80_0.tar.gz 38 | cd boost_1_80_0 39 | ./bootstrap.sh 40 | ./b2 architecture=arm address-model=64 -s NO_LZMA=1 -s NO_ZSTD=1 abi=aapcs install 41 | - name: Build ORE CMake 42 | run: | 43 | cd ORE 44 | mkdir build 45 | cd build 46 | cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64 -DORE_USE_ZLIB=ON -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_TESTS=OFF -DORE_BUILD_APP=OFF -DQL_BUILD_BENCHMARK=OFF -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF -DQL_ENABLE_SESSIONS=ON -DCMAKE_BUILD_TYPE=Release .. 47 | cmake --build . -j4 48 | cmake --install . 49 | - name: Wrap ORE-SWIG 50 | run: | 51 | pwd 52 | python -m pip install setuptools 53 | cp wheels/oreanalytics-config.macos OREAnalytics-SWIG/oreanalytics-config 54 | cd OREAnalytics-SWIG 55 | ls -al 56 | cd SWIG 57 | ls -al 58 | chmod +x oreanalytics.i 59 | cd .. 60 | cd Python 61 | ls -al 62 | pwd 63 | python setup.py wrap 64 | - name: Build Wheels 65 | uses: pypa/cibuildwheel@v2.16.5 66 | env: 67 | CIBW_SKIP: cp36-* 68 | #CIBW_BUILD: cp310-macosx_arm64 69 | #CIBW_BUILD: cp311-macosx_arm64 70 | CIBW_ARCHS_MACOS: arm64 71 | CXXFLAGS: -std=c++17 -g0 -O3 72 | CIBW_BUILD_VERBOSITY: 2 73 | CIBW_REPAIR_WHEEL_COMMAND_MACOS: > 74 | DYLD_LIBRARY_PATH=/usr/local/lib delocate-listdeps {wheel} && 75 | DYLD_LIBRARY_PATH=/usr/local/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} 76 | with: 77 | package-dir: /Users/runner/work/ORE-SWIG/ORE-SWIG/OREAnalytics-SWIG/Python 78 | - name: Save wheels as artifacts 79 | uses: actions/upload-artifact@v4 80 | with: 81 | name: wheels-macos-arm64 82 | path: ./wheelhouse/*.whl 83 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_creditdefaultswap.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_credit_default_swap_i 20 | #define qle_credit_default_swap_i 21 | 22 | %include instruments.i 23 | %include credit.i 24 | %include termstructures.i 25 | %include bonds.i 26 | %include null.i 27 | %include creditdefaultswap.i 28 | 29 | %{ 30 | using QLECdsOption = QuantExt::CdsOption; 31 | using QLEBlackCdsOptionEngine = QuantExt::BlackCdsOptionEngine; 32 | %} 33 | 34 | %shared_ptr(QLECdsOption) 35 | class QLECdsOption : public Instrument { 36 | public: 37 | enum StrikeType { Price, Spread }; 38 | QLECdsOption(const ext::shared_ptr swap, 39 | const ext::shared_ptr& exercise, 40 | bool knocksOut = true, const QuantLib::Real strike = Null(), 41 | const StrikeType strikeType = StrikeType::Spread); 42 | const ext::shared_ptr underlyingSwap() const; 43 | QuantLib::Rate atmRate() const; 44 | QuantLib::Real riskyAnnuity() const; 45 | QuantLib::Volatility impliedVolatility(QuantLib::Real price, 46 | const QuantLib::Handle& termStructure, 47 | const QuantLib::Handle& probability, 48 | QuantLib::Real recoveryRate, 49 | QuantLib::Real accuracy = 1.e-4, 50 | QuantLib::Size maxEvaluations = 100, 51 | QuantLib::Volatility minVol = 1.0e-7, 52 | QuantLib::Volatility maxVol = 4.0) const; 53 | }; 54 | 55 | %shared_ptr(QLEBlackCdsOptionEngine) 56 | class QLEBlackCdsOptionEngine : public PricingEngine { 57 | public: 58 | QLEBlackCdsOptionEngine(const QuantLib::Handle& probability, 59 | QuantLib::Real recoveryRate, 60 | const QuantLib::Handle& termStructure, 61 | const QuantLib::Handle& vol); 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_equityforward.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_equityforward_i 20 | #define qle_equityforward_i 21 | 22 | %include instruments.i 23 | %include termstructures.i 24 | %include cashflows.i 25 | %include timebasket.i 26 | %include indexes.i 27 | 28 | %include qle_termstructures.i 29 | 30 | %{ 31 | using QuantExt::EquityForward; 32 | using QuantExt::DiscountingEquityForwardEngine; 33 | %} 34 | 35 | %shared_ptr(EquityForward) 36 | class EquityForward : public Instrument { 37 | public: 38 | EquityForward(const std::string& name, 39 | const QuantLib::Currency& currency, 40 | const QuantLib::Position::Type& longShort, 41 | const QuantLib::Real& quantity, 42 | const QuantLib::Date& maturityDate, 43 | const QuantLib::Real& strike); 44 | bool isExpired() const; 45 | const std::string& name(); 46 | QuantLib::Currency currency(); 47 | QuantLib::Position::Type longShort(); 48 | QuantLib::Real quantity(); 49 | QuantLib::Date maturityDate(); 50 | QuantLib::Real strike(); 51 | }; 52 | 53 | %shared_ptr(DiscountingEquityForwardEngine) 54 | class DiscountingEquityForwardEngine : public PricingEngine { 55 | public: 56 | DiscountingEquityForwardEngine(const QuantLib::Handle& equityInterestRateCurve, 57 | const QuantLib::Handle& dividendYieldCurve, 58 | const QuantLib::Handle& equitySpot, 59 | const QuantLib::Handle& discountCurve, 60 | boost::optional includeSettlementDateFlows = boost::none, 61 | const QuantLib::Date& settlementDate = QuantLib::Date(), 62 | const QuantLib::Date& npvDate = QuantLib::Date()); 63 | void calculate(); 64 | const QuantLib::Handle& equityReferenceRateCurve(); 65 | const QuantLib::Handle& divYieldCurve(); 66 | const QuantLib::Handle& discountCurve(); 67 | const QuantLib::Handle& equitySpot(); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/test/test_marketdatum.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (C) 2019 Quaternion Risk Management Ltd 4 | All rights reserved. 5 | """ 6 | 7 | from ORE import * 8 | import unittest 9 | 10 | class CorrelationRateQuoteTest(unittest.TestCase): 11 | 12 | def setUp(self): 13 | self.d = Date(1, January, 1990) 14 | self.value = 1 15 | self.input = "CORRELATION/RATE/INDEX1/INDEX2/1Y/ATM" 16 | self.datum = parseMarketDatum(self.d, self.input, self.value) 17 | 18 | def testSimpleInspectors(self): 19 | """ Test CorrelationQuote simple inspectors. """ 20 | self.assertEqual(self.datum.asofDate(), self.d) 21 | self.assertAlmostEqual(self.datum.quote().value(), self.value) 22 | self.assertAlmostEqual(self.datum.instrumentType(), MarketDatum.InstrumentType_CORRELATION) 23 | self.assertAlmostEqual(self.datum.quoteType(), MarketDatum.QuoteType_RATE) 24 | 25 | corr = CorrelationQuote.getFullView(self.datum) 26 | self.assertEqual(corr.index1(), "INDEX1") 27 | self.assertEqual(corr.index2(), "INDEX2") 28 | self.assertEqual(corr.expiry(), "1Y") 29 | self.assertEqual(corr.strike(), "ATM") 30 | 31 | class CorrelationPriceQuoteTest(unittest.TestCase): 32 | 33 | def setUp(self): 34 | self.d = Date(3, March, 2018) 35 | self.value = 10 36 | self.input = "CORRELATION/PRICE/INDEX1/INDEX2/1Y/0.1" 37 | self.datum = parseMarketDatum(self.d, self.input, self.value) 38 | 39 | def testSimpleInspectors(self): 40 | """ Test CorrelationQuote simple inspectors. """ 41 | self.assertEqual(self.datum.asofDate(), self.d) 42 | self.assertAlmostEqual(self.datum.quote().value(), self.value) 43 | self.assertAlmostEqual(self.datum.instrumentType(), MarketDatum.InstrumentType_CORRELATION) 44 | self.assertAlmostEqual(self.datum.quoteType(), MarketDatum.QuoteType_PRICE) 45 | 46 | corr = CorrelationQuote.getFullView(self.datum) 47 | self.assertEqual(corr.index1(), "INDEX1") 48 | self.assertEqual(corr.index2(), "INDEX2") 49 | self.assertEqual(corr.expiry(), "1Y") 50 | self.assertEqual(corr.strike(), "0.1") 51 | 52 | class CorrelationQuoteThrowTest(unittest.TestCase): 53 | 54 | def setUp(self): 55 | self.d = Date(3, March, 2018) 56 | self.value = 10 57 | 58 | def testMarketDatumParsingFail(self): 59 | with self.assertRaises(RuntimeError): 60 | parseMarketDatum(self.d, "CORRELATION/PRICE/INDEX1/INDEX2/1Y/SS", self.value) 61 | parseMarketDatum(self.d, "CORRELATION/PRICE/INDEX1/INDEX2/6X/0.1", self.value) 62 | 63 | 64 | if __name__ == '__main__': 65 | import ORE 66 | print('testing ORE ' + ORE.__version__) 67 | suite = unittest.TestSuite() 68 | suite.addTest(unittest.makeSuite(CorrelationRateQuoteTest,'test')) 69 | suite.addTest(unittest.makeSuite(CorrelationPriceQuoteTest,'test')) 70 | suite.addTest(unittest.makeSuite(CorrelationQuoteThrowTest,'test')) 71 | unittest.TextTestRunner(verbosity=2).run(suite) 72 | unittest.main() 73 | 74 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/todaysmarket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | inccy_swap 5 | inccy_swap 6 | 7 | 8 | inccy_swap 9 | inccy_swap 10 | 11 | 12 | 13 | Yield/EUR/EUR6M 14 | 15 | 16 | 17 | 18 | 19 | 20 | Yield/EUR/EUR3M 21 | Yield/EUR/EUR6M 22 | Yield/EUR/EUR1D 23 | 24 | 25 | 26 | 27 | EUR-EONIA 28 | 29 | 30 | EUR-EONIA 31 | 32 | 33 | EUR-EONIA 34 | 35 | 36 | EUR-EONIA 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 55 | 56 | 57 | SwaptionVolatility/EUR/EUR_SW_N 58 | 59 | 60 | 61 | CapFloorVolatility/EUR/EUR_CF_N 62 | 63 | 64 | 65 | CDSVolatility/CPTY_A 66 | 67 | 68 | 69 | Default/USD/CPTY_A_SR_EUR 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_cashflows.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_cashflows_i 20 | #define qle_cashflows_i 21 | 22 | %include date.i 23 | %include types.i 24 | %include calendars.i 25 | %include daycounters.i 26 | %include indexes.i 27 | %include termstructures.i 28 | %include scheduler.i 29 | %include vectors.i 30 | %include cashflows.i 31 | %include qle_indexes.i 32 | 33 | %{ 34 | //using QuantExt::FXLinked; 35 | using QuantExt::FXLinkedCashFlow; 36 | using QuantExt::FloatingRateFXLinkedNotionalCoupon; 37 | %} 38 | 39 | //%shared_ptr(FXLinked) 40 | //class FXLinked { 41 | // private: 42 | // FXLinked(); 43 | // public: 44 | // FXLinked(const QuantLib::Date& fixingDate, 45 | // QuantLib::Real foreignAmount, 46 | // ext::shared_ptr fxIndex); 47 | // QuantLib::Date fxFixingDate() const; 48 | // const ext::shared_ptr& fxIndex() const; 49 | // QuantLib::Real foreignAmount() const; 50 | // QuantLib::Real fxRate() const; 51 | // ext::shared_ptr clone(ext::shared_ptr fxIndex) = 0; 52 | //}; 53 | 54 | %shared_ptr(FXLinkedCashFlow) 55 | class FXLinkedCashFlow : public CashFlow { 56 | public: 57 | FXLinkedCashFlow(const QuantLib::Date& cashFlowDate, 58 | const QuantLib::Date& fixingDate, 59 | QuantLib::Real foreignAmount, 60 | ext::shared_ptr fxIndex); 61 | QuantLib::Date date() const; 62 | QuantLib::Date fxFixingDate() const; 63 | const ext::shared_ptr fxIndex() const; 64 | QuantLib::Real amount() const override; 65 | QuantLib::Real foreignAmount() const; 66 | QuantLib::Real fxRate() const; 67 | }; 68 | 69 | %shared_ptr(FloatingRateFXLinkedNotionalCoupon) 70 | class FloatingRateFXLinkedNotionalCoupon : public FloatingRateCoupon { 71 | public: 72 | FloatingRateFXLinkedNotionalCoupon(const QuantLib::Date& fxFixingDate, 73 | QuantLib::Real foreignAmount, 74 | ext::shared_ptr fxIndex, 75 | const ext::shared_ptr underlying); 76 | Real nominal() const; 77 | Rate rate() const; 78 | Rate indexFixing() const; 79 | void setPricer(const ext::shared_ptr& p); 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /OREData-SWIG/SWIG/ored_loader.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2019, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef ored_loader_i 20 | #define ored_loader_i 21 | 22 | %include ored_marketdatum.i 23 | %include std_set.i 24 | 25 | %{ 26 | using ore::data::Loader; 27 | using ore::data::Fixing; 28 | using ore::data::Wildcard; 29 | %} 30 | 31 | %shared_ptr(Loader) 32 | class Loader { 33 | private: 34 | Loader(); 35 | public: 36 | std::vector> loadQuotes(const QuantLib::Date&) const; 37 | ext::shared_ptr get(const std::string& name, const QuantLib::Date&) const; 38 | ext::shared_ptr get(const std::pair& name, const QuantLib::Date& d) const; 39 | std::set> get(const std::set& names, const QuantLib::Date& asof) const; 40 | std::set> get(const Wildcard& wildcard, const QuantLib::Date& asof) const; 41 | bool has(const std::string& name, const QuantLib::Date& d) const; 42 | bool hasQuotes(const QuantLib::Date& d) const; 43 | std::set loadFixings() const; 44 | }; 45 | %template(StringBoolPair) std::pair; 46 | %template(MarketDatumVector) std::vector>; 47 | 48 | // Fixing class has no default ctor, excluding some features of std::vector 49 | %ignore std::vector::pop; 50 | %ignore std::vector::resize; 51 | %ignore std::vector::vector(size_type); 52 | %template(FixingVector) std::vector; 53 | %template(FixingSet) std::set; 54 | 55 | %{ 56 | using ore::data::CSVLoader; 57 | %} 58 | 59 | %shared_ptr(CSVLoader) 60 | class CSVLoader : public Loader { 61 | public: 62 | CSVLoader(const std::string& marketFilename, const std::string& fixingFilename, 63 | bool implyTodaysFixings = false); 64 | CSVLoader(const std::vector& marketFiles, const std::vector& fixingFiles, 65 | bool implyTodaysFixings = false); 66 | }; 67 | 68 | %{ 69 | using ore::data::InMemoryLoader; 70 | %} 71 | 72 | %shared_ptr(InMemoryLoader) 73 | class InMemoryLoader : public Loader { 74 | public: 75 | InMemoryLoader(); 76 | void add(QuantLib::Date date, const std::string& name, QuantLib::Real value); 77 | void addFixing(QuantLib::Date date, const std::string& name, QuantLib::Real value); 78 | }; 79 | 80 | struct Fixing { 81 | QuantLib::Date date; 82 | std::string name; 83 | QuantLib::Real fixing; 84 | Fixing(const QuantLib::Date& d, const std::string& s, const QuantLib::Real f); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/ore_amc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | N 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio.xml 17 | None 18 | false 19 | calendaradjustment.xml 20 | currencies.xml 21 | 1 22 | 23 | 24 | libor 25 | libor 26 | libor 27 | libor 28 | libor 29 | 30 | 31 | 32 | Y 33 | EUR 34 | npv.csv 35 | 36 | 37 | Y 38 | Y 39 | Swap,Swaption,FxOption 40 | simulation.xml 41 | pricingengine.xml 42 | pricingengine_amc.xml 43 | EUR 44 | N 45 | 50 | 51 | 52 | Y 53 | netting.xml 54 | 58 | EUR 59 | Y 60 | Y 61 | 0.95 62 | NoLag 63 | None 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/ore_bermudans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | N 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio_bermudans.xml 17 | None 18 | false 19 | calendaradjustment.xml 20 | currencies.xml 21 | 1 22 | 23 | 24 | libor 25 | libor 26 | libor 27 | libor 28 | libor 29 | 30 | 31 | 32 | Y 33 | EUR 34 | npv.csv 35 | 36 | 37 | Y 38 | Y 39 | Swap,Swaption,FxOption 40 | simulation.xml 41 | pricingengine.xml 42 | pricingengine_amc.xml 43 | EUR 44 | N 45 | 50 | 51 | 52 | Y 53 | netting.xml 54 | 58 | EUR 59 | Y 60 | N 61 | 0.95 62 | NoLag 63 | None 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/bak/portfolio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swaption 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Long 13 | Call 14 | 15 | Physical 16 | false 17 | 18 | 2026-02-25 19 | 2027-02-25 20 | 2028-02-25 21 | 2029-02-25 22 | 2030-02-25 23 | 2031-02-25 24 | 2032-02-25 25 | 2033-02-25 26 | 2034-02-25 27 | 2035-02-25 28 | 29 | 30 | 31 | Floating 32 | false 33 | EUR 34 | 35 | 1000000 36 | 37 | A360 38 | ModifiedFollowing 39 | 40 | EUR-EURIBOR-6M 41 | 42 | 0.0 43 | 44 | 2 45 | false 46 | 47 | 48 | 49 | 2026-03-01 50 | 2036-03-01 51 | 6M 52 | TARGET 53 | Following 54 | Following 55 | Forward 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Fixed 64 | true 65 | EUR 66 | 67 | 1000000 68 | 69 | ACT/ACT 70 | Following 71 | 72 | 73 | 0.02 74 | 75 | 76 | 77 | 78 | 2026-03-01 79 | 2036-03-01 80 | 1Y 81 | TARGET 82 | Following 83 | Following 84 | Forward 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_crossccyfixfloatswap.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_crossccyfixfloatswap_i 20 | #define qle_crossccyfixfloatswap_i 21 | 22 | %include instruments.i 23 | %include scheduler.i 24 | %include indexes.i 25 | %include swap.i 26 | %include qle_ccyswap.i 27 | 28 | %{ 29 | using QuantExt::CrossCcyFixFloatSwap; 30 | %} 31 | 32 | %shared_ptr(CrossCcyFixFloatSwap) 33 | class CrossCcyFixFloatSwap : public CrossCcySwap { 34 | public: 35 | enum Type { Receiver = -1, Payer = 1 }; 36 | CrossCcyFixFloatSwap(CrossCcyFixFloatSwap::Type type, 37 | QuantLib::Real fixedNominal, 38 | const QuantLib::Currency& fixedCurrency, 39 | const QuantLib::Schedule& fixedSchedule, 40 | QuantLib::Rate fixedRate, 41 | const QuantLib::DayCounter& fixedDayCount, 42 | QuantLib::BusinessDayConvention fixedPaymentBdc, 43 | QuantLib::Natural fixedPaymentLag, 44 | const QuantLib::Calendar& fixedPaymentCalendar, 45 | QuantLib::Real floatNominal, 46 | const QuantLib::Currency& floatCurrency, 47 | const QuantLib::Schedule& floatSchedule, 48 | const ext::shared_ptr& floatIndex, 49 | QuantLib::Spread floatSpread, 50 | QuantLib::BusinessDayConvention floatPaymentBdc, 51 | QuantLib::Natural floatPaymentLag, 52 | const QuantLib::Calendar& floatPaymentCalendar); 53 | CrossCcyFixFloatSwap::Type type() const; 54 | QuantLib::Real fixedNominal() const; 55 | const QuantLib::Currency& fixedCurrency() const; 56 | const QuantLib::Schedule& fixedSchedule() const; 57 | QuantLib::Rate fixedRate() const; 58 | const QuantLib::DayCounter& fixedDayCount() const; 59 | QuantLib::BusinessDayConvention fixedPaymentBdc(); 60 | QuantLib::Natural fixedPaymentLag() const; 61 | const QuantLib::Calendar& fixedPaymentCalendar() const; 62 | QuantLib::Real floatNominal() const; 63 | const QuantLib::Currency& floatCurrency() const; 64 | const QuantLib::Schedule& floatSchedule() const; 65 | QuantLib::Rate floatSpread() const; 66 | QuantLib::BusinessDayConvention floatPaymentBdc(); 67 | QuantLib::Natural floatPaymentLag() const; 68 | const QuantLib::Calendar& floatPaymentCalendar() const; 69 | QuantLib::Rate fairFixedRate() const; 70 | QuantLib::Spread fairSpread() const; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /.github/workflows/linux_manylinux_wheels_01.yml: -------------------------------------------------------------------------------- 1 | name: Linux x86_64 ManyLinux Wheels (pp*) 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | tags: 7 | - 'v*' 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | jobs: 13 | wheels-linux: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout ORE-SWIG 17 | uses: actions/checkout@v4 18 | - name: get QuantLib-SWIG 19 | run: | 20 | git submodule update --init 21 | - name: Checkout ORE 22 | uses: actions/checkout@v4 23 | with: 24 | repository: OpenSourceRisk/Engine 25 | path: './ORE' 26 | fetch-depth: 0 27 | - name: get QuantLib 28 | run: | 29 | cd ORE 30 | git submodule update --init 31 | - name: Set Swap Space 32 | uses: pierotofy/set-swap-space@master 33 | with: 34 | swap-size-gb: 10 35 | - name: Install eigen 36 | run: | 37 | curl -O -L https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz 38 | tar zxvf eigen-3.4.0.tar.gz 39 | cd eigen-3.4.0 40 | mkdir build 41 | cd build 42 | cmake .. 43 | export 44 | export Eigen3_DIR=$CURRENT_DIR/eigen-3.4.0 45 | - name: Set up Boost 46 | run: | 47 | sudo apt update 48 | sudo apt install -y libboost-all-dev libboost-test-dev ninja-build 49 | - name: Build Zlib 50 | run: | 51 | pwd 52 | curl -O -L https://www.zlib.net/zlib-1.3.1.tar.gz 53 | tar xzvf zlib-1.3.1.tar.gz 54 | cd zlib-1.3.1 55 | ./configure 56 | make 57 | export ZLIB_ROOT=$CURRENT_DIR/zlib-1.3.1 58 | - name: Build ORE 59 | run : pwd; cd ORE; mkdir build; cd build; cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DORE_USE_ZLIB=ON -DBUILD_SHARED_LIBS=false -DQL_BUILD_EXAMPLES=false -DQL_BUILD_TEST_SUITE=false -DQL_BUILD_BENCHMARK=false -DQL_ENABLE_SESSIONS=true -DORE_BUILD_DOC=false -G "Ninja" .. 60 | - name: cmake build 61 | run: pwd; cd ORE; cd build; cmake --build . -j $(nproc) 62 | - name: Wrap ORE-SWIG 63 | run: pwd; cd OREAnalytics-SWIG/Python; python setup.py wrap 64 | - name: Copy Configuration 65 | run: | 66 | pwd 67 | cp Wheels/oreanalytics-config.linux OREAnalytics-SWIG/oreanalytics-config 68 | cd Wheels 69 | chmod +x before_all_linux.sh 70 | - name: Build ORE wheels 71 | uses: pypa/cibuildwheel@v2.16.2 72 | env: 73 | CIBW_BUILD: "*-manylinux*" 74 | CIBW_SKIP: cp* 75 | #CIBW_BUILD: cp37-manylinux_x86_64 76 | #CIBW_BUILD: cp38-manylinux_x86_64 77 | #CIBW_BUILD: cp39-manylinux_x86_64 78 | #CIBW_BUILD: cp310-manylinux_x86_64 79 | #CIBW_BUILD: cp311-manylinux_x86_64 80 | CIBW_ARCHS_LINUX: x86_64 81 | CIBW_BUILD_VERBOSITY: 2 82 | CIBW_BEFORE_ALL_LINUX: ./Wheels/before_all_linux.sh 83 | #CIBW_ENVIRONMENT_LINUX: CXXFLAGS="-O3 -g0" 84 | CIBW_ENVIRONMENT_LINUX: CXXFLAGS="-std=c++17 -O3 -g0" ORE=/project/ORE 85 | CIBW_ENVIRONMENT_PASS_LINUX: CXXFLAGS 86 | with: 87 | package-dir: /home/runner/work/ORE-SWIG/ORE-SWIG/OREAnalytics-SWIG/Python 88 | - name: Save wheels as artifacts 89 | uses: actions/upload-artifact@v4 90 | with: 91 | name: wheels-linux-manylinux-x86_64 92 | path: ./wheelhouse/*.whl 93 | -------------------------------------------------------------------------------- /.github/workflows/linux_manylinux_wheels_02.yml: -------------------------------------------------------------------------------- 1 | name: Linux x86_64 ManyLinux Wheels (cp*) 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | tags: 7 | - 'v*' 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | jobs: 13 | wheels-linux: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout ORE-SWIG 17 | uses: actions/checkout@v4 18 | - name: get QuantLib-SWIG 19 | run: | 20 | git submodule update --init 21 | - name: Checkout ORE 22 | uses: actions/checkout@v4 23 | with: 24 | repository: OpenSourceRisk/Engine 25 | path: './ORE' 26 | fetch-depth: 0 27 | - name: get QuantLib 28 | run: | 29 | cd ORE 30 | git submodule update --init 31 | - name: Set Swap Space 32 | uses: pierotofy/set-swap-space@master 33 | with: 34 | swap-size-gb: 10 35 | - name: Install eigen 36 | run: | 37 | curl -O -L https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz 38 | tar zxvf eigen-3.4.0.tar.gz 39 | cd eigen-3.4.0 40 | mkdir build 41 | cd build 42 | cmake .. 43 | export 44 | export Eigen3_DIR=$CURRENT_DIR/eigen-3.4.0 45 | - name: Set up Boost 46 | run: | 47 | sudo apt update 48 | sudo apt install -y libboost-all-dev libboost-test-dev ninja-build 49 | - name: Build Zlib 50 | run: | 51 | pwd 52 | curl -O -L https://www.zlib.net/zlib-1.3.1.tar.gz 53 | tar xzvf zlib-1.3.1.tar.gz 54 | cd zlib-1.3.1 55 | ./configure 56 | make 57 | export ZLIB_ROOT=$CURRENT_DIR/zlib-1.3.1 58 | - name: Build ORE 59 | run : pwd; cd ORE; mkdir build; cd build; cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DORE_USE_ZLIB=ON -DBUILD_SHARED_LIBS=false -DQL_BUILD_EXAMPLES=false -DQL_BUILD_TEST_SUITE=false -DQL_BUILD_BENCHMARK=false -DQL_ENABLE_SESSIONS=true -DORE_BUILD_DOC=false -G "Ninja" .. 60 | - name: cmake build 61 | run: pwd; cd ORE; cd build; cmake --build . -j $(nproc) 62 | - name: Wrap ORE-SWIG 63 | run: pwd; cd OREAnalytics-SWIG/Python; python setup.py wrap 64 | - name: Copy Configuration 65 | run: | 66 | pwd 67 | cp Wheels/oreanalytics-config.linux OREAnalytics-SWIG/oreanalytics-config 68 | cd Wheels 69 | chmod +x before_all_linux.sh 70 | - name: Build ORE wheels 71 | uses: pypa/cibuildwheel@v2.16.2 72 | env: 73 | CIBW_BUILD: "*-manylinux*" 74 | CIBW_SKIP: cp36-* pp* 75 | #CIBW_BUILD: cp37-manylinux_x86_64 76 | #CIBW_BUILD: cp38-manylinux_x86_64 77 | #CIBW_BUILD: cp39-manylinux_x86_64 78 | #CIBW_BUILD: cp310-manylinux_x86_64 79 | #CIBW_BUILD: cp311-manylinux_x86_64 80 | CIBW_ARCHS_LINUX: x86_64 81 | CIBW_BUILD_VERBOSITY: 2 82 | CIBW_BEFORE_ALL_LINUX: ./Wheels/before_all_linux.sh 83 | #CIBW_ENVIRONMENT_LINUX: CXXFLAGS="-O3 -g0" 84 | CIBW_ENVIRONMENT_LINUX: CXXFLAGS="-std=c++17 -O3 -g0" ORE=/project/ORE 85 | CIBW_ENVIRONMENT_PASS_LINUX: CXXFLAGS 86 | with: 87 | package-dir: /home/runner/work/ORE-SWIG/ORE-SWIG/OREAnalytics-SWIG/Python 88 | - name: Save wheels as artifacts 89 | uses: actions/upload-artifact@v4 90 | with: 91 | name: wheels-linux-manylinux-x86_64 92 | path: ./wheelhouse/*.whl 93 | -------------------------------------------------------------------------------- /tutorials.05.wheels.md: -------------------------------------------------------------------------------- 1 | 2 | # Managing Wheels 3 | 4 | This document contains some notes regarding the management of wheels. The 5 | basic process of generating wheels on Github Actions is documented elsewhere 6 | and is not repeated here. This document contains some useful information 7 | regarding specific details of managing Python wheels for the ORE project. The 8 | commands listed here are for Ubuntu, the approach is similar for Windows and 9 | MacOS. 10 | 11 | [Back to tutorials index](tutorials.00.index.md) 12 | 13 | # Generating Source Tarballs 14 | 15 | We need to upload the ORE and ORESWIG source to the GitHub Actions jobs which 16 | build the wheels. Here are the commands for generating the tarballs. 17 | 18 | pip install git-archive-all 19 | cd $DEMO_ORE_DIR 20 | git-archive-all ore.tgz 21 | mv ore.tgz ~/projects/wheels/tarballs 22 | cd $DEMO_ORE_SWIG_DIR 23 | git-archive-all oreswig.tgz 24 | mv oreswig.tgz ~/projects/wheels/tarballs 25 | 26 | # Running the Wrapper 27 | 28 | We do not install swig to the Github Actions Runner. Instead, before uploading 29 | the ORESWIG tarball, we uncompress it, run the swig wrapper, and then compress 30 | it again. Here are the commands to run the wrapper: 31 | 32 | cd ~/projects/wheels/tarballs/oreswig/OREAnalytics-SWIG/Python 33 | export BOOST_INC=$DEMO_BOOST_INC 34 | export BOOST_LIB=$DEMO_BOOST_LIB 35 | export ORE=$DEMO_ORE_DIR 36 | python3 setup.py wrap 37 | 38 | # Uploading Wheels to the Test Server 39 | 40 | The test server for Python wheels is: https://test.pypi.org/ 41 | 42 | The upload command relies on twine which uses the following configuration file to authenticate to the server: 43 | 44 | ~/.pypirc 45 | 46 | Here are the commands to upload the wheels to the test server: 47 | 48 | python3 -m pip install --upgrade pip 49 | python3 -m pip install --upgrade twine 50 | cd ~/projects/wheels 51 | python3 -m twine upload --repository testpypi *.whl 52 | 53 | Here is the command to install the wheel from the test server (run this within a virtual environment): 54 | 55 | pip install -i https://test.pypi.org/simple/ open-source-risk-engine 56 | 57 | # Uploading Wheels to the Production Server 58 | 59 | The production server for Python wheels is: https://pypi.org/ 60 | 61 | The command to upload the wheels to the production server is: 62 | 63 | twine upload -r pypi *whl 64 | 65 | Here is the command to install the wheel from the production server (run this within a virtual environment): 66 | 67 | pip install open-source-risk-engine 68 | 69 | # Running cibuildwheels Locally 70 | 71 | Github Actions uses cibuildwheels to generate the wheels. For troubleshooting purposes, it can be helpful to run cibuildwheels locally. Here are the commands to do that: 72 | 73 | cd $DEMO_ORE_SWIG_DIR/OREAnalytics-SWIG/Python 74 | python3 -m venv env1 75 | . ./env1/bin/activate 76 | pip install cibuildwheel 77 | export CIBW_BUILD='cp310-manylinux_x86_64' 78 | export CIBW_BUILD_VERBOSITY='2' 79 | export CIBW_ENVIRONMENT_LINUX='CXXFLAGS="-O3 -g0"' 80 | export CIBW_ENVIRONMENT_PASS_LINUX='CXXFLAGS' 81 | export CIBW_BEFORE_ALL_LINUX='./before_all_linux.local.sh' 82 | export CIBW_REPAIR_WHEEL_COMMAND_LINUX='LD_LIBRARY_PATH=/host~/erik/quaternion/boost_1_81_0/stage/lib auditwheel repair -w {dest_dir} {wheel}' 83 | cibuildwheel --platform linux 84 | deactivate 85 | rm -rf env1 86 | 87 | -------------------------------------------------------------------------------- /tutorials.01.install_windows.md: -------------------------------------------------------------------------------- 1 | 2 | # Installing ORE Python Libraries and Example Scripts on Windows 3 | 4 | This tutorial is aimed at the Windows user who wants to install and use the ORE 5 | Python libraries and example scripts. No compilation is necessary. 6 | 7 | [Back to tutorials index](tutorials.00.index.md) 8 | 9 | ## Introduction 10 | 11 | In principle, the command to install ORE is simply: 12 | 13 | pip install open-source-risk-engine 14 | 15 | However, there are some additional considerations: 16 | 17 | 1) The ORE example Python scripts depend upon other Python libraries. 18 | 2) If you use `pip install` to install a load of Python libraries, there is the 19 | potential to pollute your machine with outdated or incompatible libraries. It 20 | is cleaner to install Python libraries into a virtual environment. 21 | 22 | Therefore, this tutorial will take a step back. Starting from a clean WIndows 23 | machine, we will install all necessary prerequisites, and then the ORE Python 24 | library itself, along with the example Python scripts. We will use a virtual 25 | environment which can be modified or deleted without affecting the rest of your 26 | computer. 27 | 28 | ## Python 29 | 30 | You need to download and install Python. You need at least Python version 3.8. 31 | To verify that you have Python installed correctly, and that it is a supported 32 | version, open a command prompt and do: 33 | 34 | python --version 35 | 36 | ## Pip 37 | 38 | We are going to be using pip, so make sure that you have it installed and that 39 | you have the latest version: 40 | 41 | python -m ensurepip --upgrade 42 | 43 | ## Example Scripts 44 | 45 | You probably want a copy of the example Python scripts from the ORE project. 46 | So point your browser at the git repo... 47 | 48 | https://github.com/OpenSourceRisk/ORE-SWIG 49 | 50 | ...and click on the download button. Download a zip file of the repo and 51 | uncompress it somewhere on your hard drive. 52 | 53 | Back at the command prompt, cd into the directory containing the example 54 | scripts, e.g: 55 | 56 | cd C:\path\to\OREAnalytics-SWIG\Python\Examples 57 | 58 | ## Virtual Environment 59 | 60 | Create a virtual environment into which you will install the ORE Python library: 61 | 62 | python -m venv env1 63 | 64 | Activate the virtual environment: 65 | 66 | .\env1\Scripts\activate.bat 67 | 68 | You might get a warning message that the version of pip installed inside the 69 | virtual environment is out of date, and you can make that go away with: 70 | 71 | python -m pip install --upgrade pip 72 | 73 | Some of the example scripts depend on other Python libs, here is the command to 74 | install those prerequisites: 75 | 76 | pip install jinja2 pandas 77 | 78 | Now, after all that, you are finally ready to install ORE! 79 | 80 | pip install open-source-risk-engine 81 | 82 | Now you can run the example scripts, e.g: 83 | 84 | python swap.py 85 | 86 | Once you are done using your virtual environment, you can exit it using the 87 | following command: 88 | 89 | deactivate 90 | 91 | You can later re-enter the virtual environment with the same command that you 92 | used earlier: 93 | 94 | .\env1\Scripts\activate.bat 95 | 96 | To delete the virtual environment, simply deactivate it (if necessary) and then 97 | delete the relevant directory: 98 | 99 | rmdir /s /q env1 100 | 101 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/ore_classic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | Y 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio.xml 17 | None 18 | false 19 | calendaradjustment.xml 20 | currencies.xml 21 | 1 22 | 23 | 24 | libor 25 | libor 26 | libor 27 | libor 28 | libor 29 | 30 | 31 | 32 | Y 33 | EUR 34 | npv.csv 35 | Y 36 | 37 | 38 | Y 39 | flows.csv 40 | 41 | 42 | Y 43 | default 44 | 240,1M 45 | curves.csv 46 | Y 47 | 48 | 49 | Y 50 | simulation_classic.xml 51 | pricingengine.xml 52 | EUR 53 | Disable 54 | cube.csv.gz 55 | scenariodata.csv.gz 56 | 57 | 58 | Y 59 | N 60 | netting.xml 61 | 62 | 63 | EUR 64 | Y 65 | Y 66 | 0.95 67 | netcube.csv 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/ore_swaps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | Y 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio_swaps.xml 17 | None 18 | false 19 | calendaradjustment.xml 20 | currencies.xml 21 | 1 22 | 23 | 24 | libor 25 | libor 26 | libor 27 | libor 28 | libor 29 | 30 | 31 | 32 | Y 33 | EUR 34 | npv.csv 35 | Y 36 | 37 | 38 | Y 39 | flows.csv 40 | 41 | 42 | Y 43 | default 44 | 240,1M 45 | curves.csv 46 | Y 47 | 48 | 49 | Y 50 | simulation_multi.xml 51 | pricingengine.xml 52 | EUR 53 | Disable 54 | 58 | 59 | 60 | Y 61 | netting.xml 62 | 66 | EUR 67 | Y 68 | N 69 | 0.95 70 | NoLag 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /tutorials.02.install_posix.md: -------------------------------------------------------------------------------- 1 | 2 | # Installing ORE Python Libraries and Example Scripts on Posix Systems (e.g. MacOS and Linux) 3 | 4 | This tutorial is aimed at users on Posix systems (e.g. MacOS and Linux) who 5 | want to install and use the ORE Python libraries and example scripts. No 6 | compilation is necessary. The commands listed here were tested on 7 | Ubuntu and you will likely have to modify the commands slightly on other 8 | systems. 9 | 10 | [Back to tutorials index](tutorials.00.index.md) 11 | 12 | ## Introduction 13 | 14 | In principle, the command to install ORE is simply: 15 | 16 | pip install open-source-risk-engine 17 | 18 | However, there are some additional considerations: 19 | 20 | 1) The ORE example Python scripts depend upon other Python libraries. 21 | 2) If you use `pip install` to install a load of Python libraries, there is the 22 | potential to pollute your machine with outdated or incompatible libraries. It 23 | is cleaner to install Python libraries into a virtual environment. 24 | 25 | Therefore, this tutorial will take a step back. Starting from a clean machine, 26 | we will install all necessary prerequisites, and then the ORE Python library 27 | itself, along with the example Python scripts. We will use a virtual 28 | environment which can be modified or deleted without affecting the rest of your 29 | computer. 30 | 31 | ## Python 32 | 33 | You need to download and install Python. You need at least Python version 3.8. 34 | To verify that you have Python installed correctly, and that it is a supported 35 | version, open a command prompt and do: 36 | 37 | python3 --version 38 | 39 | ## Pip 40 | 41 | We are going to be using pip, so make sure that you have it installed and that 42 | you have the latest version: 43 | 44 | python3 -m ensurepip --upgrade 45 | 46 | ## Example Scripts 47 | 48 | You probably want a copy of the example Python scripts from the ORE project. 49 | So point your browser at the git repo... 50 | 51 | https://github.com/OpenSourceRisk/ORE-SWIG 52 | 53 | ...and click on the download button. Download a zip file of the repo and 54 | uncompress it somewhere on your hard drive. 55 | 56 | Back at the command prompt, cd into the directory containing the example 57 | scripts, e.g: 58 | 59 | cd /path/to/OREAnalytics-SWIG/Python/Examples 60 | 61 | ## Virtual Environment 62 | 63 | Create a virtual environment into which you will install the ORE Python library: 64 | 65 | python3 -m venv env1 66 | 67 | Activate the virtual environment: 68 | 69 | . ./env1/bin/activate 70 | 71 | You might get a warning message that the version of pip installed inside the 72 | virtual environment is out of date, and you can make that go away with: 73 | 74 | python3 -m pip install --upgrade pip 75 | 76 | Some of the example scripts depend on other Python libs, here is the command to 77 | install those prerequisites: 78 | 79 | pip install jinja2 pandas 80 | 81 | Now, after all that, you are finally ready to install ORE! 82 | 83 | pip install open-source-risk-engine 84 | 85 | Now you can run the example scripts, e.g: 86 | 87 | python3 swap.py 88 | 89 | Once you are done using your virtual environment, you can exit it using the 90 | following command: 91 | 92 | deactivate 93 | 94 | You can later re-enter the virtual environment with the same command that you 95 | used earlier: 96 | 97 | . ./env1/bin/activate 98 | 99 | To delete the virtual environment, simply deactivate it (if necessary) and then 100 | delete the relevant directory: 101 | 102 | rm -rf env1 103 | 104 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_3/Input/portfolio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Swaption 5 | 6 | CPTY_A 7 | CPTY_A 8 | 9 | 10 | 11 | 12 | Long 13 | Call 14 | 15 | Physical 16 | false 17 | 18 | 2021-02-25 19 | 2022-02-25 20 | 2023-02-25 21 | 2024-02-25 22 | 2025-02-25 23 | 2026-02-25 24 | 2027-02-25 25 | 2028-02-25 26 | 2029-02-25 27 | 2030-02-25 28 | 2031-02-25 29 | 2032-02-25 30 | 2033-02-25 31 | 2034-02-25 32 | 2035-02-25 33 | 34 | 35 | 36 | Floating 37 | false 38 | EUR 39 | 40 | 1000000 41 | 42 | A360 43 | ModifiedFollowing 44 | 45 | EUR-EURIBOR-6M 46 | 47 | 0.0 48 | 49 | 2 50 | false 51 | 52 | 53 | 54 | 2021-03-01 55 | 2036-03-01 56 | 6M 57 | TARGET 58 | Following 59 | Following 60 | Forward 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Fixed 69 | true 70 | EUR 71 | 72 | 1000000 73 | 74 | ACT/ACT 75 | Following 76 | 77 | 78 | 0.02 79 | 80 | 81 | 82 | 83 | 2021-03-01 84 | 2036-03-01 85 | 1Y 86 | TARGET 87 | Following 88 | Following 89 | Forward 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /QuantExt-SWIG/SWIG/qle_oiccbasisswap.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018, 2020 Quaternion Risk Management Ltd 3 | All rights reserved. 4 | 5 | This file is part of ORE, a free-software/open-source library 6 | for transparent pricing and risk analysis - http://opensourcerisk.org 7 | 8 | ORE is free software: you can redistribute it and/or modify it 9 | under the terms of the Modified BSD License. You should have received a 10 | copy of the license along with this program. 11 | The license is also available online at 12 | 13 | This program is distributed on the basis that it will form a useful 14 | contribution to risk analytics and model standardisation, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. 17 | */ 18 | 19 | #ifndef qle_oiccbasisswap_i 20 | #define qle_oiccbasisswap_i 21 | 22 | %include instruments.i 23 | %include scheduler.i 24 | %include indexes.i 25 | 26 | %{ 27 | using QuantExt::OvernightIndexedCrossCcyBasisSwap; 28 | using QuantExt::OvernightIndexedCrossCcyBasisSwapEngine; 29 | %} 30 | 31 | %shared_ptr(OvernightIndexedCrossCcyBasisSwap) 32 | class OvernightIndexedCrossCcyBasisSwap : public Instrument { 33 | public: 34 | OvernightIndexedCrossCcyBasisSwap(QuantLib::Real payNominal, 35 | QuantLib::Currency payCurrency, 36 | const QuantLib::Schedule& paySchedule, 37 | const ext::shared_ptr& payIndex, 38 | QuantLib::Real paySpread, 39 | QuantLib::Real recNominal, 40 | QuantLib::Currency recCurrency, 41 | const QuantLib::Schedule& recSchedule, 42 | const ext::shared_ptr& recIndex, 43 | QuantLib::Real recSpread); 44 | /*Name Inspectors*/ 45 | /*Pay Leg*/ 46 | QuantLib::Real payNominal() const; 47 | QuantLib::Currency payCurrency(); 48 | const QuantLib::Schedule& paySchedule(); 49 | QuantLib::Real paySpread(); 50 | /*Receiver Leg*/ 51 | QuantLib::Real recNominal() const; 52 | QuantLib::Currency recCurrency(); 53 | const QuantLib::Schedule& recSchedule(); 54 | QuantLib::Real recSpread(); 55 | /*Other*/ 56 | const QuantLib::Leg& payLeg(); 57 | const QuantLib::Leg& recLeg(); 58 | /*Name Results*/ 59 | QuantLib::Real payLegBPS(); 60 | QuantLib::Real payLegNPV(); 61 | QuantLib::Real fairPayLegSpread() const; 62 | QuantLib::Real recLegBPS() const; 63 | QuantLib::Real recLegNPV() const; 64 | QuantLib::Spread fairRecLegSpread() const; 65 | }; 66 | 67 | %shared_ptr(OvernightIndexedCrossCcyBasisSwapEngine) 68 | class OvernightIndexedCrossCcyBasisSwapEngine : public PricingEngine { 69 | public: 70 | OvernightIndexedCrossCcyBasisSwapEngine(const QuantLib::Handle& ts1, 71 | const QuantLib::Currency& ccy1, 72 | const QuantLib::Handle& ts2, 73 | const QuantLib::Currency& ccy2, 74 | const QuantLib::Handle& fx); 75 | QuantLib::Handle ts1(); 76 | QuantLib::Handle ts2(); 77 | QuantLib::Currency ccy1(); 78 | QuantLib::Currency ccy2(); 79 | QuantLib::Handle fx(); 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /OREAnalytics-SWIG/Python/Examples/Notebooks/Example_2/Input/ore_external_im.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-02-05 5 | Input 6 | Output 7 | log_dim.txt 8 | 31 9 | market.txt 10 | fixings.txt 11 | N 12 | curveconfig.xml 13 | conventions.xml 14 | todaysmarket.xml 15 | pricingengine.xml 16 | portfolio.xml 17 | Disable 18 | 19 | 20 | collateral_inccy 21 | default 22 | default 23 | default 24 | 25 | 26 | 27 | N 28 | EUR 29 | npv.csv 30 | 31 | 32 | N 33 | flows.csv 34 | 35 | 36 | N 37 | default 38 | 240,1M 39 | curves.csv 40 | 41 | 42 | N 43 | simulation.xml 44 | pricingengine.xml 45 | EUR 46 | 47 | 48 | Y 49 | netting_dim.xml 50 | cube.csv.gz 51 | scenariodata.csv.gz 52 | EUR 53 | Y 54 | Y 55 | 0.95 56 | NoLag 57 | Marginal 58 | 1.0 59 | N 60 | Y 61 | N 62 | BANK 63 | Y 64 | BANK_EUR_BORROW 65 | BANK_EUR_LEND 66 | Y 67 | Y 68 | Y 69 | Y 70 | dim_evolution.csv 71 | 72 | 73 | 74 | 75 | --------------------------------------------------------------------------------