diff --git a/.ci/csharp.build b/.ci/csharp.build
deleted file mode 100755
index e991b6a2..00000000
--- a/.ci/csharp.build
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-set -e
-
-./autogen.sh
-./configure CC=clang CXX=clang++ CXXFLAGS='-O2'
-make -C CSharp
diff --git a/.ci/csharp.check b/.ci/csharp.check
deleted file mode 100755
index 763d8490..00000000
--- a/.ci/csharp.check
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-
-make -C CSharp check
diff --git a/.ci/csharp.install b/.ci/csharp.install
deleted file mode 100755
index 2005ff9b..00000000
--- a/.ci/csharp.install
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-set -e
diff --git a/.ci/java-new.build b/.ci/java-new.build
deleted file mode 100755
index 0cb9cc4c..00000000
--- a/.ci/java-new.build
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-set -e
-
-./autogen.sh
-./configure --disable-java-finalizer --enable-java-autocloseable \
- --with-jdk-include=/usr/lib/jvm/default-java/include \
- --with-jdk-system-include=/usr/lib/jvm/default-java/include/linux \
- CC=clang CXX=clang++ CXXFLAGS='-O2'
-make -C Java
diff --git a/.ci/java-new.check b/.ci/java-new.check
deleted file mode 100755
index a288402d..00000000
--- a/.ci/java-new.check
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-
-make -C Java check
diff --git a/.ci/java-new.install b/.ci/java-new.install
deleted file mode 100755
index 2005ff9b..00000000
--- a/.ci/java-new.install
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-set -e
diff --git a/.ci/java-old.build b/.ci/java-old.build
deleted file mode 100755
index af3f87f4..00000000
--- a/.ci/java-old.build
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-
-./autogen.sh
-./configure --with-jdk-include=/usr/lib/jvm/default-java/include \
- --with-jdk-system-include=/usr/lib/jvm/default-java/include/linux \
- CC=clang CXX=clang++ CXXFLAGS='-O2'
-make -C Java
diff --git a/.ci/java-old.check b/.ci/java-old.check
deleted file mode 100755
index a288402d..00000000
--- a/.ci/java-old.check
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-
-make -C Java check
diff --git a/.ci/java-old.install b/.ci/java-old.install
deleted file mode 100755
index 2005ff9b..00000000
--- a/.ci/java-old.install
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-set -e
diff --git a/.ci/python.build b/.ci/python.build
deleted file mode 100755
index aa36b29f..00000000
--- a/.ci/python.build
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-set -e
-
-./autogen.sh
-./configure PYTHON=/usr/bin/python3 CC=clang CXX=clang++ CXXFLAGS='-O1'
-make -C Python
-make -C Python wheel
diff --git a/.ci/python.check b/.ci/python.check
deleted file mode 100755
index e8ad9d40..00000000
--- a/.ci/python.check
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-set -e
-
-make -C Python check
-
-. .venv/bin/activate
-for i in Python/examples/*.py
-do
- echo "$i"
- python "$i" || break -1
-done
diff --git a/.ci/python.install b/.ci/python.install
deleted file mode 100755
index 11b983fd..00000000
--- a/.ci/python.install
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-
-python3 -m venv .venv
-. .venv/bin/activate
-pip install Python/dist/QuantLib-*.whl
-grep -v QuantLib binder/requirements.txt > Python/examples/requirements.txt
-pip install -r Python/examples/requirements.txt
diff --git a/.ci/r.build b/.ci/r.build
deleted file mode 100755
index 6d985890..00000000
--- a/.ci/r.build
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-set -e
-
-mkdir -p ~/.R
-echo 'CC=clang' > ~/.R/Makevars
-echo 'CXX=clang++' >> ~/.R/Makevars
-
-./autogen.sh
-./configure CXXFLAGS='-O0'
-make -C R
diff --git a/.ci/r.check b/.ci/r.check
deleted file mode 100755
index b6d2aaa0..00000000
--- a/.ci/r.check
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-set -e
-
-echo Execute Scripts in demo folder
-for fn in ./R/demo/*.R
-do
- echo $fn
- Rscript "$fn" || break -1
-done
diff --git a/.ci/r.install b/.ci/r.install
deleted file mode 100755
index 8e6262c4..00000000
--- a/.ci/r.install
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-
-R CMD INSTALL ./R.Rcheck/QuantLib
diff --git a/.ci/scala.build b/.ci/scala.build
deleted file mode 100755
index a1a36510..00000000
--- a/.ci/scala.build
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-set -e
-
-./autogen.sh
-./configure --with-jdk-include=/usr/lib/jvm/default-java/include \
- --with-jdk-system-include=/usr/lib/jvm/default-java/include/linux CXXFLAGS='-O2'
-make -C Java
diff --git a/.ci/scala.check b/.ci/scala.check
deleted file mode 100755
index eb0eeb22..00000000
--- a/.ci/scala.check
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-
-make -C Scala check
diff --git a/.ci/scala.install b/.ci/scala.install
deleted file mode 100755
index 2005ff9b..00000000
--- a/.ci/scala.install
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-set -e
diff --git a/.gitignore b/.gitignore
index 9a02c02b..2635a8c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,27 +1,4 @@
# Compilation artifacts
-configure
-aclocal.m4
-autom4te.cache
-config.log
-config.status
-config/
-CSharp/cpp/quantlib_wrap.cpp
-CSharp/cpp/quantlib_wrap.h
-CSharp/cpp/build
-CSharp/csharp/obj
-CSharp/examples/*/bin
-CSharp/examples/*/obj
-CSharp/.vs/
-Java/bin/
-Java/quantlib_wrap.cpp
-Java/quantlib_wrap.h
-Perl/Makefile.quantlib
-Perl/QuantLib.bs
-Perl/blib/
-Perl/pm_to_blib
-Perl/quantlib_wrap.cpp
-Perl/MYMETA.yml
-Perl/MYMETA.json
Python/QuantLib/quantlib_wrap.cpp
Python/.cache/
Python/QuantLib.egg-info
@@ -29,12 +6,6 @@ Python/QuantLib_Python.egg-info
Python/dist
Python/examples/*.ipynb
Python/examples/.ipynb_checkpoints
-R/src/QuantLib.cpp
-R/makeRData.Rout
-R/src/symbols.rds
-R.Rcheck
-Ruby/extension.mak
-Ruby/quantlib_wrap.cpp
# Build outputs
**/x64/Debug
@@ -83,18 +54,11 @@ testCaseCollection.xml
*.ipch
# Outputs
-CSharp/csharp/*.cs
-CSharp/NQuantLib.dll
-Java/QuantLib.jar
-Java/*.jnilib
-Java/org/
-Perl/QuantLib.pm
Python/QuantLib_Risks/QuantLib_Risks.py
Python/build
-R/R/QuantLib.R
-R/QuantLib.RData
.vscode
**/venv
/build
-**/.venv
\ No newline at end of file
+**/.venv
+__pycache__
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index ed95341e..2e64546a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,6 +4,6 @@
[submodule "lib/XAD"]
path = lib/XAD
url = https://github.com/auto-differentiation/XAD.git
-[submodule "lib/quantlib-xad"]
- path = lib/quantlib-xad
- url = https://github.com/auto-differentiation/quantlib-xad.git
+[submodule "lib/QuantLib-Risks-Cpp"]
+ path = lib/QuantLibRisks-Cpp
+ url = https://github.com/auto-differentiation/QuantLib-Risks-Cpp.git
diff --git a/.misspell-fixer.ignore b/.misspell-fixer.ignore
deleted file mode 100644
index 8b76091d..00000000
--- a/.misspell-fixer.ignore
+++ /dev/null
@@ -1,2 +0,0 @@
-^./ChangeLog.txt
-
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aea6175b..4d2f73ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,12 @@ the underlying QuantLib-SWIG changelog.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [1.33-post1] - 2024-03-26
+## [1.33.3] - 2024-04-03
+
+- Builds against renamed xad-autodiff -> xad Python package
+- Cleanup of repository
+
+## [1.33.2] - 2024-03-29
- Renaming quantlib-risks -> QuantLib-Risks for consistency
- Fixing markdown annotations in examples
@@ -18,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Initial release, matching QuantLib Python bindings version 1.33
-[1.33-post1]: https://github.com/auto-differentiation/QuantLib-Risks/compare/v1.33...v1.33-post1
+[1.33.3]: https://github.com/auto-differentiation/QuantLib-Risks/compare/v1.33.2...v1.33.3
+
+[1.33.2]: https://github.com/auto-differentiation/QuantLib-Risks/compare/v1.33...v1.33.2
[1.33]: https://github.com/auto-differentiation/QuantLib-Risks/releases/tag/v1.33
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9027fb5..5ecf3ea9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,17 +24,17 @@
##############################################################################
cmake_minimum_required(VERSION 3.15.0)
-project(QuantLib_Risks LANGUAGES CXX VERSION 1.33.2)
+project(QuantLib_Risks LANGUAGES CXX VERSION 1.33.3)
# For MSVC RUNTIME LIBRARY, need CMP0091=NEW and cmake 3.15+
cmake_policy(SET CMP0091 NEW)
set(PACKAGE_VERSION "${PROJECT_VERSION}")
-set(PACKAGE_VERSION_HEX "0x013302f0")
+set(PACKAGE_VERSION_HEX "0x013303f0")
set(QLR_VERSION ${PACKAGE_VERSION})
set(QLR_HEX_VERSION ${PACKAGE_VERSION_HEX})
-find_package(QuantLibXad REQUIRED)
+find_package(QuantLib-Risks REQUIRED)
find_package(SWIG REQUIRED)
include(UseSWIG)
diff --git a/CSharp/Makefile.am b/CSharp/Makefile.am
deleted file mode 100644
index 1e1c28a1..00000000
--- a/CSharp/Makefile.am
+++ /dev/null
@@ -1,68 +0,0 @@
-
-CLEANFILES = cpp/quantlib_wrap.* cpp/*.so cpp/*.dylib csharp/*.cs *.dll
-
-BUILT_SOURCES = cpp/quantlib_wrap.cpp cpp/quantlib_wrap.h
-
-if HAVE_DOTNET
-if BUILD_DOTNET
-
-all-local: cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@ csharp/bin/Release/net6.0/NQuantLib.dll
-
-cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@: cpp/quantlib_wrap.o
- $(CXX) -shared cpp/quantlib_wrap.o -o cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@ `quantlib-config --libs`
-
-cpp/quantlib_wrap.o: $(BUILT_SOURCES)
- $(CXX) -c -fpic $(CXXFLAGS) cpp/quantlib_wrap.cpp -o cpp/quantlib_wrap.o `quantlib-config --cflags`
-
-csharp/bin/Release/net6.0/NQuantLib.dll: $(BUILT_SOURCES)
- $(DOTNET) build --nologo -c Release -p:Version=$(PACKAGE_VERSION) csharp/NQuantLib.csproj
-
-nupkg: cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@ csharp/bin/Release/net6.0/NQuantLib.dll
- $(DOTNET) pack --no-build -c Release -p:PackageVersion=$(PACKAGE_VERSION) --include-symbols --include-source csharp/NQuantLib.csproj
-
-check-local: cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@ csharp/bin/Release/net6.0/NQuantLib.dll
- ln -f cpp/libNQuantLibc.@SHARED_LIB_EXTENSION@ examples/
- cd examples && LD_LIBRARY_PATH=. $(DOTNET) run -c Release --project BermudanSwaption/BermudanSwaption.csproj
- cd examples && LD_LIBRARY_PATH=. $(DOTNET) run -c Release --project EquityOption/EquityOption.csproj
- cd examples && LD_LIBRARY_PATH=. $(DOTNET) run -c Release --project FiniteDifferenceMethods/FiniteDifferenceMethods.csproj
- cd examples && LD_LIBRARY_PATH=. $(DOTNET) run -c Release --project Times/Times.csproj
- rm -f examples/libNQuantLibc.@SHARED_LIB_EXTENSION@
-
-clean-local:
- rm -rf csharp/bin csharp/obj examples/*/bin examples/*/obj
-
-endif
-endif
-
-$(BUILT_SOURCES): ../SWIG/*.i
- $(SWIG) -csharp -c++ -outdir csharp \
- -namespace QuantLib -o cpp/quantlib_wrap.cpp ../SWIG/quantlib.i
-
-dist-hook: $(BUILT_SOURCES)
- mkdir -p $(distdir)/cpp
- cp ./cpp/*.vcxproj $(distdir)/cpp
- cp ./cpp/quantlib_wrap.cpp $(distdir)/cpp
- cp ./cpp/quantlib_wrap.h $(distdir)/cpp
- mkdir -p $(distdir)/csharp
- cp ./csharp/*.csproj $(distdir)/csharp
- cp ./csharp/*.cs $(distdir)/csharp
- mkdir -p $(distdir)/examples
- mkdir -p $(distdir)/examples/BermudanSwaption
- cp ./examples/BermudanSwaption/BermudanSwaption.csproj $(distdir)/examples/BermudanSwaption
- cp ./examples/BermudanSwaption/BermudanSwaption.cs $(distdir)/examples/BermudanSwaption
- mkdir -p $(distdir)/examples/EquityOption
- cp ./examples/EquityOption/EquityOption.csproj $(distdir)/examples/EquityOption
- cp ./examples/EquityOption/EquityOption.cs $(distdir)/examples/EquityOption
- mkdir -p $(distdir)/examples/FiniteDifferenceMethods
- cp ./examples/FiniteDifferenceMethods/FiniteDifferenceMethods.csproj $(distdir)/examples/FiniteDifferenceMethods
- cp ./examples/FiniteDifferenceMethods/FiniteDifferenceMethods.cs $(distdir)/examples/FiniteDifferenceMethods
- mkdir -p $(distdir)/examples/Times
- cp ./examples/Times/Times.csproj $(distdir)/examples/Times
- cp ./examples/Times/Times.cs $(distdir)/examples/Times
-
-EXTRA_DIST = \
- QuantLib.sln \
- QuantLib.props \
- swig.cmd \
- README.txt
-
diff --git a/CSharp/QuantLib.props b/CSharp/QuantLib.props
deleted file mode 100644
index ef46bbdf..00000000
--- a/CSharp/QuantLib.props
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- v100
- v110
- v120
- v130
- v140
- v141
- v142
- v143
-
-
diff --git a/CSharp/QuantLib.sln b/CSharp/QuantLib.sln
deleted file mode 100644
index e97a489e..00000000
--- a/CSharp/QuantLib.sln
+++ /dev/null
@@ -1,92 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31515.178
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BermudanSwaption", "examples\BermudanSwaption\BermudanSwaption.csproj", "{1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}"
- ProjectSection(ProjectDependencies) = postProject
- {21183104-9963-4D4F-B7E8-C8A6169FD053} = {21183104-9963-4D4F-B7E8-C8A6169FD053}
- EndProjectSection
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EquityOption", "examples\EquityOption\EquityOption.csproj", "{1FD947F1-D99E-46FB-8890-04E11E8340C2}"
- ProjectSection(ProjectDependencies) = postProject
- {21183104-9963-4D4F-B7E8-C8A6169FD053} = {21183104-9963-4D4F-B7E8-C8A6169FD053}
- EndProjectSection
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FiniteDifferenceMethods", "examples\FiniteDifferenceMethods\FiniteDifferenceMethods.csproj", "{EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}"
- ProjectSection(ProjectDependencies) = postProject
- {21183104-9963-4D4F-B7E8-C8A6169FD053} = {21183104-9963-4D4F-B7E8-C8A6169FD053}
- EndProjectSection
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NQuantLib", "csharp\NQuantLib.csproj", "{928F98EE-7D50-457F-9304-A6818DCF1079}"
- ProjectSection(ProjectDependencies) = postProject
- {21183104-9963-4D4F-B7E8-C8A6169FD053} = {21183104-9963-4D4F-B7E8-C8A6169FD053}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NQuantLibc", "cpp\QuantLibWrapper.vcxproj", "{21183104-9963-4D4F-B7E8-C8A6169FD053}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Times", "examples\Times\Times.csproj", "{C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Debug|Win32.Build.0 = Debug|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Debug|x64.ActiveCfg = Debug|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Debug|x64.Build.0 = Debug|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Release|Win32.ActiveCfg = Release|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Release|Win32.Build.0 = Release|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Release|x64.ActiveCfg = Release|Any CPU
- {1BEC49E8-122D-4CC9-9DAC-DD59F551E5E9}.Release|x64.Build.0 = Release|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Debug|Win32.Build.0 = Debug|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Debug|x64.ActiveCfg = Debug|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Debug|x64.Build.0 = Debug|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Release|Win32.ActiveCfg = Release|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Release|Win32.Build.0 = Release|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Release|x64.ActiveCfg = Release|Any CPU
- {1FD947F1-D99E-46FB-8890-04E11E8340C2}.Release|x64.Build.0 = Release|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Debug|Win32.Build.0 = Debug|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Debug|x64.ActiveCfg = Debug|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Debug|x64.Build.0 = Debug|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Release|Win32.ActiveCfg = Release|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Release|Win32.Build.0 = Release|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Release|x64.ActiveCfg = Release|Any CPU
- {EF2AFADF-B632-4E95-BEB5-7B7109A9E4FD}.Release|x64.Build.0 = Release|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Debug|Win32.Build.0 = Debug|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Debug|x64.ActiveCfg = Debug|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Debug|x64.Build.0 = Debug|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Release|Win32.ActiveCfg = Release|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Release|Win32.Build.0 = Release|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Release|x64.ActiveCfg = Release|Any CPU
- {928F98EE-7D50-457F-9304-A6818DCF1079}.Release|x64.Build.0 = Release|Any CPU
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Debug|Win32.ActiveCfg = Debug|Win32
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Debug|Win32.Build.0 = Debug|Win32
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Debug|x64.ActiveCfg = Debug|x64
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Debug|x64.Build.0 = Debug|x64
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Release|Win32.ActiveCfg = Release|Win32
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Release|Win32.Build.0 = Release|Win32
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Release|x64.ActiveCfg = Release|x64
- {21183104-9963-4D4F-B7E8-C8A6169FD053}.Release|x64.Build.0 = Release|x64
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Debug|Win32.Build.0 = Debug|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Debug|x64.ActiveCfg = Debug|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Debug|x64.Build.0 = Debug|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Release|Win32.ActiveCfg = Release|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Release|Win32.Build.0 = Release|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Release|x64.ActiveCfg = Release|Any CPU
- {C93F5204-5BC9-4AB3-AC06-C2CCE166CEBD}.Release|x64.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {D5A8DD18-AC31-4E40-A70A-11339ED8FAE8}
- EndGlobalSection
-EndGlobal
diff --git a/CSharp/README.txt b/CSharp/README.txt
deleted file mode 100644
index 2d3cf3ee..00000000
--- a/CSharp/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-Visual Studio .NET projects are provided; note that before launching
-the IDE, you'll have to define an environment variable QL_DIR whose
-value must equal the path to your QuantLib installation, e.g.,
-"C:\Lib\QuantLib".
-
-The interfaces should also work with Mono on Linux; run 'make' in this
-directory.
-
diff --git a/CSharp/cpp/QuantLibWrapper.vcxproj b/CSharp/cpp/QuantLibWrapper.vcxproj
deleted file mode 100644
index f82e0454..00000000
--- a/CSharp/cpp/QuantLibWrapper.vcxproj
+++ /dev/null
@@ -1,207 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- NQuantLibc
- {21183104-9963-4D4F-B7E8-C8A6169FD053}
- NQuantLibc
- Win32Proj
-
-
-
-
- DynamicLibrary
- MultiByte
-
-
- DynamicLibrary
- MultiByte
-
-
- DynamicLibrary
- MultiByte
-
-
- DynamicLibrary
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- bin\$(Platform)\Debug\
- build\$(Platform)\Debug\
- true
- bin\$(Platform)\Release\
- build\$(Platform)\Release\
- false
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
-
-
-
- Disabled
- $(QL_DIR);%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;_USRDLL;QUANTLIBWRAPPER_EXPORTS;_cplusplus;NOMINMAX;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- true
-
-
- Level3
- EditAndContinue
- /bigobj %(AdditionalOptions)
-
-
- $(OutDir)NQuantLibc.dll
- $(QL_DIR)\lib;%(AdditionalLibraryDirectories)
- true
- $(OutDir)QuantlibWrapper.pdb
- Windows
- false
-
-
- $(OutDir)NQuantLibc.lib
- MachineX86
-
-
- copy "$(OutDir)NQuantLibc.dll" "$(ProjectDir)"
-
-
-
-
- Disabled
- $(QL_DIR);%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;_USRDLL;QUANTLIBWRAPPER_EXPORTS;_cplusplus;NOMINMAX;%(PreprocessorDefinitions)
- EnableFastChecks
- MultiThreadedDebugDLL
- true
-
-
- Level3
- ProgramDatabase
- /bigobj %(AdditionalOptions)
-
-
- $(OutDir)NQuantLibc.dll
- $(QL_DIR)\lib;%(AdditionalLibraryDirectories)
- true
- $(OutDir)QuantlibWrapper.pdb
- Windows
- false
-
-
- $(OutDir)NQuantLibc.lib
-
-
- copy "$(OutDir)NQuantLibc.dll" "$(ProjectDir)"
-
-
-
-
- $(QL_DIR);%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTLIBWRAPPER_EXPORTS;%(PreprocessorDefinitions)
- MultiThreadedDLL
- true
- true
-
-
- Level3
- ProgramDatabase
- 4244;%(DisableSpecificWarnings)
- /bigobj %(AdditionalOptions)
-
-
- $(OutDir)NQuantLibc.dll
- $(QL_DIR)\lib;%(AdditionalLibraryDirectories)
- true
- Windows
- true
- true
- false
-
-
- $(OutDir)NQuantLibc.lib
- MachineX86
-
-
- copy "$(OutDir)NQuantLibc.dll" "$(ProjectDir)"
-
-
-
-
- $(QL_DIR);%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTLIBWRAPPER_EXPORTS;%(PreprocessorDefinitions)
- MultiThreadedDLL
- true
- true
-
-
- Level3
- ProgramDatabase
- 4244;%(DisableSpecificWarnings)
- /bigobj %(AdditionalOptions)
-
-
- $(OutDir)NQuantLibc.dll
- $(QL_DIR)\lib;%(AdditionalLibraryDirectories)
- true
- Windows
- true
- true
- false
-
-
- $(OutDir)NQuantLibc.lib
-
-
- copy "$(OutDir)NQuantLibc.dll" "$(ProjectDir)"
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CSharp/cpp/QuantLibWrapper.vcxproj.filters b/CSharp/cpp/QuantLibWrapper.vcxproj.filters
deleted file mode 100644
index 5891cf4c..00000000
--- a/CSharp/cpp/QuantLibWrapper.vcxproj.filters
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx
-
-
-
-
- Source Files
-
-
-
-
- Header Files
-
-
-
diff --git a/CSharp/csharp/NQuantLib.csproj b/CSharp/csharp/NQuantLib.csproj
deleted file mode 100644
index 5a832b39..00000000
--- a/CSharp/csharp/NQuantLib.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- net6.0
- QuantLib
-
-
-
- runtimes/win-x64/native
-
-
- runtimes/linux-x64/native
-
-
- runtimes/osx-x64/native
-
-
-
diff --git a/CSharp/examples/BermudanSwaption/BermudanSwaption.cs b/CSharp/examples/BermudanSwaption/BermudanSwaption.cs
deleted file mode 100644
index c8134994..00000000
--- a/CSharp/examples/BermudanSwaption/BermudanSwaption.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- Copyright (C) 2005 Dominic Thuillier
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-using System;
-using QuantLib;
-
-namespace BermudanSwaption
-{
- class Run
- {
- private const int numRows = 5;
- private const int numCols = 5;
-
- private static int[] swapLengths = { 1, 2, 3, 4, 5 };
- private static double[] swaptionVols = {
- 0.1490, 0.1340, 0.1228, 0.1189, 0.1148,
- 0.1290, 0.1201, 0.1146, 0.1108, 0.1040,
- 0.1149, 0.1112, 0.1070, 0.1010, 0.0957,
- 0.1047, 0.1021, 0.0980, 0.0951, 0.1270,
- 0.1000, 0.0950, 0.0900, 0.1230, 0.1160 };
-
- private static void calibrateModel(
- ShortRateModel model,
- CalibrationHelperVector helpers,
- double lambda )
- {
- Simplex om = new Simplex( lambda );
- model.calibrate(helpers, om,
- new EndCriteria(1000, 250, 1e-7, 1e-7, 1e-7));
-
- // Output the implied Black volatilities
- for (int i=0; i
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main(string[] args)
- {
- DateTime startTime = DateTime.Now;
-
- Date todaysDate = new Date(15, Month.February, 2002);
- Calendar calendar = new TARGET();
- Date settlementDate = new Date(19, Month.February, 2002);
- Settings.instance().setEvaluationDate( todaysDate );
-
- // flat yield term structure impling 1x5 swap at 5%
- Quote flatRate = new SimpleQuote(0.04875825);
- FlatForward myTermStructure = new FlatForward(
- settlementDate,
- new QuoteHandle( flatRate ),
- new Actual365Fixed() );
- RelinkableYieldTermStructureHandle rhTermStructure =
- new RelinkableYieldTermStructureHandle();
- rhTermStructure.linkTo( myTermStructure );
-
- // Define the ATM/OTM/ITM swaps
- Period fixedLegTenor = new Period(1,TimeUnit.Years);
- BusinessDayConvention fixedLegConvention =
- BusinessDayConvention.Unadjusted;
- BusinessDayConvention floatingLegConvention =
- BusinessDayConvention.ModifiedFollowing;
- DayCounter fixedLegDayCounter =
- new Thirty360( Thirty360.Convention.European );
- Period floatingLegTenor = new Period(6,TimeUnit.Months);
- double dummyFixedRate = 0.03;
- IborIndex indexSixMonths = new Euribor6M( rhTermStructure );
-
- Date startDate = calendar.advance(settlementDate,1,TimeUnit.Years,
- floatingLegConvention);
- Date maturity = calendar.advance(startDate,5,TimeUnit.Years,
- floatingLegConvention);
- Schedule fixedSchedule = new Schedule(startDate,maturity,
- fixedLegTenor,calendar,fixedLegConvention,fixedLegConvention,
- DateGeneration.Rule.Forward,false);
- Schedule floatSchedule = new Schedule(startDate,maturity,
- floatingLegTenor,calendar,floatingLegConvention,
- floatingLegConvention,DateGeneration.Rule.Forward,false);
- VanillaSwap swap = new VanillaSwap(
- Swap.Type.Payer, 1000.0,
- fixedSchedule, dummyFixedRate, fixedLegDayCounter,
- floatSchedule, indexSixMonths, 0.0,
- indexSixMonths.dayCounter());
- DiscountingSwapEngine swapEngine =
- new DiscountingSwapEngine(rhTermStructure);
- swap.setPricingEngine(swapEngine);
- double fixedATMRate = swap.fairRate();
- double fixedOTMRate = fixedATMRate * 1.2;
- double fixedITMRate = fixedATMRate * 0.8;
-
- VanillaSwap atmSwap = new VanillaSwap(
- Swap.Type.Payer, 1000.0,
- fixedSchedule, fixedATMRate, fixedLegDayCounter,
- floatSchedule, indexSixMonths, 0.0,
- indexSixMonths.dayCounter() );
- VanillaSwap otmSwap = new VanillaSwap(
- Swap.Type.Payer, 1000.0,
- fixedSchedule, fixedOTMRate, fixedLegDayCounter,
- floatSchedule, indexSixMonths, 0.0,
- indexSixMonths.dayCounter());
- VanillaSwap itmSwap = new VanillaSwap(
- Swap.Type.Payer, 1000.0,
- fixedSchedule, fixedITMRate, fixedLegDayCounter,
- floatSchedule, indexSixMonths, 0.0,
- indexSixMonths.dayCounter());
- atmSwap.setPricingEngine(swapEngine);
- otmSwap.setPricingEngine(swapEngine);
- itmSwap.setPricingEngine(swapEngine);
-
- // defining the swaptions to be used in model calibration
- PeriodVector swaptionMaturities = new PeriodVector();
- swaptionMaturities.Add( new Period(1, TimeUnit.Years) );
- swaptionMaturities.Add( new Period(2, TimeUnit.Years) );
- swaptionMaturities.Add( new Period(3, TimeUnit.Years) );
- swaptionMaturities.Add( new Period(4, TimeUnit.Years) );
- swaptionMaturities.Add( new Period(5, TimeUnit.Years) );
-
- CalibrationHelperVector swaptions = new CalibrationHelperVector();
-
- // List of times that have to be included in the timegrid
- DoubleVector times = new DoubleVector();
-
- for ( int i=0; iparams()[0] << ", "
-// << "sigma = " << modelHW2->params()[1]
-// << std::endl << std::endl;
-
-
- Console.WriteLine( "Black-Karasinski (numerical) calibration" );
- for (int i=0; iparams()[0] << ", "
-// << "sigma = " << modelBK->params()[1]
-// << std::endl << std::endl;
-
- // ATM Bermudan swaption pricing
-
- Console.WriteLine( "Payer bermudan swaption struck at {0} (ATM)",
- fixedATMRate );
-
- DateVector bermudanDates = new DateVector();
- Schedule schedule = new Schedule(startDate,maturity,
- new Period(3,TimeUnit.Months),calendar,
- BusinessDayConvention.Following,
- BusinessDayConvention.Following,
- DateGeneration.Rule.Forward,false);
-
- for (uint i=0; i
-
-
- net6.0
- false
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CSharp/examples/EquityOption/EquityOption.cs b/CSharp/examples/EquityOption/EquityOption.cs
deleted file mode 100644
index 6c600e38..00000000
--- a/CSharp/examples/EquityOption/EquityOption.cs
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- Copyright (C) 2007 Eric H. Jensen
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using QuantLib;
-
-namespace EquityOptionTest
-{
- class EquityOption
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main(string[] args)
- {
- DateTime startTime = DateTime.Now;
-
- Option.Type optionType = Option.Type.Put;
- double underlyingPrice = 36;
- double strikePrice = 40;
- double dividendYield = 0.0;
- double riskFreeRate = 0.06;
- double volatility = 0.2;
-
- Date todaysDate = new Date(15, Month.May, 1998);
- Settings.instance().setEvaluationDate(todaysDate);
-
- Date settlementDate = new Date(17, Month.May, 1998);
- Date maturityDate = new Date(17, Month.May, 1999);
-
- Calendar calendar = new TARGET();
-
- DateVector exerciseDates = new DateVector(4);
- for (int i = 1; i <= 4; i++) {
- Period forwardPeriod = new Period(3 * i, TimeUnit.Months);
- Date forwardDate = settlementDate.Add(forwardPeriod);
- exerciseDates.Add(forwardDate);
- }
-
- EuropeanExercise europeanExercise =
- new EuropeanExercise(maturityDate);
- BermudanExercise bermudanExercise =
- new BermudanExercise(exerciseDates);
- AmericanExercise americanExercise =
- new AmericanExercise(settlementDate, maturityDate);
-
- // bootstrap the yield/dividend/vol curves and create a
- // BlackScholesMerton stochastic process
- DayCounter dayCounter = new Actual365Fixed();
- YieldTermStructureHandle flatRateTSH =
- new YieldTermStructureHandle(
- new FlatForward(settlementDate, riskFreeRate,
- dayCounter));
- YieldTermStructureHandle flatDividendTSH =
- new YieldTermStructureHandle(
- new FlatForward(settlementDate, dividendYield,
- dayCounter));
- BlackVolTermStructureHandle flatVolTSH =
- new BlackVolTermStructureHandle(
- new BlackConstantVol(settlementDate, calendar,
- volatility, dayCounter));
-
- QuoteHandle underlyingQuoteH =
- new QuoteHandle(new SimpleQuote(underlyingPrice));
- BlackScholesMertonProcess stochasticProcess =
- new BlackScholesMertonProcess(underlyingQuoteH,
- flatDividendTSH,
- flatRateTSH,
- flatVolTSH);
-
- PlainVanillaPayoff payoff =
- new PlainVanillaPayoff(optionType, strikePrice);
-
- // options
- VanillaOption europeanOption =
- new VanillaOption(payoff, europeanExercise);
- VanillaOption bermudanOption =
- new VanillaOption(payoff, bermudanExercise);
- VanillaOption americanOption =
- new VanillaOption(payoff, americanExercise);
-
- // report the parameters we are using
- ReportParameters(optionType, underlyingPrice, strikePrice,
- dividendYield, riskFreeRate,
- volatility, maturityDate);
-
- // write out the column headings
- ReportHeadings();
-
- #region Analytic Formulas
-
- // Black-Scholes for European
- try {
- europeanOption.setPricingEngine(
- new AnalyticEuropeanEngine(stochasticProcess));
- ReportResults("Black-Scholes",
- europeanOption.NPV(), null, null);
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Barone-Adesi and Whaley approximation for American
- try {
- americanOption.setPricingEngine(
- new BaroneAdesiWhaleyApproximationEngine(stochasticProcess));
- ReportResults("Barone-Adesi/Whaley",
- null, null, americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Bjerksund and Stensland approximation for American
- try {
- americanOption.setPricingEngine(
- new BjerksundStenslandApproximationEngine(stochasticProcess));
- ReportResults("Bjerksund/Stensland",
- null, null, americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Integral
- try {
- europeanOption.setPricingEngine(
- new IntegralEngine(stochasticProcess));
- ReportResults("Integral",
- europeanOption.NPV(), null, null);
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- uint timeSteps = 801;
-
- // Finite differences
- try {
- europeanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps, timeSteps - 1));
- bermudanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps, timeSteps - 1));
- americanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps, timeSteps - 1));
- ReportResults("Finite differences",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- //Variance Gamma
- try
- {
- VarianceGammaProcess vgProcess = new VarianceGammaProcess(underlyingQuoteH,
- flatDividendTSH,
- flatRateTSH,
- volatility, 0.01, 0.0
- );
- europeanOption.setPricingEngine(
- new VarianceGammaEngine(vgProcess));
- ReportResults("Variance-Gamma",
- europeanOption.NPV(), null, null);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
-
- #endregion Analytic Formulas
-
- #region Binomial Methods
-
- // Binomial Jarrow-Rudd
- try {
- europeanOption.setPricingEngine(
- new BinomialJRVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialJRVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialJRVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Jarrow-Rudd",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Binomial Cox-Ross-Rubinstein
- try {
- europeanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Cox-Ross-Rubinstein",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Additive Equiprobabilities
- try {
- europeanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Additive Equiprobabilities",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Binomial Trigeorgis
- try {
- europeanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Trigeorgis",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Binomial Tian
- try {
- europeanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Tian",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Binomial Leisen-Reimer
- try {
- europeanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Leisen-Reimer",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // Binomial Joshi
- try {
- europeanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- ReportResults("Binomial Joshi",
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV());
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- #endregion Binomial Methods
-
- #region Monte Carlo Methods
-
- // quantlib appears to use max numeric (int and real) values to test for 'null' (or rather 'default') values
-
- // MC (crude)
- try {
- int mcTimeSteps = 1;
- int timeStepsPerYear = int.MaxValue;
- bool brownianBridge = false;
- bool antitheticVariate = false;
- int requiredSamples = int.MaxValue;
- double requiredTolerance = 0.02;
- int maxSamples = int.MaxValue;
- int seed = 42;
- europeanOption.setPricingEngine(
- new MCPREuropeanEngine(stochasticProcess,
- mcTimeSteps,
- timeStepsPerYear,
- brownianBridge,
- antitheticVariate,
- requiredSamples,
- requiredTolerance,
- maxSamples, seed));
- ReportResults("MC (crude)", europeanOption.NPV(), null, null);
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- // MC (Sobol)
- try {
- int mcTimeSteps = 1;
- int timeStepsPerYear = int.MaxValue;
- bool brownianBridge = false;
- bool antitheticVariate = false;
- int requiredSamples = 32768; // 2^15
- double requiredTolerance = double.MaxValue;
- int maxSamples = int.MaxValue;
- int seed = 0;
- europeanOption.setPricingEngine(
- new MCLDEuropeanEngine(stochasticProcess,
- mcTimeSteps,
- timeStepsPerYear,
- brownianBridge,
- antitheticVariate,
- requiredSamples,
- requiredTolerance,
- maxSamples, seed));
- ReportResults("MC (Sobol)", europeanOption.NPV(), null, null);
- }
- catch (Exception e) {
- Console.WriteLine(e.ToString());
- }
-
- #endregion Monte Carlo Methods
-
- DateTime endTime = DateTime.Now;
- TimeSpan delta = endTime - startTime;
- Console.WriteLine();
- Console.WriteLine("Run completed in {0} s", delta.TotalSeconds);
- Console.WriteLine();
- }
-
- private static void ReportParameters(Option.Type optionType,
- double underlyingPrice,
- double strikePrice,
- double dividendYield,
- double riskFreeRate,
- double volatility,
- Date maturityDate)
- {
- Console.WriteLine();
- Console.WriteLine("Option type = {0}", optionType);
- Console.WriteLine("Maturity = {0} {1} {2}", maturityDate.year(),
- maturityDate.month(), maturityDate.dayOfMonth());
- Console.WriteLine("Underlying price = ${0}", underlyingPrice);
- Console.WriteLine("Strike = ${0}", strikePrice);
- Console.WriteLine("Risk-free interest rate = {0}%",
- riskFreeRate * 100.0);
- Console.WriteLine("Dividend yield = {0}%", dividendYield * 100.0);
- Console.WriteLine("Volatility = {0}%", volatility * 100);
- Console.WriteLine();
- }
-
- private static int[] columnWidths = { 35, 14, 14, 14 };
-
- private static void ReportHeadings()
- {
- Console.Write("Method".PadRight(columnWidths[0]));
- Console.Write("European".PadRight(columnWidths[1]));
- Console.Write("Bermudan".PadRight(columnWidths[2]));
- Console.Write("American".PadRight(columnWidths[3]));
- Console.WriteLine();
- }
-
- private static void ReportResults(string methodName, double? european,
- double? bermudan, double? american)
- {
- string strNA = "N/A";
- string format = "{0:N6}";
- Console.Write(methodName.PadRight(columnWidths[0]));
- Console.Write(String.Format((european == null) ? strNA : format,
- european).PadRight(columnWidths[1]));
- Console.Write(String.Format((bermudan == null) ? strNA : format,
- bermudan).PadRight(columnWidths[2]));
- Console.Write(String.Format((american == null) ? strNA : format,
- american).PadRight(columnWidths[3]));
- Console.WriteLine();
- }
- }
-}
-
diff --git a/CSharp/examples/EquityOption/EquityOption.csproj b/CSharp/examples/EquityOption/EquityOption.csproj
deleted file mode 100644
index 7503700c..00000000
--- a/CSharp/examples/EquityOption/EquityOption.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net6.0
- false
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.cs b/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.cs
deleted file mode 100644
index 0ba14f0d..00000000
--- a/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- Copyright (C) 2020 Klaus Spanderen
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-using System;
-
-using QuantLib;
-using static QuantLib.NQuantLibc;
-
-namespace FiniteDifferenceMethods
-{
- class FdmDemo
- {
- // test class for the operator delegate and proxy
- public class FdmBSDelegate : FdmLinearOpCompositeDelegate
- {
- private readonly FdmLinearOpComposite op;
-
- public FdmBSDelegate(FdmLinearOpComposite op)
- {
- this.op = op;
- }
-
- override public uint size()
- {
- return op.size();
- }
-
- override public void setTime(double t1, double t2)
- {
- op.setTime(t1, t2);
- }
-
- override public QlArray apply(QlArray r)
- {
- return op.apply(r);
- }
-
- override public QlArray apply_direction(uint i, QlArray r)
- {
- return op.apply_direction(i, r);
- }
-
- override public QlArray solve_splitting(uint i, QlArray r, double s)
- {
- return op.solve_splitting(i, r, s);
- }
- };
-
- static void Main(string[] args)
- {
- const int xSteps = 100;
- const int tSteps = 25;
- const int dampingSteps = 0;
-
- Date today = new Date(15, Month.January, 2020);
- Settings.instance().setEvaluationDate(today);
-
- DayCounter dc = new Actual365Fixed();
-
- YieldTermStructureHandle rTS = new YieldTermStructureHandle(
- new FlatForward(today, 0.06, dc));
- YieldTermStructureHandle qTS = new YieldTermStructureHandle(
- new FlatForward(today, 0.02, dc));
-
- const double strike = 110.0;
- StrikedTypePayoff payoff = new PlainVanillaPayoff(Option.Type.Put, strike);
-
- Date maturityDate = today.Add(new Period(1, TimeUnit.Years));
- double maturity = dc.yearFraction(today, maturityDate);
-
- Exercise exercise = new AmericanExercise(today, maturityDate);
-
- Instrument vanillaOption = new VanillaOption(payoff, exercise);
-
- QuoteHandle spot = new QuoteHandle(new SimpleQuote(100.0));
- BlackVolTermStructureHandle volatility = new BlackVolTermStructureHandle(
- new BlackConstantVol(today, new TARGET(), 0.20, dc));
-
- BlackScholesMertonProcess process =
- new BlackScholesMertonProcess(spot, qTS, rTS, volatility);
-
- vanillaOption.setPricingEngine(new FdBlackScholesVanillaEngine(
- process, tSteps, xSteps, dampingSteps));
-
- double expected = vanillaOption.NPV();
-
- // build an PDE engine from scratch
- Fdm1dMesher equityMesher = new FdmBlackScholesMesher(
- xSteps, process, maturity, strike,
- nullDouble(), nullDouble(), 0.0001, 1.5,
- new DoublePair(strike, 0.1));
-
- FdmMesherComposite mesher = new FdmMesherComposite(equityMesher);
-
- FdmLinearOpComposite op = new FdmBlackScholesOp(mesher, process, strike);
-
- FdmInnerValueCalculator calc = new FdmLogInnerValue(payoff, mesher, 0);
-
- QlArray x = new QlArray(equityMesher.size());
- QlArray rhs = new QlArray(equityMesher.size());
-
- FdmLinearOpIterator iter = mesher.layout().begin();
- for (uint i = 0; i < rhs.size(); ++i, iter.increment())
- {
- x.set(i, mesher.location(iter, 0));
- rhs.set(i, calc.avgInnerValue(iter, maturity));
- }
-
- FdmBoundaryConditionSet bcSet = new FdmBoundaryConditionSet();
-
- FdmStepConditionComposite stepCondition =
- FdmStepConditionComposite.vanillaComposite(
- new DividendSchedule(), exercise, mesher, calc, today, dc);
-
-
- FdmLinearOpComposite proxyOp = new FdmLinearOpCompositeProxy(
- new FdmBSDelegate(op));
-
- FdmBackwardSolver solver = new FdmBackwardSolver(
- proxyOp, bcSet, stepCondition, FdmSchemeDesc.Douglas());
-
- solver.rollback(rhs, maturity, 0.0, tSteps, dampingSteps);
-
- double logS = Math.Log(spot.value());
-
- double calculated = new CubicNaturalSpline(x, rhs).call(logS);
-
- Console.WriteLine("Homebrew PDE engine : {0:0.0000}", calculated);
- Console.WriteLine("FdBlackScholesVanillaEngine: {0:0.0000}", expected);
- }
- }
-}
\ No newline at end of file
diff --git a/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.csproj b/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.csproj
deleted file mode 100644
index 7503700c..00000000
--- a/CSharp/examples/FiniteDifferenceMethods/FiniteDifferenceMethods.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net6.0
- false
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CSharp/examples/Times/Times.cs b/CSharp/examples/Times/Times.cs
deleted file mode 100644
index 9da98ac3..00000000
--- a/CSharp/examples/Times/Times.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- Copyright (C) 2021 Ralf Konrad Eckel
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-#pragma warning disable CS1718 // Comparison made to same variable
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using QL = QuantLib;
-
-namespace TimesTest
-{
- class Times
- {
- class TestCaseException : Exception { }
-
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main(string[] args)
- {
- try
- {
- DateTime startTime = DateTime.Now;
-
- RunTestCases();
-
- DateTime endTime = DateTime.Now;
- TimeSpan delta = endTime - startTime;
- Console.WriteLine();
- Console.WriteLine("Run completed in {0} s", delta.TotalSeconds);
- Console.WriteLine();
- }
- catch (TestCaseException exc)
- {
- Console.Error.WriteLine(exc);
- throw;
- }
- }
-
- private static void RunTestCases()
- {
- Action> writePeriods = (heading, periods2Write) =>
- {
- Console.Write($" {heading}: ");
- foreach (var item in periods2Write)
- {
- var itemAsString = item != null ? item.ToString() : "null";
- Console.Write($"{itemAsString} ");
- }
- Console.WriteLine();
- };
-
- Action testCase = (testResult) =>
- {
- if (!testResult) throw new TestCaseException();
- };
-
- var tenorNull = null as QL.Period;
- var tenor91D = new QL.Period("91D");
- var tenor03M = new QL.Period("03M");
- var tenor06M = new QL.Period("06M");
- var tenor12M = new QL.Period("12M");
- var tenor01Y = new QL.Period("01Y");
- var tenor02Y = new QL.Period("02Y");
-
- var periods = new List() { tenor01Y, tenorNull, tenor02Y, tenor06M, tenor03M };
-
- Console.WriteLine("Testing sorting of a list.");
- writePeriods("Before sorting", periods);
-
- periods.Sort();
-
- writePeriods(" After sorting", periods);
-
- testCase(periods[0] == tenorNull);
- testCase(periods[1] == tenor03M);
- testCase(periods[2] == tenor06M);
- testCase(periods[3] == tenor01Y);
- testCase(periods[4] == tenor02Y);
-
-
- #region test Period.CompareTo(Period)
-
- Console.WriteLine("test Period.CompareTo(Period)");
-
- testCase(tenor12M.CompareTo(tenorNull) > 0);
- testCase(tenor12M.CompareTo(tenor03M) > 0);
- testCase(tenor12M.CompareTo(tenor06M) > 0);
- testCase(tenor12M.CompareTo(tenor01Y) == 0);
- testCase(tenor01Y.CompareTo(tenor01Y) == 0);
- testCase(tenor12M.CompareTo(tenor02Y) < 0);
-
- #endregion
-
- #region test Period == Period
-
- Console.WriteLine("test Period == Period");
-
- testCase(tenorNull == null);
- testCase(null == tenorNull);
- testCase(!(tenorNull == tenor12M));
- testCase(!(tenor12M == null));
- testCase(tenor12M == tenor12M);
- testCase(tenor12M == tenor01Y);
- testCase(!(tenor12M == tenor06M));
- testCase(!(tenor06M == tenor12M));
-
- #endregion
-
- #region test Period != Period
-
- Console.WriteLine("test Period != Period");
-
- testCase(!(tenorNull != null));
- testCase(!(null != tenorNull));
- testCase(tenorNull != tenor12M);
- testCase(tenor12M != null);
- testCase(!(tenor12M != tenor12M));
- testCase(!(tenor12M != tenor01Y));
- testCase(tenor12M != tenor06M);
-
- #endregion
-
- #region test Period < Period
-
- Console.WriteLine("test Period < Period");
-
- testCase(!(tenorNull < null));
- testCase(!(null < tenorNull));
- testCase(tenorNull < tenor12M);
- testCase(!(tenor12M < null));
- testCase(!(tenor12M < tenor12M));
- testCase(!(tenor12M < tenor01Y));
- testCase(!(tenor12M < tenor06M));
- testCase(tenor06M < tenor12M);
-
- #endregion
-
- #region test Period <= Period
-
- Console.WriteLine("test Period <= Period");
-
- testCase(tenorNull <= null);
- testCase(null <= tenorNull);
- testCase(tenorNull <= tenor12M);
- testCase(!(tenor12M <= null));
- testCase(tenor12M <= tenor12M);
- testCase(tenor12M <= tenor01Y);
- testCase(!(tenor12M <= tenor06M));
- testCase(tenor06M <= tenor12M);
-
- #endregion
-
- #region test Period > Period
-
- Console.WriteLine("test Period > Period");
-
- testCase(!(tenorNull > null));
- testCase(!(null > tenorNull));
- testCase(!(tenorNull > tenor12M));
- testCase(tenor12M > null);
- testCase(!(tenor12M > tenor12M));
- testCase(!(tenor12M > tenor01Y));
- testCase(tenor12M > tenor06M);
- testCase(!(tenor06M > tenor12M));
-
- #endregion
-
- #region test Period >= Period
-
- Console.WriteLine("test Period >= Period");
-
- testCase(tenorNull >= null);
- testCase(null >= tenorNull);
- testCase(!(tenorNull >= tenor12M));
- testCase(tenor12M >= null);
- testCase(tenor12M >= tenor12M);
- testCase(tenor12M >= tenor01Y);
- testCase(tenor12M >= tenor06M);
- testCase(!(tenor06M >= tenor12M));
-
- #endregion
-
- Console.WriteLine("test Period.GetHashCode()");
- testCase(tenor01Y.GetHashCode() == tenor12M.GetHashCode());
-
- Console.WriteLine("test that uncomparable periods throw");
- Func compare91Dversus03MthrowsApplicationException = () =>
- {
- bool hasThrown = false;
- try
- {
- tenor91D.CompareTo(tenor03M);
- }
- catch (System.ApplicationException)
- {
- hasThrown = true;
- }
- return hasThrown;
- };
-
- testCase(compare91Dversus03MthrowsApplicationException());
- }
- }
-}
-
-#pragma warning restore CS1718 // Comparison made to same variable
diff --git a/CSharp/examples/Times/Times.csproj b/CSharp/examples/Times/Times.csproj
deleted file mode 100644
index 7503700c..00000000
--- a/CSharp/examples/Times/Times.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net6.0
- false
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CSharp/swig.cmd b/CSharp/swig.cmd
deleted file mode 100644
index a240d6a6..00000000
--- a/CSharp/swig.cmd
+++ /dev/null
@@ -1 +0,0 @@
-swig.exe -csharp -c++ -outdir csharp -namespace QuantLib -o cpp\quantlib_wrap.cpp ..\SWIG\quantlib.i
diff --git a/Java/Makefile.am b/Java/Makefile.am
deleted file mode 100644
index 4b716432..00000000
--- a/Java/Makefile.am
+++ /dev/null
@@ -1,77 +0,0 @@
-
-CLEANFILES = quantlib_wrap.cpp libQuantLibJNI.@JNILIB_EXTENSION@ QuantLib.jar
-
-BUILT_SOURCES = quantlib_wrap.cpp quantlib_wrap.h
-
-EXAMPLES = Bonds CallableBonds CallableBondsOAS DiscreteHedging EquityOptions FRA FunctionDelegates Time
-
-SWIGFLAGS =
-
-if JAVA_AUTOLOAD
-SWIGFLAGS += -DJAVA_AUTOLOAD
-endif
-
-if JAVA_FINALIZER
-SWIGFLAGS += -DJAVA_FINALIZER
-endif
-
-if JAVA_AUTOCLOSEABLE
-SWIGFLAGS += -DJAVA_AUTOCLOSEABLE
-endif
-
-if HAVE_JAVA
-if BUILD_JAVA
-
-examples/%.class: examples/%.java QuantLib.jar
- $(JAVAC) -cp QuantLib.jar examples/$*.java
-
-.PHONY: $(EXAMPLES)
-
-all-local: libQuantLibJNI.@JNILIB_EXTENSION@ QuantLib.jar
-
-quantlib_wrap.o: quantlib_wrap.cpp quantlib_wrap.h
- $(CXX) -c quantlib_wrap.cpp -fno-strict-aliasing -fPIC $(CXXFLAGS) @JDK_INCLUDE@ @JDK_SYSTEM_INCLUDE@ `quantlib-config --cflags` -o quantlib_wrap.o
-
-libQuantLibJNI.@JNILIB_EXTENSION@: quantlib_wrap.o
- $(CXX) $(CXXFLAGS) $(LDFLAGS) @SHARED_LIB@ quantlib_wrap.o -o libQuantLibJNI.@JNILIB_EXTENSION@ `quantlib-config --libs`
-
-QuantLib.jar: quantlib_wrap.cpp org/quantlib/*.java
- mkdir -p bin
- find org/quantlib -name '*.java' | xargs $(JAVAC) -g -d bin
- $(JAR) cf QuantLib.jar -C bin org
-
-install-exec-local:
- mkdir -p $(DESTDIR)/$(libdir)
- cp -p libQuantLibJNI.@JNILIB_EXTENSION@ $(DESTDIR)/$(libdir)/libQuantLibJNI.@JNILIB_EXTENSION@
- cp -p QuantLib.jar $(DESTDIR)/$(libdir)/QuantLib.jar
-
-check-local: $(EXAMPLES)
-
-$(EXAMPLES): $(EXAMPLES:%=examples/%.class)
- LD_LIBRARY_PATH=. $(JAVA) -cp ".:QuantLib.jar" examples.$@
-
-endif
-endif
-
-
-quantlib_wrap.cpp: ../SWIG/*.i
- mkdir -p org/quantlib
- $(SWIG) $(SWIGFLAGS) -java -c++ -outdir org/quantlib \
- -package org.quantlib -o quantlib_wrap.cpp ../SWIG/quantlib.i
-
-dist-hook:
- mkdir -p $(distdir)/org/quantlib
- cp ./org/quantlib/*.java $(distdir)/org/quantlib
- touch $(distdir)/quantlib_wrap.cpp
- touch $(distdir)/quantlib_wrap.h
- mkdir -p $(distdir)/examples
- cp ./examples/*.java $(distdir)/examples
-
-clean-local:
- rm -rf org
- rm -f examples/*.class
- rm -f quantlib_wrap.o
- rm -rf bin
-
-EXTRA_DIST = README.txt $(BUILT_SOURCES)
-
diff --git a/Java/README.txt b/Java/README.txt
deleted file mode 100644
index 799da6e0..00000000
--- a/Java/README.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-
-Instructions for building the QuantLib-Java module under Eclipse are
-available at
-.
-
-On Linux systems, the module can be build by supplying the location of
-the JDK to configure, as in (for example)
-
-./configure --with-jdk-include=/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include \
- --with-jdk-system-include=usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux
-
-and by running 'make' afterwards.
-
diff --git a/Java/examples/Bonds.java b/Java/examples/Bonds.java
deleted file mode 100644
index f7f8cd0c..00000000
--- a/Java/examples/Bonds.java
+++ /dev/null
@@ -1,545 +0,0 @@
-
-/*
- Copyright (C) 2014 Wondersys Srl
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import java.util.ArrayList;
-
-import org.quantlib.Actual360;
-import org.quantlib.Actual365Fixed;
-import org.quantlib.ActualActual;
-import org.quantlib.BlackIborCouponPricer;
-import org.quantlib.BusinessDayConvention;
-import org.quantlib.Calendar;
-import org.quantlib.Compounding;
-import org.quantlib.ConstantOptionletVolatility;
-import org.quantlib.Date;
-import org.quantlib.DateGeneration;
-import org.quantlib.DayCounter;
-import org.quantlib.DepositRateHelper;
-import org.quantlib.DiscountingBondEngine;
-import org.quantlib.DoubleVector;
-import org.quantlib.Euribor6M;
-import org.quantlib.FixedRateBond;
-import org.quantlib.FixedRateBondHelper;
-import org.quantlib.FloatingRateBond;
-import org.quantlib.FloatingRateCouponPricer;
-import org.quantlib.Frequency;
-import org.quantlib.IborCouponPricer;
-import org.quantlib.IborIndex;
-import org.quantlib.Month;
-import org.quantlib.OptionletVolatilityStructureHandle;
-import org.quantlib.Period;
-import org.quantlib.PiecewiseFlatForward;
-import org.quantlib.PiecewiseLinearForward;
-import org.quantlib.PricingEngine;
-import org.quantlib.QuantLib;
-import org.quantlib.QuantLibJNI;
-import org.quantlib.QuoteHandle;
-import org.quantlib.QuoteVector;
-import org.quantlib.RateHelper;
-import org.quantlib.RateHelperVector;
-import org.quantlib.QuoteHandleVector;
-import org.quantlib.RelinkableYieldTermStructureHandle;
-import org.quantlib.Schedule;
-import org.quantlib.Settings;
-import org.quantlib.SimpleQuote;
-import org.quantlib.SwapRateHelper;
-import org.quantlib.TARGET;
-import org.quantlib.Thirty360;
-import org.quantlib.TimeUnit;
-import org.quantlib.USDLibor;
-import org.quantlib.UnitedStates;
-import org.quantlib.YieldTermStructure;
-import org.quantlib.YieldTermStructureHandle;
-import org.quantlib.ZeroCouponBond;
-
-public class Bonds {
- public static void main(String[] args) throws Exception {
-
- // MARKET DATA
- Calendar cal = new TARGET();
- Date settlementDate = new Date(18, Month.September, 2008);
- // must be a business day
- settlementDate = cal.adjust(settlementDate);
-
- int fixingDays = 3;
- int settlementdays = 3;
-
- Date todayDate = cal.advance(settlementDate,
- -fixingDays, TimeUnit.Days);
-
- Settings.instance().setEvaluationDate(todayDate);
-
- System.out.println("Today: " + todayDate.weekday()
- + ", " + todayDate);
- System.out.println("Settlement date: " + settlementDate.weekday()
- + ", " + settlementDate);
-
- // Building of the bonds discounting yield curve
-
- // RATE HELPERS
-
- // RateHelpers are built from the above quotes together with
- // other instrument dependant infos. Quotes are passed in
- // relinkable handles which could be relinked to some other
- // data source later.
-
- // Common data
-
- // ZC rates for the short end
-
- QuoteHandle zc3mRate = new QuoteHandle(new SimpleQuote(0.0096));
- QuoteHandle zc6mRate = new QuoteHandle(new SimpleQuote(0.0145));
- QuoteHandle zc1yRate = new QuoteHandle(new SimpleQuote(0.0194));
-
- DayCounter zcBondsDayCounter = new Actual365Fixed();
-
- DepositRateHelper zc3m =
- new DepositRateHelper(zc3mRate, new Period(3, TimeUnit.Months),
- fixingDays, cal,
- BusinessDayConvention.ModifiedFollowing,
- true, zcBondsDayCounter);
-
- DepositRateHelper zc6m =
- new DepositRateHelper(zc6mRate, new Period(6, TimeUnit.Months),
- fixingDays, cal,
- BusinessDayConvention.ModifiedFollowing,
- true, zcBondsDayCounter);
-
- DepositRateHelper zc1y =
- new DepositRateHelper(zc1yRate, new Period(1, TimeUnit.Years),
- fixingDays, cal,
- BusinessDayConvention.ModifiedFollowing,
- true, zcBondsDayCounter);
-
- // setup bonds
- double redemption = 100.0;
- final int numberOfBonds = 5;
-
- Date issueDates[] = {
- new Date(15, Month.March, 2005),
- new Date(15, Month.June, 2005),
- new Date(30, Month.June, 2006),
- new Date(15, Month.November, 2002),
- new Date(15, Month.May, 1987),
- };
-
- Date maturities[] = {
- new Date(31, Month.August, 2010),
- new Date(31, Month.August, 2011),
- new Date(31, Month.August, 2013),
- new Date(15, Month.August, 2018),
- new Date(15, Month.May, 2038),
- };
-
- double couponRates[] = {
- 0.02375,
- 0.04625,
- 0.03125,
- 0.04000,
- 0.04500
- };
-
- SimpleQuote marketQuotes[] = {
- new SimpleQuote(100.390625),
- new SimpleQuote(106.21875),
- new SimpleQuote(100.59375),
- new SimpleQuote(101.6875),
- new SimpleQuote(102.140625)
- };
-
- QuoteHandleVector quoteHandle = new QuoteHandleVector();
- for (int i=0; i bondHelpers =
- new ArrayList();
- for (int i=0; i. The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.CallableFixedRateBond;
-import org.quantlib.Date;
-import org.quantlib.Period;
-import org.quantlib.Settings;
-import org.quantlib.DayCounter;
-import org.quantlib.ActualActual;
-import org.quantlib.Compounding;
-import org.quantlib.Frequency;
-import org.quantlib.FlatForward;
-import org.quantlib.QuoteHandle;
-import org.quantlib.Quote;
-import org.quantlib.SimpleQuote;
-import org.quantlib.YieldTermStructure;
-import org.quantlib.YieldTermStructureHandle;
-import org.quantlib.InterestRate;
-import org.quantlib.Month;
-import org.quantlib.Date;
-import org.quantlib.CallabilitySchedule;
-import org.quantlib.Schedule;
-import org.quantlib.NullCalendar;
-import org.quantlib.UnitedStates;
-import org.quantlib.Calendar;
-import org.quantlib.Callability;
-import org.quantlib.BondPrice;
-import org.quantlib.TimeUnit;
-import org.quantlib.BusinessDayConvention;
-import org.quantlib.DateGeneration;
-import org.quantlib.ShortRateModel;
-import org.quantlib.HullWhite;
-import org.quantlib.PricingEngine;
-import org.quantlib.TreeCallableFixedRateBondEngine;
-import org.quantlib.DoubleVector;
-
-public class CallableBonds {
-
- public static YieldTermStructure flatRate(Date today,
- Quote forward,
- DayCounter dc,
- Compounding compounding,
- Frequency frequency)
- {
- return new FlatForward(today,
- new QuoteHandle(forward),
- dc,
- compounding,
- frequency);
- }
-
- public static void priceCallable(double sigma,
- YieldTermStructureHandle termStructure,
- CallableFixedRateBond callableBond,
- Frequency frequency,
- DayCounter bondDayCounter)
- {
- long maxIterations = 1000;
- double accuracy = 1e-8;
- long gridIntervals = 40;
- double reversionParameter = .03;
-
- ShortRateModel hw0 =
- new HullWhite(termStructure,
- reversionParameter,
- sigma);
-
- PricingEngine engine0 =
- new TreeCallableFixedRateBondEngine(hw0,
- gridIntervals);
-
- callableBond.setPricingEngine(engine0);
-
- System.out.printf("sigma/vol (%%) = %6.2f \n",
- 100.*sigma);
-
- System.out.printf("QuantLib price/yld (%%) %10.2f / %10.2f \n",
- callableBond.cleanPrice(),
- 100.0 * callableBond.yield(bondDayCounter,
- Compounding.Compounded,
- frequency,
- accuracy,
- maxIterations));
-
- System.out.printf("QuantLib OAS from model clean price (bp) %10.2f \n",
- 10000.0 * callableBond.OAS(callableBond.cleanPrice(),
- termStructure,
- bondDayCounter,
- Compounding.Compounded,
- frequency));
-
-
- double cp=callableBond.cleanPriceOAS(10*1e-4,
- termStructure,
- bondDayCounter,
- Compounding.Compounded,
- frequency);
- System.out.printf("QuantLib spreaded clean price with 10bp OAS %f \n",
- cp);
-
- System.out.printf("QuantLib OAS from spreaded clean price (bp) %10.2f \n",
- 10000.0 * callableBond.OAS(cp,
- termStructure,
- bondDayCounter,
- Compounding.Compounded,
- frequency));
-
- System.out.printf("QuantLib effectiveDuration / convexity for 10bp OAS %f / %f \n",
- callableBond.effectiveDuration(10*1e-4,
- termStructure,
- bondDayCounter,
- Compounding.Compounded,
- frequency),
- callableBond.effectiveConvexity(10*1e-4,
- termStructure,
- bondDayCounter,
- Compounding.Compounded,
- frequency));
- }
-
-
- public static void main(String[] args) throws Exception {
- System.out.println("Callable Bonds example:");
-
- Date today = new Date(16, Month.October, 2007);
- Settings.instance().setEvaluationDate(today);
-
- double bbCurveRate = 0.055;
- DayCounter bbDayCounter =
- new ActualActual(ActualActual.Convention.Bond);
-
- InterestRate bbIR =
- new InterestRate(bbCurveRate,
- bbDayCounter,
- Compounding.Compounded,
- Frequency.Semiannual);
-
- YieldTermStructureHandle termStructure =
- new YieldTermStructureHandle(flatRate(today,
- new SimpleQuote(bbIR.rate()),
- bbIR.dayCounter(),
- bbIR.compounding(),
- bbIR.frequency()));
-
-
- // set up the call schedule
- CallabilitySchedule callSchedule =
- new CallabilitySchedule();
- double callPrice = 100.;
- long numberOfCallDates = 24;
- Date callDate =
- new Date(15, Month.September, 2006);
-
- Calendar nullCalendar = new NullCalendar();
-
- for (long i=0; i< numberOfCallDates; ++i) {
-
- BondPrice myPrice=
- new BondPrice(callPrice,
- BondPrice.Type.Clean);
- callSchedule.add(new Callability(myPrice,
- Callability.Type.Call,
- callDate));
- callDate = nullCalendar.advance(callDate, 3, TimeUnit.Months);
- }
-
- // set up the callable bond
- Date dated =
- new Date(16, Month.September, 2004);
- Date issue = dated;
- Date maturity = new Date(15, Month.September, 2012);
- int settlementDays = 3; // Bloomberg OAS1 settle is Oct 19, 2007
- Calendar bondCalendar = new
- UnitedStates(UnitedStates.Market.GovernmentBond);
- double coupon = .0465;
- Frequency frequency = Frequency.Quarterly;
- double redemption = 100.0;
- double faceAmount = 100.0;
-
- /* The 30/360 day counter Bloomberg uses for this bond cannot
- reproduce the US Bond/ISMA (constant) cashflows used in PFC1.
- Therefore use ActAct(Bond)
- */
- DayCounter bondDayCounter =
- new ActualActual(ActualActual.Convention.Bond);
-
- // PFC1 shows no indication dates are being adjusted
- // for weekends/holidays for vanilla bonds
- BusinessDayConvention accrualConvention = BusinessDayConvention.Unadjusted;
- BusinessDayConvention paymentConvention = BusinessDayConvention.Unadjusted;
-
- Schedule sch =
- new Schedule(dated,
- maturity,
- new Period(frequency),
- bondCalendar,
- accrualConvention,
- accrualConvention,
- DateGeneration.Rule.Backward,
- false);
-
- DoubleVector couponsVector = new DoubleVector();
- couponsVector.add(coupon);
-
- CallableFixedRateBond callableBond =
- new CallableFixedRateBond(settlementDays,
- faceAmount,
- sch,
- couponsVector,
- bondDayCounter,
- paymentConvention,
- redemption,
- issue,
- callSchedule);
-
-
- priceCallable(1e-20,
- termStructure,
- callableBond,
- frequency,
- bondDayCounter);
-
- System.out.printf("Bloomberg price/yld (%%) 96.50 / 5.47 \n");
-
- priceCallable(0.01,
- termStructure,
- callableBond,
- frequency,
- bondDayCounter);
-
- System.out.printf("Bloomberg price/yld (%%) 95.68 / 5.66 \n");
-
- priceCallable(0.03,
- termStructure,
- callableBond,
- frequency,
- bondDayCounter);
-
- System.out.printf("Bloomberg price/yld (%%) 92.34 / 6.49 \n");
-
- priceCallable(0.06,
- termStructure,
- callableBond,
- frequency,
- bondDayCounter);
-
- System.out.printf("Bloomberg price/yld (%%) 87.16 / 7.83 \n");
-
- priceCallable(0.12,
- termStructure,
- callableBond,
- frequency,
- bondDayCounter);
-
- System.out.printf("Bloomberg price/yld (%%) 77.31 / 10.65 \n");
-
-
- System.out.println("Done");
- }
-
-}
diff --git a/Java/examples/CallableBondsOAS.java b/Java/examples/CallableBondsOAS.java
deleted file mode 100644
index 71246bd4..00000000
--- a/Java/examples/CallableBondsOAS.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
-
- Copyright (C) 2017 BN Algorithms Ltd
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import java.util.stream.IntStream;
-
-import org.quantlib.Settings;
-
-import org.quantlib.CallableFixedRateBond;
-import org.quantlib.CallabilitySchedule;
-import org.quantlib.BondPrice;
-import org.quantlib.Callability;
-import org.quantlib.TreeCallableFixedRateBondEngine;
-import org.quantlib.HullWhite;
-
-import org.quantlib.YieldTermStructure;
-import org.quantlib.YieldTermStructureHandle;
-import org.quantlib.RelinkableYieldTermStructureHandle;
-
-import org.quantlib.PiecewiseFlatForward;
-import org.quantlib.TimeUnit;
-import org.quantlib.RateHelperVector;
-import org.quantlib.Calendar;
-import org.quantlib.Compounding;
-import org.quantlib.UnitedStates;
-import org.quantlib.NullCalendar;
-import org.quantlib.BusinessDayConvention;
-import org.quantlib.DateGeneration;
-import org.quantlib.Period;
-import org.quantlib.Schedule;
-import org.quantlib.DoubleVector;
-
-import org.quantlib.ZeroCouponBond;
-import org.quantlib.FlatForward;
-import org.quantlib.Actual360;
-import org.quantlib.Thirty360;
-import org.quantlib.ActualActual;
-import org.quantlib.Month;
-import org.quantlib.Frequency;
-import org.quantlib.Date;
-import org.quantlib.DiscountingBondEngine;
-import org.quantlib.BondHelper;
-import org.quantlib.QuoteHandle;
-import org.quantlib.SimpleQuote;
-
-/** Examples focusing on the OAS and related functions of callable
- * bonds.
- */
-public class CallableBondsOAS {
-
- static public final Date today = new Date(28, Month.March, 2017);
-
-
-
- static public YieldTermStructure mkYC()
- {
- Calendar cal = new UnitedStates(UnitedStates.Market.GovernmentBond);
-
- final int np = 12;
- double ycrate[] = { 0.772,
- 0.917,
- 1.011,
- 1.302,
- 1.549,
- 1.822,
- 1.964,
- 2.242,
- 2.418,
- 2.763,
- 3.025,
- 3.025};
- int ycInt[] = { 3, 6, 1, 2, 3, 4, 5, 7, 10, 20, 30, 50 };
- TimeUnit ycUnit[] = { TimeUnit.Months, TimeUnit.Months,
- TimeUnit.Years, TimeUnit.Years, TimeUnit.Years, TimeUnit.Years, TimeUnit.Years,
- TimeUnit.Years, TimeUnit.Years, TimeUnit.Years, TimeUnit.Years, TimeUnit.Years};
-
- RateHelperVector helpers = new RateHelperVector();
- for (int i=0; i { return valuePar(558.8-0.0000001*e, yc); })
- .forEachOrdered( e -> { System.out.print( e +" ");} );
-
- }
-
-
-}
diff --git a/Java/examples/DiscreteHedging.java b/Java/examples/DiscreteHedging.java
deleted file mode 100644
index 8730c331..00000000
--- a/Java/examples/DiscreteHedging.java
+++ /dev/null
@@ -1,382 +0,0 @@
-
-/*
- Copyright (C) 2008 Tito Ingargiola
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.Actual365Fixed;
-import org.quantlib.BlackCalculator;
-import org.quantlib.BlackConstantVol;
-import org.quantlib.BlackScholesMertonProcess;
-import org.quantlib.BlackVolTermStructureHandle;
-import org.quantlib.Calendar;
-import org.quantlib.Date;
-import org.quantlib.DayCounter;
-import org.quantlib.FlatForward;
-import org.quantlib.GaussianPathGenerator;
-import org.quantlib.GaussianRandomSequenceGenerator;
-import org.quantlib.Option;
-import org.quantlib.Path;
-import org.quantlib.PlainVanillaPayoff;
-import org.quantlib.QuoteHandle;
-import org.quantlib.SamplePath;
-import org.quantlib.SimpleQuote;
-import org.quantlib.Statistics;
-import org.quantlib.TARGET;
-import org.quantlib.UniformRandomGenerator;
-import org.quantlib.UniformRandomSequenceGenerator;
-import org.quantlib.YieldTermStructureHandle;
-
-/**
- * DiscreteHedging Test app - java version of QuantLib/Examples/DiscreteHedging
- * to illustrate use of Quantlib's MonteCarlo functionality through supplied
- * SWIG interfaces.
- *
- * You need to run this with a correctly set library path and something like:
- *
- * -Djava.library.path=/usr/local/lib
- *
- * @author Tito Ingargiola
- **/
-public class DiscreteHedging {
-
-
- public static void main(String[] args) throws Exception {
-
- long begin = System.currentTimeMillis();
-
- double maturity = 1.0/12.0; // 1 month
- double strike = 100;
- double underlying = 100;
- double volatility = 0.20; // 20%
- double riskFreeRate = 0.05; // 5%
- ReplicationError rp = new ReplicationError(Option.Type.Call, maturity,
- strike, underlying, volatility, riskFreeRate);
-
- long scenarios = 50000;
- long hedgesNum = 21;
- rp.compute(hedgesNum, scenarios);
-
- hedgesNum = 84;
- rp.compute(hedgesNum, scenarios);
-
- long msecs = (System.currentTimeMillis()-begin);
- System.out.println("\nRun completed in "+msecs+" ms.");
- }
-
- /**
- * The ReplicationError class carries out Monte Carlo simulations to
- * evaluate the outcome (the replication error) of the discrete hedging
- * strategy over different, randomly generated scenarios of future stock
- * price evolution.
- **/
- public static class ReplicationError {
-
- public ReplicationError(Option.Type type, double maturity,
- double strike, double s0, double sigma, double r ) {
-
- type_ = type;
- maturity_ = maturity;
- strike_ = strike;
- s0_ = s0;
- sigma_ = sigma;
- r_ = r;
-
- // value of the option
- double rDiscount = Math.exp(-r_ * maturity_);
- double qDiscount = 1.0;
- double forward = s0_ * qDiscount/rDiscount;
- double stdDev = Math.sqrt(sigma_*sigma_*maturity);
- BlackCalculator black = new BlackCalculator
- (new PlainVanillaPayoff(type,strike),forward,stdDev,rDiscount);
-
- System.out.printf("Option value: %2.5f \n\n",black.value());
-
- // store option's vega, since Derman and Kamal's formula needs it
- vega_ = black.vega(maturity_);
-
- String fmt ="%-8s | %-8s | %-8s | %-8s | %-12s | %-8s | %-8s \n";
- System.out.printf
- (fmt, " ", " ", "P&L", "P&L", "Derman&Kamal", "P&L","P&L" );
- System.out.printf(fmt, " samples", "trades", "mean", "std.dev",
- "formula", "skewness","kurtosis" );
- for (int i = 0; i < 78; i++) System.out.print("-");
- System.out.println("-");
- }
-
- void compute(long nTimeSteps, long nSamples) {
- assert nTimeSteps>0 : "the number of steps must be > 0";
-
- /* Black-Scholes framework: the underlying stock price evolves
- lognormally with a fixed known volatility that stays constant
- throughout time. */
- Calendar calendar = new TARGET();
- Date today = Date.todaysDate();
- DayCounter dayCounter = new Actual365Fixed();
- QuoteHandle stateVariable = new QuoteHandle(new SimpleQuote(s0_));
-
- YieldTermStructureHandle riskFreeRate =
- new YieldTermStructureHandle
- (new FlatForward(today, r_, dayCounter));
- YieldTermStructureHandle dividendYield =
- new YieldTermStructureHandle
- (new FlatForward(today, 0.0, dayCounter));
- BlackVolTermStructureHandle volatility =
- new BlackVolTermStructureHandle(
- new BlackConstantVol(today, calendar, sigma_, dayCounter));
- BlackScholesMertonProcess diffusion =
- new BlackScholesMertonProcess
- (stateVariable,dividendYield, riskFreeRate, volatility);
-
- // Black Scholes equation rules the path generator:
- // at each step the log of the stock
- // will have drift and sigma^2 variance
- boolean brownianBridge = false;
- GaussianRandomSequenceGenerator rsg =
- new GaussianRandomSequenceGenerator
- (new UniformRandomSequenceGenerator
- (nTimeSteps,new UniformRandomGenerator(0)));
- GaussianPathGenerator myPathGenerator =
- new GaussianPathGenerator
- (diffusion,maturity_,nTimeSteps,rsg, brownianBridge);
-
- /* Alternately you can modify the MonteCarloModel to take a
- * GaussianSobolPathGenerator and uncomment these lines and
- * comment those just above
- *
- GaussianLowDiscrepancySequenceGenerator rsg =
- new GaussianLowDiscrepancySequenceGenerator
- (new UniformLowDiscrepancySequenceGenerator
- (nTimeSteps));
- GaussianSobolPathGenerator myPathGenerator =
- new GaussianSobolPathGenerator
- (diffusion,maturity_,nTimeSteps,rsg, brownianBridge);*/
-
- ReplicationPathPricer myPathPricer = new ReplicationPathPricer
- (type_,strike_, r_, maturity_, sigma_);
-
- MonteCarloModel mcSimulation = new MonteCarloModel
- (myPathGenerator, myPathPricer);
-
- mcSimulation.addSamples(nSamples);
-
- // the sampleAccumulator method
- // gives access to all the methods of statisticsAccumulator
- double PLMean = mcSimulation.sampleAccumulator().mean();
- double PLStDev =
- mcSimulation.sampleAccumulator().standardDeviation();
- double PLSkew = mcSimulation.sampleAccumulator().skewness();
- double PLKurt = mcSimulation.sampleAccumulator().kurtosis();
-
- // Derman and Kamal's formula
- double theorStD = Math.sqrt(Math.PI/4/nTimeSteps)*vega_*sigma_;
-
- String fmt =
- "%-8d | %-8d | %-8.3f | %-8.2f | %-12.2f | %-8.2f | %-8.2f \n";
- System.out.printf(fmt, nSamples, nTimeSteps, PLMean, PLStDev,
- theorStD, PLSkew, PLKurt );
- }
-
- double maturity_;
- Option.Type type_;
- double strike_;
- double s0_;
- double sigma_;
- double r_;
- double vega_;
- }
-
- /**
- * We pull the interface for a PathPricer into Java so we can
- * support its implementation in Java while still relying upon QuantLib's
- * powerful RNGs.
- */
- public static interface JPathPricer {
-
- public double price(Path path);
-
- }
-
- // The key for the MonteCarlo simulation is to have a PathPricer that
- // implements a value(const Path& path) method.
- // This method prices the portfolio for each Path of the random variable
- public static class ReplicationPathPricer implements JPathPricer {
-
- public ReplicationPathPricer(Option.Type type, double strike,
- double r, double maturity, double sigma) {
- assert strike > 0 : "Strike must be positive!";
- assert maturity > 0 : "Risk free rate must be positive!";
- assert r >= 0 : "Risk free rate must be positive or Zero!";
- assert sigma >= 0 : "Volatility must be positive or Zero!";
-
- type_ = type;
- strike_ = strike;
- r_ = r;
- maturity_ = maturity;
- sigma_ = sigma;
- }
-
- public double price(Path path) {
-
- long n = path.length() - 1;
- assert n > 0 : "The path can't be empty!";
-
- // discrete hedging interval
- double dt = maturity_ / n;
-
- // For simplicity, we assume the stock pays no dividends.
- double stockDividendYield = 0.0;
-
- // let's start
- double t = 0;
-
- // stock value at t=0
- double stock = path.front();
-
- // money account at t=0
- double money_account = 0.0;
-
- /************************/
- /*** the initial deal ***/
- /************************/
- // option fair price (Black-Scholes) at t=0
- double rDiscount = Math.exp(-r_*maturity_);
- double qDiscount = Math.exp(-stockDividendYield*maturity_);
- double forward = stock*qDiscount/rDiscount;
- double stdDev = Math.sqrt(sigma_*sigma_*maturity_);
- PlainVanillaPayoff payoff = new PlainVanillaPayoff(type_,strike_);
- BlackCalculator black = new BlackCalculator
- (payoff,forward,stdDev,rDiscount);
-
- // sell the option, cash in its premium
- money_account += black.value();
- // compute delta
- double delta = black.delta(stock);
- // delta-hedge the option buying stock
- double stockAmount = delta;
- money_account -= stockAmount*stock;
- /**********************************/
- /*** hedging during option life ***/
- /**********************************/
- for (long step = 0; step < n-1; step++){
-
- // time flows
- t += dt;
-
- // accruing on the money account
- money_account *= Math.exp( r_*dt );
-
- // stock growth:
- stock = path.value(step+1);
-
- // recalculate option value at the current stock value,
- // and the current time to maturity
- rDiscount = Math.exp(-r_*(maturity_-t));
- qDiscount = Math.exp(-stockDividendYield*(maturity_-t));
-
- forward = stock*(qDiscount/rDiscount);
-
- stdDev = Math.sqrt(sigma_*sigma_*(maturity_-t));
- black = new BlackCalculator
- (new PlainVanillaPayoff(type_,strike_),forward,stdDev,rDiscount);
-
- // recalculate delta
- delta = black.delta(stock);
-
- // re-hedging
- money_account -= (delta - stockAmount)*stock;
- stockAmount = delta;
- }
-
- /*************************/
- /*** option expiration ***/
- /*************************/
- // last accrual on my money account
- money_account *= Math.exp( r_*dt );
- // last stock growth
- stock = path.value(n);
-
- // the hedger delivers the option payoff to the option holder
- double optionPayoff =
- (new PlainVanillaPayoff(type_, strike_)).getValue(stock);
- money_account -= optionPayoff;
-
- // and unwinds the hedge selling his stock position
- money_account += stockAmount*stock;
-
- // final Profit&Loss
- return money_account;
- }
-
- double maturity_;
- Option.Type type_;
- double strike_;
- double sigma_;
- double r_;
- }
-
-
- /**
- * We pull the MonteCarloModel into Java so that we can enable the
- * implementation in java of our PathPricer
- */
- public static class MonteCarloModel {
-
- /** convenience ctor **/
- public MonteCarloModel
- (GaussianPathGenerator gpg, JPathPricer pathpricer) {
- this(gpg,pathpricer,false, null);
- }
-
- /** complete ctor **/
- public MonteCarloModel(GaussianPathGenerator gpg,
- JPathPricer pathpricer, boolean antitheticVariate,
- Statistics stats ) {
- assert gpg != null : "PathGenerator must not be null!";
- assert pathpricer != null : "PathPricer must not be null!";
- gpg_ = gpg;
- ppricer_ = pathpricer;
- stats_ = (stats==null) ? new Statistics() : stats;
- av_ = antitheticVariate;
- }
-
- public Statistics sampleAccumulator () { return stats_; }
-
-
- public void addSamples( long samples ) {
- for(long j = 0; j < samples; j++) {
-
- SamplePath path = gpg_.next();
- double price = ppricer_.price(path.value());
- if ( av_ ) {
- path = gpg_.antithetic();
- double price2 = ppricer_.price(path.value());
- stats_.add((price+price2)/2.0, path.weight());
-
- } else {
- stats_.add(price, path.weight());
- }
- }
-
- }
- final boolean av_;
- final GaussianPathGenerator gpg_;
- final JPathPricer ppricer_;
- final Statistics stats_;
- }
-}
-
diff --git a/Java/examples/EquityOptions.java b/Java/examples/EquityOptions.java
deleted file mode 100644
index dcc30a08..00000000
--- a/Java/examples/EquityOptions.java
+++ /dev/null
@@ -1,424 +0,0 @@
-
-/*
- Copyright (C) 2007 Richard Gomes
- Copyright (C) 2007 Tito Ingargiola
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.QuantLib;
-import org.quantlib.Actual365Fixed;
-import org.quantlib.AmericanExercise;
-import org.quantlib.AnalyticEuropeanEngine;
-import org.quantlib.AnalyticHestonEngine;
-import org.quantlib.AnalyticHestonEngine_Integration;
-import org.quantlib.AnalyticPTDHestonEngine;
-import org.quantlib.BaroneAdesiWhaleyApproximationEngine;
-import org.quantlib.BatesEngine;
-import org.quantlib.BatesModel;
-import org.quantlib.BatesProcess;
-import org.quantlib.BermudanExercise;
-import org.quantlib.BinomialCRRVanillaEngine;
-import org.quantlib.BinomialEQPVanillaEngine;
-import org.quantlib.BinomialJ4VanillaEngine;
-import org.quantlib.BinomialJRVanillaEngine;
-import org.quantlib.BinomialLRVanillaEngine;
-import org.quantlib.BinomialTianVanillaEngine;
-import org.quantlib.BinomialTrigeorgisVanillaEngine;
-import org.quantlib.BjerksundStenslandApproximationEngine;
-import org.quantlib.BlackConstantVol;
-import org.quantlib.BlackScholesMertonProcess;
-import org.quantlib.BlackVolTermStructureHandle;
-import org.quantlib.BoundaryConstraint;
-import org.quantlib.Calendar;
-import org.quantlib.ConstantParameter;
-import org.quantlib.COSHestonEngine;
-import org.quantlib.Date;
-import org.quantlib.DateVector;
-import org.quantlib.DayCounter;
-import org.quantlib.EuropeanExercise;
-import org.quantlib.Exercise;
-import org.quantlib.FdBlackScholesVanillaEngine;
-import org.quantlib.HestonModel;
-import org.quantlib.HestonProcess;
-import org.quantlib.FlatForward;
-import org.quantlib.IntegralEngine;
-import org.quantlib.MCLDEuropeanEngine;
-import org.quantlib.MCPREuropeanEngine;
-import org.quantlib.MCPREuropeanHestonEngine;
-import org.quantlib.Month;
-import org.quantlib.Option;
-import org.quantlib.Payoff;
-import org.quantlib.Period;
-import org.quantlib.PiecewiseTimeDependentHestonModel;
-import org.quantlib.PlainVanillaPayoff;
-import org.quantlib.PositiveConstraint;
-import org.quantlib.QuoteHandle;
-import org.quantlib.Settings;
-import org.quantlib.SimpleQuote;
-import org.quantlib.TARGET;
-import org.quantlib.TimeGrid;
-import org.quantlib.TimeUnit;
-import org.quantlib.VanillaOption;
-import org.quantlib.YieldTermStructureHandle;
-
-/**
- * EquityOption Test app - java version of QuantLib/Examples/EquityOption
- * to illustrate use of Quantlib through supplied SWIG interfaces.
- *
- * You need to run this with a correctly set library path and something like:
- *
- * -Djava.library.path=/usr/local/lib
- *
- * @author Richard Gomes
- * @author Tito Ingargiola
- */
-public class EquityOptions {
-
- public static void main(String[] args) throws Exception {
- long beginTime = System.currentTimeMillis();
-
- // our option
- Option.Type type = Option.Type.Put;
- double strike = 40.0;
- double underlying = 36.0;
- double riskFreeRate = 0.06;
- double dividendYield = 0.00;
- double volatility = 0.2;
-
- Date todaysDate = new Date(15, Month.May, 1998);
- Date settlementDate = new Date(17, Month.May, 1998);
- Settings.instance().setEvaluationDate(todaysDate);
-
- Date maturity = new Date(17, Month.May, 1999);
- DayCounter dayCounter = new Actual365Fixed();
- Calendar calendar = new TARGET();
-
- // write column headings
- String fmt = "\n%-35s %-14s %-14s %-14s\n";
- System.out.printf(fmt, "Method", "European", "Bermudan", "American");
- System.out.println("============================================================================");
-
-
- // define European, Bermudan, and American exercises
- DateVector exerciseDates = new DateVector();
- for (int i = 1; i <= 4; i++) {
- Date forward = settlementDate.add(new Period(3*i, TimeUnit.Months));
- exerciseDates.add(forward);
- }
- Exercise europeanExercise = new EuropeanExercise(maturity);
- Exercise bermudanExercise = new BermudanExercise(exerciseDates);
- Exercise americanExercise = new AmericanExercise(settlementDate,
- maturity);
-
-
- // define the underlying asset and the yield/dividend/volatility curves
- QuoteHandle underlyingH = new QuoteHandle(new SimpleQuote(underlying));
- YieldTermStructureHandle flatTermStructure =
- new YieldTermStructureHandle(new FlatForward(
- settlementDate, riskFreeRate, dayCounter));
- YieldTermStructureHandle flatDividendYield =
- new YieldTermStructureHandle(new FlatForward(
- settlementDate, dividendYield, dayCounter));
- BlackVolTermStructureHandle flatVolatility =
- new BlackVolTermStructureHandle(new BlackConstantVol(
- settlementDate, calendar, volatility, dayCounter));
-
- BlackScholesMertonProcess stochasticProcess =
- new BlackScholesMertonProcess(underlyingH,
- flatDividendYield,
- flatTermStructure,
- flatVolatility);
-
- // options
- PlainVanillaPayoff payoff = new PlainVanillaPayoff(type, strike);
-
- VanillaOption europeanOption =
- new VanillaOption(payoff, europeanExercise);
- VanillaOption bermudanOption =
- new VanillaOption(payoff, bermudanExercise);
- VanillaOption americanOption =
- new VanillaOption(payoff, americanExercise);
-
- fmt = "%34s %13.9f %13.9f %13.9f\n";
-
- // Analytic formulas:
-
- // Black-Scholes for European
- String method = "Black-Scholes";
- europeanOption.setPricingEngine(
- new AnalyticEuropeanEngine(stochasticProcess));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
-
- // Heston
- method = "Heston Semi-Analytic";
- HestonProcess hestonProcess =
- new HestonProcess(flatTermStructure,
- flatDividendYield,
- underlyingH,
- volatility*volatility,
- 1.0,
- volatility*volatility,
- 0.0001,
- 0.0);
- HestonModel hestonModel = new HestonModel(hestonProcess);
- europeanOption.setPricingEngine(new AnalyticHestonEngine(hestonModel));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- method = "Heston COS Method";
- europeanOption.setPricingEngine(new COSHestonEngine(hestonModel));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- method = "Heston time dependent parameter";
- europeanOption.setPricingEngine(
- new AnalyticPTDHestonEngine(
- new PiecewiseTimeDependentHestonModel(
- flatTermStructure,
- flatDividendYield,
- underlyingH,
- volatility*volatility,
- new ConstantParameter(volatility*volatility, new PositiveConstraint()),
- new ConstantParameter(1.0, new PositiveConstraint()),
- new ConstantParameter(1e-4, new PositiveConstraint()),
- new ConstantParameter(0.0, new BoundaryConstraint(-1.0, 1.0)),
- new TimeGrid(dayCounter.yearFraction(todaysDate, maturity), 10)
- ),
- AnalyticPTDHestonEngine.ComplexLogFormula.AndersenPiterbarg,
- AnalyticHestonEngine_Integration.gaussLaguerre(32)) );
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- // Bates
- method = "Bates Semi-Analytic";
- BatesProcess batesProcess =
- new BatesProcess(flatTermStructure,
- flatDividendYield,
- underlyingH,
- volatility*volatility,
- 1.0,
- volatility*volatility,
- 0.0001,
- 0.0,
- 1e-14, 1e-14, 1e-14);
- BatesModel batesModel = new BatesModel(batesProcess);
- europeanOption.setPricingEngine(new BatesEngine(batesModel));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- // Barone-Adesi and Whaley approximation for American
- method = "Barone-Adesi/Whaley";
- americanOption.setPricingEngine(
- new BaroneAdesiWhaleyApproximationEngine(stochasticProcess));
- System.out.printf(fmt, new Object[] { method,
- Double.NaN,
- Double.NaN,
- americanOption.NPV() } );
-
- // Bjerksund and Stensland approximation for American
- method = "Bjerksund/Stensland";
- americanOption.setPricingEngine(
- new BjerksundStenslandApproximationEngine(stochasticProcess));
- System.out.printf(fmt, new Object[] { method,
- Double.NaN,
- Double.NaN,
- americanOption.NPV() } );
-
- // Integral
- method = "Integral";
- europeanOption.setPricingEngine(new IntegralEngine(stochasticProcess));
- System.out.printf(fmt, new Object[] { method, europeanOption.NPV(),
- Double.NaN, Double.NaN } );
-
- // Finite differences
- int timeSteps = 801;
- method = "Finite differences";
- europeanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps,
- timeSteps-1));
- bermudanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps,
- timeSteps-1));
- americanOption.setPricingEngine(
- new FdBlackScholesVanillaEngine(stochasticProcess,
- timeSteps,
- timeSteps-1));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() });
-
- // Binomial method
- method = "Binomial Jarrow-Rudd";
- europeanOption.setPricingEngine(new BinomialJRVanillaEngine(
- stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(new BinomialJRVanillaEngine(
- stochasticProcess, timeSteps));
- americanOption.setPricingEngine(new BinomialJRVanillaEngine(
- stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Binomial Cox-Ross-Rubinstein";
- europeanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialCRRVanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Additive equiprobabilities";
- europeanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialEQPVanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Binomial Trigeorgis";
- europeanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Binomial Tian";
- europeanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialTianVanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Binomial Leisen-Reimer";
- europeanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialLRVanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
- method = "Binomial Joshi";
- europeanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- bermudanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- americanOption.setPricingEngine(
- new BinomialJ4VanillaEngine(stochasticProcess, timeSteps));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- bermudanOption.NPV(),
- americanOption.NPV() } );
-
-
- // Monte Carlo Method
- timeSteps = 1;
- int mcSeed = 42;
- int nSamples = 32768; // 2^15
- int maxSamples = 1048576; // 2^20
-
- method = "MC (crude)";
- europeanOption.setPricingEngine(
- new MCPREuropeanEngine(stochasticProcess,
- timeSteps,
- QuantLib.nullInt(),
- false, false,
- nSamples, 0.02, maxSamples, mcSeed));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- method = "MC (Sobol)";
- europeanOption.setPricingEngine(
- new MCLDEuropeanEngine(stochasticProcess,
- timeSteps,
- QuantLib.nullInt(),
- false, false,
- nSamples, 0.02, maxSamples, mcSeed));
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- method = "Heston Monte-Carlo";
- europeanOption.setPricingEngine(
- new MCPREuropeanHestonEngine(hestonProcess, 25, QuantLib.nullInt(), true, nSamples));
-
- System.out.printf(fmt, new Object[] { method,
- europeanOption.NPV(),
- Double.NaN,
- Double.NaN } );
-
- /*
- method = "MC (Longstaff Schwartz)";
- // This is the original C++ code:
- // MakeMCAmericanEngine().withSteps(100)
- // .withAntitheticVariate()
- // .withCalibrationSamples(4096)
- // .withTolerance(0.02)
- // .withSeed(mcSeed);
-
- System.out.printf(fmt, new Object[] { method,
- Double.NaN,
- Double.NaN,
- americanOption.NPV() });
- */
-
- long msecs = (System.currentTimeMillis()-beginTime);
- System.out.println("Run completed in "+msecs+" ms.");
-
- }
-}
-
diff --git a/Java/examples/FRA.java b/Java/examples/FRA.java
deleted file mode 100644
index 82a40152..00000000
--- a/Java/examples/FRA.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package examples;
-
-import org.quantlib.Actual360;
-import org.quantlib.Date;
-import org.quantlib.DayCounter;
-import org.quantlib.FlatForward;
-import org.quantlib.Month;
-import org.quantlib.Settings;
-import org.quantlib.YieldTermStructureHandle;
-import org.quantlib.ForwardRateAgreement;
-import org.quantlib.Position;
-import org.quantlib.IborIndex;
-import org.quantlib.Euribor3M;
-
-public class FRA {
-
-
- public static void main(String[] args) throws Exception {
-
- Date todaysDate = new Date(23, Month.May, 2006);
- Settings.instance().setEvaluationDate(todaysDate);
-
- Date startDate = new Date(23, Month.August, 2006);
- Position.Type type = Position.Type.Long;
- double strike = 0.02;
- double notional = 100.0;
- double riskFreeRate = 0.06;
- DayCounter dayCounter = new Actual360();
-
- // define the underlying asset and the yield/dividend/volatility curves
- YieldTermStructureHandle flatTermStructure =
- new YieldTermStructureHandle(new FlatForward(todaysDate, riskFreeRate, dayCounter));
- IborIndex euribor3m = new Euribor3M(flatTermStructure);
-
- ForwardRateAgreement myFra =
- new ForwardRateAgreement(startDate, type, strike, notional, euribor3m, flatTermStructure);
- System.out.println(myFra.amount());
- System.out.println(myFra.NPV());
- }
-}
-
diff --git a/Java/examples/FunctionDelegates.java b/Java/examples/FunctionDelegates.java
deleted file mode 100644
index a454edbd..00000000
--- a/Java/examples/FunctionDelegates.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package examples;
-
-import org.quantlib.Brent;
-import org.quantlib.Newton;
-import org.quantlib.DoubleVector;
-import org.quantlib.OdeFctDelegate;
-import org.quantlib.GaussKronrodAdaptive;
-import org.quantlib.UnaryFunctionDelegate;
-import org.quantlib.BinaryFunctionDelegate;
-import org.quantlib.RichardsonExtrapolation;
-import org.quantlib.RungeKutta;
-
-public class FunctionDelegates {
-
- public static void main(String[] args) {
- System.out.println("Integration result " +
- new GaussKronrodAdaptive(1e-8).calculate(
- new UnaryFunctionDelegate() {
- public double value(double x) { return Math.sin(x); }
- }, 0.0, Math.PI
- )
- );
-
- System.out.println("Brent Solver result " +
- new Brent().solve(
- new UnaryFunctionDelegate() {
- public double value(double x) { return Math.cos(x)-x; }
- }, 1e-8, 0.5, 0.0, Math.PI
- )
- );
-
- System.out.println("Newton Solver result " +
- new Newton().solve(
- new UnaryFunctionDelegate() {
- public double value(double x) { return x*x-1.0; }
- },
- new UnaryFunctionDelegate() {
- public double value(double x) { return 2*x; }
- },
- 1e-4, 0.25, 0.1
- )
- );
-
- System.out.println("Richardson Extrapolation, known order " +
- new RichardsonExtrapolation(
- new UnaryFunctionDelegate() {
- public double value(double x) { return Math.exp(1 + x); }
- }, 0.1, 1.0).getValue(2.0)
- );
-
- System.out.println("Richardson Extrapolation, unknown order " +
- new RichardsonExtrapolation(
- new UnaryFunctionDelegate() {
- public double value(double x) { return Math.exp(1 + x); }
- }, 0.1).getValue(4.0, 2.0)
- );
-
- System.out.println("One dimensional adaptive Runge-Kutta result " +
- // y'=y and y[0] = 1
- new RungeKutta().getValue(
- new BinaryFunctionDelegate() {
- public double value(double x, double y) { return y; }
- }, 1.0, 0.0, 1.0
- )
- );
-
- DoubleVector startVal = new DoubleVector();
- startVal.add(0.0);
- startVal.add(1.0);
-
- System.out.println("Two dimensional adaptive Runge-Kutta result " +
- // y_0'=y_1 & y_1'=-y_0 and y_0[0]=0 & y_1[0]=1
- new RungeKutta().getValue(
- new OdeFctDelegate() {
- public DoubleVector value(double x, DoubleVector y) {
- DoubleVector retVal = new DoubleVector();
- retVal.add(y.get(1));
- retVal.add(-y.get(0));
- return retVal;
- }
- }, startVal, 0.0, 0.5*Math.PI
- ).get(0)
- );
- }
-}
diff --git a/Java/examples/Time.java b/Java/examples/Time.java
deleted file mode 100644
index 07fd5af4..00000000
--- a/Java/examples/Time.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package examples;
-
-import org.quantlib.Date;
-import org.quantlib.Month;
-import java.time.LocalDate;
-
-public class Time {
-
-
- public static void main(String[] args) throws Exception {
-
- Date qlDate = new Date(18, Month.April, 2023);
- LocalDate localDate = LocalDate.of(2023, 4, 18);
-
- Date qlDateFromLocalDate = Date.of(localDate);
- LocalDate localDateFromQlDate = qlDate.toLocalDate();
-
- System.out.println("qlDate: " + qlDate);
- System.out.println("qlDateFromLocalDate: " + qlDateFromLocalDate);
- System.out.println("localDate: " + localDate);
- System.out.println("localDateFromQlDate: " + localDateFromQlDate);
- }
-}
-
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 8a0efb6e..00000000
--- a/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-
-SUBDIRS = CSharp Java Python R Scala
-
-EXTRA_DIST = \
- ChangeLog.txt \
- LICENSE.TXT \
- News.md \
- README.md \
- autogen.sh
-
-
-dist-hook:
- mkdir -p $(distdir)/SWIG
- cp -p ./SWIG/*.i $(distdir)/SWIG
- cp -p ./binder/requirements.txt $(distdir)/Python/examples/
diff --git a/News.md b/News.md
deleted file mode 100644
index 08d01614..00000000
--- a/News.md
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Main changes for QuantLib-SWIG 1.33
-===================================
-
-More details on the changes are available in ChangeLog.txt and at
-.
-
-- Exported Burley 2020 Sobol generator (@lballabio).
-
-- Allowed different calendars and frequencies for different legs in
- `OISRateHelper`; thanks to Eugene Toder (@eltoder).
-
-- Exported convex-monotone forward-rate curve (@lballabio).
-
-- Exported support for angled contour shift integrals in Heston model;
- thanks to Klaus Spanderen (@klausspanderen).
-
-- Allowed negative payment lag in swap legs; thanks to Fredrik Gerdin
- Börjesson (@gbfredrik).
-
-- Exported `reset` method in calendars; thanks to Fredrik Gerdin
- Börjesson (@gbfredrik).
-
-- Added Python tests for `BondFunctions`; thanks to Francois Botha
- (@igitur).
diff --git a/Python/Makefile.am b/Python/Makefile.am
deleted file mode 100644
index 6de18c74..00000000
--- a/Python/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-
-CLEANFILES = QuantLib/quantlib_wrap.cpp QuantLib/QuantLib.py .build-stamp
-
-BUILT_SOURCES = QuantLib/quantlib_wrap.cpp QuantLib/QuantLib.py
-
-if HAVE_PYTHON
-if BUILD_PYTHON
-
-all-local: .build-stamp
-
-.build-stamp: QuantLib/quantlib_wrap.cpp QuantLib/QuantLib.py setup.py
- CXXFLAGS="$(CXXFLAGS) $(CXXWARNINGFLAGS)" CC="$(CC)" CXX="$(CXX)" $(PYTHON) setup.py build
- touch .build-stamp
-
-check-local: .build-stamp
- $(PYTHON) setup.py test
-
-install-exec-local: .build-stamp
- $(PYTHON) setup.py install
-
-wheel: .build-stamp
- $(PYTHON) setup.py bdist_wheel
-
-clean-local:
- rm -rf build
-
-endif
-endif
-
-QuantLib/quantlib_wrap.cpp QuantLib/QuantLib.py: ../SWIG/*.i
- $(SWIG) -python -c++ -outdir QuantLib \
- -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
-
-dist-hook:
- mkdir -p $(distdir)/examples
- cp ./examples/*.py $(distdir)/examples
- mkdir -p $(distdir)/test
- cp ./test/*.py $(distdir)/test
-
-EXTRA_DIST = README.txt setup.py QuantLib/__init__.py $(BUILT_SOURCES)
-
diff --git a/Python/QuantLib-Python.spec.in b/Python/QuantLib-Python.spec.in
deleted file mode 100644
index 192f7732..00000000
--- a/Python/QuantLib-Python.spec.in
+++ /dev/null
@@ -1,46 +0,0 @@
-Summary: The Python wrapper for the QuantLib library.
-Name: QuantLib-Python
-Version: @PACKAGE_VERSION@
-Epoch: 0
-Release: 0
-License: BSD License
-Group: System Environment/Libraries
-Packager: Liguo Song (Leo)
-Vendor: QuantLib.org
-Source0: http://prdownloads.sourceforge.net/quantlib/QuantLib-Python-%{version}.tar.gz
-URL: https://www.quantlib.org/
-Buildroot: %{_tmppath}/%{name}-%{version}-root
-BuildRequires: QuantLib-devel == %{version}, python >= 2.1
-
-%description
-QuantLib-Python is the Python wrapper for the QuantLib library.
-
-
-%prep
-%setup -q
-
-
-%build
-python setup.py build
-python setup.py test
-
-
-%install
-rm -rf %{buildroot}
-python setup.py install --prefix=%{buildroot}%{_prefix}
-
-%clean
-rm -rf %{buildroot}
-
-%files
-%defattr(-,root,root)
-%{_includedir}/QuantLib-Python
-%{_libdir}/python2.2/site-packages/QuantLib
-
-
-%changelog
-* Wed Nov 19 2003 Liguo Song
-- Update to 0.3.4
-
-* Thu Oct 30 2003 Liguo Song
-- Initial QuantLib-Python package
diff --git a/Python/QuantLib_Risks/CMakeLists.txt b/Python/QuantLib_Risks/CMakeLists.txt
index 0e0f6e39..6eaad302 100644
--- a/Python/QuantLib_Risks/CMakeLists.txt
+++ b/Python/QuantLib_Risks/CMakeLists.txt
@@ -34,7 +34,7 @@ swig_add_library(QuantLib_Risks
SOURCES ${PROJECT_SOURCE_DIR}/SWIG/quantlib.i converters.cpp
)
target_link_libraries(QuantLib_Risks PRIVATE Python3::Module QuantLib::QuantLib pybind11::headers)
-target_compile_features(QuantLib_Risks PRIVATE c_std_17)
+target_compile_features(QuantLib_Risks PRIVATE cxx_std_17)
target_compile_definitions(QuantLib_Risks PRIVATE QL_XAD=1 QLR_VERSION=\"${QLR_VERSION}\" QLR_HEX_VERSION=${QLR_HEX_VERSION})
target_include_directories(QuantLib_Risks PRIVATE .)
set_property(TARGET QuantLib_Risks PROPERTY SUFFIX "${QL_MODULE_SUFFIX}")
diff --git a/Python/QuantLib_Risks/__init__.py b/Python/QuantLib_Risks/__init__.py
index 5215e57b..d1cd69d8 100644
--- a/Python/QuantLib_Risks/__init__.py
+++ b/Python/QuantLib_Risks/__init__.py
@@ -34,7 +34,7 @@
from .QuantLib_Risks import *
if XAD_ENABLED:
- from xad_autodiff.adj_1st import Real, Tape
+ from xad.adj_1st import Real, Tape
from typing import Union, Tuple, List
# as part of the input at the top, we'll have _QuantLib_Risks in scope
diff --git a/Python/README.md b/Python/README.md
index f6b7ed29..0873d159 100644
--- a/Python/README.md
+++ b/Python/README.md
@@ -16,7 +16,7 @@ pip install QuantLib-Risks
```python
import QuantLib_Risks as ql
-from xad_autodiff.adj_1st import Tape
+from xad.adj_1st import Tape
with Tape() as t:
rate = ql.Real(0.2)
diff --git a/Python/examples/multicurve-bootstrapping.py b/Python/examples/multicurve-bootstrapping.py
index 1a2f9353..173feb8b 100644
--- a/Python/examples/multicurve-bootstrapping.py
+++ b/Python/examples/multicurve-bootstrapping.py
@@ -64,7 +64,7 @@
# import QuantLib as ql # enable this for regular QuantLib performance
-from xad_autodiff.adj_1st import Tape
+from xad.adj_1st import Tape
import time
# %% [markdown]
diff --git a/Python/examples/slv.py b/Python/examples/slv.py
index 717f01f2..c3212f9f 100644
--- a/Python/examples/slv.py
+++ b/Python/examples/slv.py
@@ -59,7 +59,7 @@
import QuantLib_Risks as ql
from matplotlib import pyplot as plt
import numpy as np
-from xad_autodiff import math, value
+from xad import math, value
# %matplotlib inline
diff --git a/Python/examples/swap-adjoint.py b/Python/examples/swap-adjoint.py
index 74c1e919..fd23f63a 100644
--- a/Python/examples/swap-adjoint.py
+++ b/Python/examples/swap-adjoint.py
@@ -48,7 +48,7 @@
# %%
import QuantLib_Risks as ql
-from xad_autodiff.adj_1st import Tape
+from xad.adj_1st import Tape
# %% [markdown]
# ### Global data
diff --git a/Python/examples/swing.py b/Python/examples/swing.py
index 837ff21c..80458736 100644
--- a/Python/examples/swing.py
+++ b/Python/examples/swing.py
@@ -46,7 +46,7 @@
# FOR A PARTICULAR PURPOSE. See the license for more details.
import QuantLib_Risks as ql
-from xad_autodiff import math
+from xad import math
todaysDate = ql.Date(30, ql.September, 2018)
ql.Settings.instance().evaluationDate = todaysDate
diff --git a/Python/pyproject.toml.in b/Python/pyproject.toml.in
index 4682d8c9..daf93914 100644
--- a/Python/pyproject.toml.in
+++ b/Python/pyproject.toml.in
@@ -84,7 +84,7 @@ generate-setup-file = false
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
-xad-autodiff = ">=1.5.1"
+xad = ">=1.5.1"
[build-system]
diff --git a/Python/test/test_blackformula.py b/Python/test/test_blackformula.py
index 7c8b0748..c3299367 100644
--- a/Python/test/test_blackformula.py
+++ b/Python/test/test_blackformula.py
@@ -33,7 +33,7 @@
import unittest
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_extrapolation.py b/Python/test/test_extrapolation.py
index c2e06967..341f972c 100644
--- a/Python/test/test_extrapolation.py
+++ b/Python/test/test_extrapolation.py
@@ -34,7 +34,7 @@
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_fdm.py b/Python/test/test_fdm.py
index 597e2c8a..aa3c2ed4 100644
--- a/Python/test/test_fdm.py
+++ b/Python/test/test_fdm.py
@@ -34,7 +34,7 @@
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_integrals.py b/Python/test/test_integrals.py
index 2d3e38b7..911716bf 100644
--- a/Python/test/test_integrals.py
+++ b/Python/test/test_integrals.py
@@ -33,7 +33,7 @@
import QuantLib_Risks as ql
import unittest
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_ode.py b/Python/test/test_ode.py
index e6a503cd..3428ca6b 100644
--- a/Python/test/test_ode.py
+++ b/Python/test/test_ode.py
@@ -34,7 +34,7 @@
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_risks.py b/Python/test/test_risks.py
index 25d23643..489525e3 100644
--- a/Python/test/test_risks.py
+++ b/Python/test/test_risks.py
@@ -34,7 +34,7 @@
import unittest
import QuantLib_Risks as ql
-from xad_autodiff.adj_1st import Tape
+from xad.adj_1st import Tape
class SwapWithSensiTest(unittest.TestCase):
def setUp(self):
diff --git a/Python/test/test_sabr.py b/Python/test/test_sabr.py
index d60c47e5..e6d068a4 100644
--- a/Python/test/test_sabr.py
+++ b/Python/test/test_sabr.py
@@ -34,7 +34,7 @@
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_termstructures.py b/Python/test/test_termstructures.py
index e8827a3c..0b8cd6c9 100644
--- a/Python/test/test_termstructures.py
+++ b/Python/test/test_termstructures.py
@@ -35,7 +35,7 @@
import QuantLib_Risks as ql
import unittest
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/Python/test/test_volatilities.py b/Python/test/test_volatilities.py
index bd768229..48b72744 100644
--- a/Python/test/test_volatilities.py
+++ b/Python/test/test_volatilities.py
@@ -34,7 +34,7 @@
import unittest
import QuantLib_Risks as ql
if ql.XAD_ENABLED:
- from xad_autodiff import math
+ from xad import math
else:
import math
diff --git a/R/.Rinstignore b/R/.Rinstignore
deleted file mode 100644
index bc8f4891..00000000
--- a/R/.Rinstignore
+++ /dev/null
@@ -1,5 +0,0 @@
-Makefile
-Makefile.am
-Makefile.in
-makeRData.R
-README.txt
diff --git a/R/DESCRIPTION b/R/DESCRIPTION
deleted file mode 100644
index c2b5bd18..00000000
--- a/R/DESCRIPTION
+++ /dev/null
@@ -1,11 +0,0 @@
-Package: QuantLib
-Title: QuantLib bindings for R
-Version: 1.33
-Date: $Date$
-Maintainer: Dirk Eddelbuettel
-Author: The QuantLib Group
-Description: This package provides the SWIG-generated QuantLib bindings for R
-Depends: methods
-SystemRequirements: QuantLib library, Boost library
-License: QuantLib License
-URL: https://www.quantlib.org
diff --git a/R/DESCRIPTION.in b/R/DESCRIPTION.in
deleted file mode 100644
index 40996785..00000000
--- a/R/DESCRIPTION.in
+++ /dev/null
@@ -1,11 +0,0 @@
-Package: QuantLib
-Title: QuantLib bindings for R
-Version: @PACKAGE_VERSION_FOR_R@
-Date: $Date$
-Maintainer: Dirk Eddelbuettel
-Author: The QuantLib Group
-Description: This package provides the SWIG-generated QuantLib bindings for R
-Depends: methods
-SystemRequirements: QuantLib library, Boost library
-License: QuantLib License
-URL: https://www.quantlib.org
diff --git a/R/Makefile.am b/R/Makefile.am
deleted file mode 100644
index eae6c20c..00000000
--- a/R/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-QUANTLIB_R_ROOT = QuantLib
-
-BUILT_SOURCES = src/$(QUANTLIB_R_ROOT).cpp R/$(QUANTLIB_R_ROOT).R
-
-CLEANFILES = $(BUILT_SOURCES) .build-stamp
-
-QUANTLIB_CONFIG=quantlib-config
-
-if HAVE_R
-if BUILD_R
-
-all-local: .build-stamp
-
-.build-stamp: $(BUILT_SOURCES)
- ## R is better at checking from above than within
- cd .. && R CMD check R && cd -
- touch .build-stamp
-
-check-local: .build-stamp
-
-install-exec-local: .build-stamp
- R CMD INSTALL .
-
-endif
-endif
-
-$(BUILT_SOURCES): ../SWIG/*.i
- $(SWIG) -r -c++ -o src/$(QUANTLIB_R_ROOT).cpp ../SWIG/quantlib.i
- mv src/$(QUANTLIB_R_ROOT).R R/
-
-dist-hook:
- mkdir -p $(distdir)/demo
- cp ./demo/00Index $(distdir)/demo
- cp ./demo/*.R $(distdir)/demo
-
-clean-local:
- rm -rf $(BUILT_SOURCES) ../R.Rcheck \
- src/symbols.rds src/$(QUANTLIB_R_ROOT).o src/$(QUANTLIB_R_ROOT).so
-
-EXTRA_DIST = DESCRIPTION NAMESPACE README.txt cleanup \
- $(BUILT_SOURCES) \
- R/README src/Makevars
-
diff --git a/R/NAMESPACE b/R/NAMESPACE
deleted file mode 100644
index 21be0959..00000000
--- a/R/NAMESPACE
+++ /dev/null
@@ -1,6 +0,0 @@
-
-## This NAMESPACE file declares which symbols are being exported,
-## and which dynamic library needs to be loaded.
-
-useDynLib(QuantLib)
-exportPattern("^[[:alpha:]]+")
diff --git a/R/R/README b/R/R/README
deleted file mode 100644
index 2f4cd73d..00000000
--- a/R/R/README
+++ /dev/null
@@ -1,2 +0,0 @@
-The SWIG build process creates a file QuantLib.R which will be moved into
-this directory when the package is prepared by the 'make' step.
diff --git a/R/README.txt b/R/README.txt
deleted file mode 100644
index 16cea4bd..00000000
--- a/R/README.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-
-Updated July 2013
-
-The new build process creates sources for a standard R packages which can
-be installed from this directory via
-
- R CMD INSTALL .
-
-Dirk Eddelbuettel
-edd@debian.org
-
-========================================================================
-This is the R interface to QuantLib. The needed C++ bindings are created
-by means of SWIG (Simplified Wrapper and Interface Generator) available
-from . SWIG version 1.3.32 is needed.
-
-SWIG 1.3.31 generates a .R called QuantLib_wrap.R instead of
-QuantLib.R. The Makefile.am and makeRData.R has commented sections
-which can be used with SWIG 1.3.31
-
-The command
-
- make
-
-generates the R library QuantLib.so and the wrapper script
-QuantLib_wrap.R and a compiled wrapper QuantLib.RData.
-
-Once you've compiled this you can load with
-
- dyn.load('QuantLib.so')
- load('QuantLib.RData')
- cacheMetaData(1)
-
-The last line is to work around a bug that causes S4 methods not to
-get loaded correctly.
-
-You can also load the uncompiled wrapper file
-
- dyn.load('QuantLib_wrap.so')
- source('QuantLib.R')
-
-Please contact
-
-Joseph Wang - joequant@gmail.org
-
-
-if you have any comments or additions.
-
diff --git a/R/cleanup b/R/cleanup
deleted file mode 100755
index 5d833588..00000000
--- a/R/cleanup
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-rm -f src/*.o src/*.so src/*~
diff --git a/R/demo/00Index b/R/demo/00Index
deleted file mode 100644
index 5c1a77a6..00000000
--- a/R/demo/00Index
+++ /dev/null
@@ -1,8 +0,0 @@
-european-option European Option
-fd-option Finite-Differences Option
-graph Graph demo
-scatter Scatter plot
-wireframe Wireframe
-bonds Zero Coupon, Fixed Rate and Floating Rate Bonds
-bates_vol_surface Bates Stochastic Volatility
-curves Sanity check for exported curves
diff --git a/R/demo/american-option.R b/R/demo/american-option.R
deleted file mode 100644
index 4bfafb92..00000000
--- a/R/demo/american-option.R
+++ /dev/null
@@ -1,81 +0,0 @@
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-settlementDate <- Date(15, "May", 1998)
-settlementDate <- Calendar_adjust(calendar, settlementDate)
-
-fixingDays <- 3
-settlementDays <- 3
-todaysDate <- Calendar_advance(calendar, settlementDate, -fixingDays, "Days")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-cat('Today : ', todaysDate$`__str__`(), "\n")
-cat('Settlement Date: ', settlementDate$`__str__`(), "\n")
-
-
-## option
-exercise = AmericanExercise(todaysDate, Date(17, "May", 1999))
-payoff = PlainVanillaPayoff("Put", 40.0)
-option = VanillaOption(payoff, exercise)
-
-
-# ### Market data
-
-# %%
-underlying = SimpleQuote(36.0)
-dividendYield = FlatForward(todaysDate, 0.00, Actual365Fixed())
-volatility = BlackConstantVol(todaysDate, calendar, 0.20, Actual365Fixed())
-riskFreeRate = FlatForward(todaysDate, 0.06, Actual365Fixed())
-
-# %%
-process = BlackScholesMertonProcess(
- QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility)
-)
-
-# ### Pricing
-# We'll collect tuples of method name, option value, and estimated error from the analytic formula.
-
-# %%
-results = NULL
-
-# #### Analytic approximations
-
-option$setPricingEngine(BaroneAdesiWhaleyApproximationEngine(process))
-results = rbind(results, data.frame("method"="Barone-Adesi-Whaley", "NPV"=option$NPV()))
-
-option$setPricingEngine(BjerksundStenslandApproximationEngine(process))
-results = rbind(results, data.frame("method"="Bjerksund-Stensland", "NPV"=option$NPV()))
-
-
-# #### Finite-difference method
-
-timeSteps = 801
-gridPoints = 800
-
-option$setPricingEngine(FdBlackScholesVanillaEngine(process, timeSteps, gridPoints))
-results = rbind(results, data.frame("method"="finite differences", "NPV"=option$NPV()))
-
-
-# #### Binomial method
-
-timeSteps = 801
-
-# %%
-listEngineFuncsNames = lsf.str("package:QuantLib")
-listEngineFuncsNames = listEngineFuncsNames[grepl(pattern = "^Binomial", x = listEngineFuncsNames)]
-listEngineFuncsNames = listEngineFuncsNames[grepl(pattern = "VanillaEngine$", x = listEngineFuncsNames)]
-
-for (engineFuncName in listEngineFuncsNames) {
- eval(parse(text=paste0("option$setPricingEngine(", engineFuncName, "(process, timeSteps))")))
- results = rbind(results, data.frame("method"=engineFuncName, "NPV"=option$NPV()))
-}
-
-
-# ### Results
-print(results)
diff --git a/R/demo/basket-option.R b/R/demo/basket-option.R
deleted file mode 100644
index 9cd36720..00000000
--- a/R/demo/basket-option.R
+++ /dev/null
@@ -1,104 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- Date(15, "May", 1998)
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays <- 3
-settlementDate <- Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', todaysDate$`__str__`(), "\n")
-cat('Settlement Date: ', settlementDate$`__str__`(), "\n")
-
-riskFreeRate = FlatForward(settlementDate, 0.05, Actual365Fixed())
-
-
-# ### Option parameters
-exerciseDate = Date(17, "May", 1999)
-exercise = EuropeanExercise(exerciseDate)
-payoff = PlainVanillaPayoff("Call", 8.0)
-
-
-# ### Market data
-underlying1 = SimpleQuote(7.0)
-volatility1 = BlackConstantVol(todaysDate, calendar, 0.10, Actual365Fixed())
-dividendYield1 = FlatForward(settlementDate, 0.05, Actual365Fixed())
-underlying2 = SimpleQuote(7.0)
-volatility2 = BlackConstantVol(todaysDate, calendar, 0.10, Actual365Fixed())
-dividendYield2 = FlatForward(settlementDate, 0.05, Actual365Fixed())
-
-
-process1 = BlackScholesMertonProcess(
- QuoteHandle(underlying1),
- YieldTermStructureHandle(dividendYield1),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility1)
-)
-
-process2 = BlackScholesMertonProcess(
- QuoteHandle(underlying2),
- YieldTermStructureHandle(dividendYield2),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility2)
-)
-
-corrMatrix = Matrix(2, 2)
-invisible(Matrix_setitem(corrMatrix, 0, 0, 1.0))
-invisible(Matrix_setitem(corrMatrix, 1, 1, 1.0))
-invisible(Matrix_setitem(corrMatrix, 1, 0, 0.5))
-invisible(Matrix_setitem(corrMatrix, 0, 1, 0.5))
-cat(corrMatrix$`__str__`())
-
-procVector = StochasticProcess1DVector(2)
-invisible(StochasticProcess1DVector___setitem__(self = procVector, i = 0, x = process1))
-invisible(StochasticProcess1DVector___setitem__(self = procVector, i = 1, x = process2))
-
-process = StochasticProcessArray(array = procVector, correlation = corrMatrix)
-
-# ### Pricing - European
-
-basketoption = BasketOption(MaxBasketPayoff(payoff), exercise)
-basketoption$setPricingEngine(
- MCPREuropeanBasketEngine(process=process, timeSteps=NA, timeStepsPerYear=1, brownianBridge=F, antitheticVariate=F, requiredSamples=NA, requiredTolerance=0.02, maxSamples=10000, seed=42)
-)
-print(basketoption$NPV())
-
-basketoption = BasketOption(MinBasketPayoff(payoff), exercise)
-basketoption$setPricingEngine(
- MCPREuropeanBasketEngine(process=process, timeSteps=NA, timeStepsPerYear=1, brownianBridge=F, antitheticVariate=F, requiredSamples=NA, requiredTolerance=0.02, maxSamples=10000, seed=42)
-)
-print(basketoption$NPV())
-
-basketoption = BasketOption(AverageBasketPayoff(payoff, 2), exercise)
-basketoption$setPricingEngine(
- MCPREuropeanBasketEngine(process=process, timeSteps=NA, timeStepsPerYear=1, brownianBridge=F, antitheticVariate=F, requiredSamples=NA, requiredTolerance=0.02, maxSamples=10000, seed=42)
-)
-print(basketoption$NPV())
-
-
-# ### Pricing - American
-
-americanExercise = AmericanExercise(settlementDate, exerciseDate)
-americanbasketoption = BasketOption(MaxBasketPayoff(payoff), americanExercise)
-americanbasketoption$setPricingEngine(
- MCPRAmericanBasketEngine(
- process=process,
- timeSteps=10,
- timeStepsPerYear=NA,
- brownianBridge=F,
- antitheticVariate=F,
- requiredSamples=50000,
- requiredTolerance=0.02,
- maxSamples=100000,
- seed=42,
- nCalibrationSamples=5000,
- polynomOrder=5,
- polynomType=LsmBasisSystem_Hermite_get()
- )
-)
-print(americanbasketoption$NPV())
diff --git a/R/demo/bates_vol_surface.R b/R/demo/bates_vol_surface.R
deleted file mode 100644
index aa5d5662..00000000
--- a/R/demo/bates_vol_surface.R
+++ /dev/null
@@ -1,50 +0,0 @@
-
-library(QuantLib)
-library(lattice)
-
-todaysDate <- Date(18, "May", 2013)
-Settings_instance()$setEvaluationDate(d=todaysDate)
-settlementDate <- Date(18, "May", 2013)
-
-riskFreeRate <- YieldTermStructureHandle(FlatForward(settlementDate, 0.01, Actual365Fixed()))
-
-dividendYield <- YieldTermStructureHandle(FlatForward(settlementDate, 0.04, Actual365Fixed()))
-
-underlying <- QuoteHandle(SimpleQuote(100))
-
-bsProcess <- BlackScholesMertonProcess(underlying, dividendYield, riskFreeRate,
- BlackVolTermStructureHandle(
- BlackConstantVol(todaysDate, TARGET(),
- QuoteHandle(SimpleQuote(0.25)),
- Actual365Fixed())))
-
-strikes <- seq(20, 200, length=30)
-maturities <- seq(0.25, 2, length=30)
-g <- expand.grid(strikes=strikes, maturities=maturities)
-
-batesEngine <- BatesEngine(BatesModel(BatesProcess(
- riskFreeRate, dividendYield, underlying,
- 0.1, 1.5, 0.25, 0.75, -0.75, 0.75, -0.05, 0.3)), 128)
-
-impliedVol <- function(strike, maturity) {
- exercise <- EuropeanExercise(Date(18, "May", 2013) +
- Period(maturity*365, "Days"))
- payoff <- PlainVanillaPayoff("Call", strike)
- option <- VanillaOption(payoff, exercise)
- option$setPricingEngine(s_arg2=batesEngine)
- VanillaOption_impliedVolatility(option,
- targetValue=option$NPV(),
- process=bsProcess,
- accuracy=1e-16,
- maxEvaluations=100,
- minVol=0.1,
- maxVol=5.1)
-}
-
-g$vol <- mapply(impliedVol, g$strikes, g$maturities)
-
-newcols <- colorRampPalette(c("grey90", "grey10"))
-print(wireframe(vol ~ strikes*maturities, g,
- xlab="Strike",ylab="Maturitiy",zlab="Vol",
- drape=TRUE,col.regions=rainbow(100,end=0.99,alpha=0.9),
- screen = list(z = -25, x = -65),scale=list(arrows=FALSE)))
diff --git a/R/demo/bonds.R b/R/demo/bonds.R
deleted file mode 100644
index 0b889bfd..00000000
--- a/R/demo/bonds.R
+++ /dev/null
@@ -1,279 +0,0 @@
-## bonds.R -- following what bonds.py does for the QuantLib bindings for Python
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-settlementDate <- Date(18, "September", 2008)
-settlementDate <- Calendar_adjust(calendar, settlementDate)
-
-fixingDays <- 3
-settlementDays <- 3
-todaysDate <- Calendar_advance(calendar, settlementDate, -fixingDays, "Days")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-cat('Today : ', todaysDate$`__str__`(), "\n")
-cat('Settlement Date: ', settlementDate$`__str__`(), "\n")
-
-## market quotes
-## constructing bond yield curve
-zcQuotes <- list(rates=c(0.0096, 0.0145, 0.0194),
- tenor=c(Period(3, "Months"),
- Period(6, "Months"),
- Period(1, "Years")))
-
-zcBondsDayCounter <- Actual365Fixed()
-
-bondInstruments <- RateHelperVector()
-
-for (i in 1:3) {
- r <- zcQuotes[["rates"]][i]
- tenor <- zcQuotes[["tenor"]][[i]]
- drh <- DepositRateHelper(QuoteHandle(SimpleQuote(r)),
- tenor,
- fixingDays,
- calendar,
- "ModifiedFollowing",
- TRUE,
- zcBondsDayCounter)
- RateHelperVector_push_back(bondInstruments, drh)
-}
-
-## setup bonds
-redemption <- 100.0
-numberOfBonds <- 5
-
-bondQuotes <- list(list(Date(15,"March",2005),
- Date(31,"August",2010),
- 0.02375, 100.390625),
- list(Date(15,"June",2005),
- Date(31,"August",2011),
- 0.04625, 106.21875),
- list(Date(30,"June",2006),
- Date(31,"August",2013),
- 0.03125, 100.59375),
- list(Date(15,"November",2002),
- Date(15,"August",2018),
- 0.04000, 101.6875),
- list(Date(15,"May",1987),
- Date (15,"May",2038),
- 0.04500, 102.140625)
- )
-
-# Definition of the rate helpers
-for (i in 1:5) {
- issueDate <- bondQuotes[[i]][[1]]
- maturity <- bondQuotes[[i]][[2]]
- couponRate <- bondQuotes[[i]][[3]]
- marketQuote <- bondQuotes[[i]][[4]]
- schedule <- Schedule(issueDate, maturity, Period("Semiannual"),
- UnitedStates("GovernmentBond"),
- "Unadjusted", "Unadjusted",
- copyToR(DateGeneration(), "Backward"),
- FALSE)
-
- bh <- FixedRateBondHelper(QuoteHandle(SimpleQuote(marketQuote)),
- settlementDays,
- 100.0,
- schedule,
- couponRate,
- ActualActual("Bond"),
- "Unadjusted",
- redemption,
- issueDate)
- RateHelperVector_push_back(bondInstruments, bh)
-}
-termStructureDayCounter <- ActualActual("ISDA")
-
-# not needed as defined in the interface file: tolerance = 1.0e-15
-
-bondDiscountingTermStructure <- PiecewiseFlatForward(settlementDate,
- bondInstruments,
- termStructureDayCounter)
-
-
-# Building of the Libor forecasting curve
-# deposits
-dQuotes <- list(list(0.043375, Period(1,"Weeks")),
- list(0.031875, Period(1,"Months")),
- list(0.0320375, Period(3,"Months")),
- list(0.03385, Period(6,"Months")),
- list(0.0338125, Period(9,"Months")),
- list(0.0335125, Period(1,"Years")))
-sQuotes <- list(list(0.0295, Period(2,"Years")),
- list(0.0323, Period(3,"Years")),
- list(0.0359, Period(5,"Years")),
- list(0.0412, Period(10,"Years")),
- list(0.0433, Period(15,"Years")))
-
-## deposits
-depositDayCounter <- Actual360()
-depoSwapInstruments <- RateHelperVector()
-
-for (i in 1:length(dQuotes)) {
- rate <- dQuotes[[i]][[1]]
- tenor <- dQuotes[[i]][[2]]
- drh <- DepositRateHelper(QuoteHandle(SimpleQuote(rate)),
- tenor, fixingDays,
- calendar, "ModifiedFollowing",
- TRUE, depositDayCounter)
- RateHelperVector_push_back(depoSwapInstruments, drh)
-}
-
-
-## swaps
-swFixedLegFrequency <- "Annual"
-swFixedLegConvention <- "Unadjusted"
-swFixedLegDayCounter <- Thirty360("European")
-swFloatingLegIndex <- Euribor6M()
-forwardStart <- Period(1,"Days")
-for (i in 1:length(sQuotes)) {
- rate <- sQuotes[[i]][[1]]
- tenor <- sQuotes[[i]][[2]]
- srh <- SwapRateHelper(QuoteHandle(SimpleQuote(rate)), tenor,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, QuoteHandle(),forwardStart)
- RateHelperVector_push_back(depoSwapInstruments, srh)
-}
-
-depoSwapTermStructure <- PiecewiseFlatForward(settlementDate, depoSwapInstruments,
- termStructureDayCounter)
-
-## Term structures that will be used for pricing:
-## the one used for discounting cash flows
-
-discountingTermStructure <- RelinkableYieldTermStructureHandle()
-
-## the one used for forward rate forecasting
-forecastingTermStructure <- RelinkableYieldTermStructureHandle()
-
-########################################
-## BONDS TO BE PRICED #
-########################################
-
-## common data
-
-faceAmount <- 100
-
-## pricing engine
-bondEngine <- DiscountingBondEngine(discountingTermStructure)
-
-## zero coupon bond
-zeroCouponBond <- ZeroCouponBond(settlementDays,
- UnitedStates("GovernmentBond"),
- faceAmount,
- Date(15,"August",2013),
- "Following",
- 116.92,
- Date(15,"August",2003))
-
-invisible(Instrument_setPricingEngine(zeroCouponBond, bondEngine))
-
-## fixed 4.5% US Treasury note
-
-fixedBondSchedule <- Schedule(Date(15, "May", 2007),
- Date(15, "May",2017), Period("Semiannual"),
- UnitedStates("GovernmentBond"),
- "Unadjusted", "Unadjusted",
- copyToR(DateGeneration(), "Backward"), FALSE)
-
-fixedRateBond <- FixedRateBond(settlementDays,
- faceAmount,
- fixedBondSchedule,
- 0.045,
- ActualActual("Bond"),
- "ModifiedFollowing",
- 100.0, Date(15, "May", 2007))
-invisible(Instrument_setPricingEngine(fixedRateBond, bondEngine))
-
-## Floating rate bond (3M USD Libor + 0.1%)
-## Should and will be priced on another curve later...
-
-liborTermStructure <- RelinkableYieldTermStructureHandle()
-
-libor3m <- USDLibor(Period(3,"Months"),liborTermStructure)
-invisible(Index_addFixing(libor3m, Date(17, "July", 2008), 0.0278625))
-
-floatingBondSchedule <- Schedule(Date(21, "October", 2005),
- Date(21, "October", 2010), Period("Quarterly"),
- UnitedStates("NYSE"),
- "Unadjusted", "Unadjusted",
- copyToR(DateGeneration(), "Backward"), TRUE)
-
-floatingRateBond <- FloatingRateBond(settlementDays,
- faceAmount,
- floatingBondSchedule,
- libor3m,
- Actual360(),
- "ModifiedFollowing",
- 2,
- 1.0, # Gearings
- 0.001, # Spreads
- numeric(0), #[], # Caps
- numeric(0), #[], # Floors
- TRUE, # Fixing in arrears
- 100.0,
- Date(21, "October", 2005))
-
-invisible(Instrument_setPricingEngine(floatingRateBond, bondEngine))
-
-## coupon pricers
-
-pricer <- BlackIborCouponPricer()
-
-## optionlet volatilities
-volatility <- 0.0
-vol <- ConstantOptionletVolatility(settlementDays,
- calendar,
- "ModifiedFollowing",
- volatility,
- Actual365Fixed())
-
-invisible(IborCouponPricer_setCapletVolatility(pricer, OptionletVolatilityStructureHandle(vol)))
-invisible(setCouponPricer(Bond_cashflows(floatingRateBond), pricer))
-
-
-## Yield curve bootstrapping
-invisible(RelinkableYieldTermStructureHandle_linkTo(forecastingTermStructure, depoSwapTermStructure))
-invisible(RelinkableYieldTermStructureHandle_linkTo(discountingTermStructure, bondDiscountingTermStructure))
-
-## We are using the depo & swap curve to estimate the future Libor rates
-invisible(RelinkableYieldTermStructureHandle_linkTo(liborTermStructure, depoSwapTermStructure))
-
-##
-df <- data.frame(zeroCoupon=c(Instrument_NPV(zeroCouponBond),
- Bond_cleanPrice(zeroCouponBond),
- Bond_dirtyPrice(zeroCouponBond),
- Bond_accruedAmount(zeroCouponBond),
- NA,
- NA,
- 100*Bond_yield(zeroCouponBond, Actual360(), "Compounded", "Annual")),
- fixedRate=c(Instrument_NPV(fixedRateBond),
- Bond_cleanPrice(fixedRateBond),
- Bond_dirtyPrice(fixedRateBond),
- Bond_accruedAmount(fixedRateBond),
- 100*Bond_previousCouponRate(fixedRateBond),
- 100*Bond_nextCouponRate(fixedRateBond),
- 100*Bond_yield(fixedRateBond, Actual360(), "Compounded", "Annual")),
- floatingRate=c(Instrument_NPV(floatingRateBond),
- Bond_cleanPrice(floatingRateBond),
- Bond_dirtyPrice(floatingRateBond),
- Bond_accruedAmount(floatingRateBond),
- 100*Bond_previousCouponRate(floatingRateBond),
- 100*Bond_nextCouponRate(floatingRateBond),
- 100*Bond_yield(floatingRateBond, Actual360(), "Compounded", "Annual")),
- row.names=c("NPV", "Clean Price", "Dirty Price",
- "Accrued Amount", "Previous Coupon", "Next Coupon", "Yield"))
-cat("\nResults:\n")
-print(df, digits=5)
-
-# Other computations
-
-cat("\nSample indirect computations (for the floating rate bond):\n")
-yld <- Bond_yield(floatingRateBond, Actual360(), "Compounded", "Annual")
-clnPrc <- Bond_cleanPrice(floatingRateBond, yld, Actual360(), "Compounded", "Annual", settlementDate)
-cat("Yield to Clean Price: ", clnPrc, "\n")
-yld <- Bond_yield(floatingRateBond, clnPrc, Actual360(), "Compounded", "Annual",settlementDate)
-cat("Clean Price to Yield: ", yld, "\n")
diff --git a/R/demo/cashflows.R b/R/demo/cashflows.R
deleted file mode 100644
index f1017f1e..00000000
--- a/R/demo/cashflows.R
+++ /dev/null
@@ -1,144 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- Date(19, "October", 2020)
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays <- 3
-settlementDate <- Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', todaysDate$`__str__`(), "\n")
-cat('Settlement Date: ', settlementDate$`__str__`(), "\n")
-
-# ### Term structure construction
-
-# %%
-dates = DateVector()
-DateVector_append(dates, DateParser_parseISO("2020-10-19"))
-DateVector_append(dates, DateParser_parseISO("2020-11-19"))
-
-DateVector_append(dates, DateParser_parseISO("2021-01-19"))
-DateVector_append(dates, DateParser_parseISO("2021-04-19"))
-DateVector_append(dates, DateParser_parseISO("2021-10-19"))
-
-DateVector_append(dates, DateParser_parseISO("2022-04-19"))
-DateVector_append(dates, DateParser_parseISO("2022-10-19"))
-
-DateVector_append(dates, DateParser_parseISO("2023-10-19"))
-DateVector_append(dates, DateParser_parseISO("2025-10-19"))
-DateVector_append(dates, DateParser_parseISO("2030-10-19"))
-DateVector_append(dates, DateParser_parseISO("2035-10-19"))
-DateVector_append(dates, DateParser_parseISO("2040-10-19"))
-
-DateVector_size(dates)
-
-rates = c(
- -0.004,
- -0.002,
- 0.001,
- 0.005,
- 0.009,
- 0.010,
- 0.010,
- 0.012,
- 0.017,
- 0.019,
- 0.028,
- 0.032
-)
-
-length(rates)
-
-forecast_curve = ZeroCurve(dates, rates, Actual365Fixed())
-forecast_handle = YieldTermStructureHandle(forecast_curve)
-
-# ### Swap construction
-#
-# We'll use an overnight swap as an example.
-# We're keeping the initialization simple,
-# but the analysis work in the same way for more complex ones,
-# as well as for other kinds of swaps and bonds (once we extract the cashflows from them using the proper methods).
-
-# %%
-swapBuilder = MakeOIS(swapTenor=Period(5, "Years"),
- overnightIndex=Eonia(forecast_handle),
- fixedRate=0.002)
-
-swap = MakeOIS_makeOIS(swapBuilder)
-
-# ### Cash-flow analysis
-#
-# The fixed-rate coupons can be extracted from the swap using the `fixedLeg` method.
-#
-
-fixed_leg = OvernightIndexedSwap_fixedLeg(swap)
-CashFlows_maturityDate(fixed_leg)
-
-df = NULL
-for (i in seq(1, fixed_leg$size())) {
- cfl = fixed_leg[i][[1]]
- df = rbind(df, data.frame(date=Date_ISO(CashFlow_date(cfl)), amount=CashFlow_amount(cfl)))
-}
-print(df)
-
-
-#
-# If we want to extract more information, we need to upcast the coupons to a more specific class.
-# This can be done by using the `as_coupon` or the `as_fixed_rate_coupon` method.
-#
-
-df = NULL
-for (i in seq(1, fixed_leg$size())) {
- cfl = fixed_leg[i][[1]]
- cflCoupon = as_coupon(cfl)
- cflCouponFix = as_fixed_rate_coupon(cfl)
- cflCouponFixIr = FixedRateCoupon_interestRate(cflCouponFix)
-
- df = rbind(df, data.frame(date=Date_ISO(CashFlow_date(cfl)), amount=CashFlow_amount(cfl),
- accrualStartDate=Date_ISO(Coupon_accrualStartDate(cflCoupon)),
- accrualEndDate=Date_ISO(Coupon_accrualEndDate(cflCoupon)),
- accrualPeriod=Coupon_accrualPeriod(cflCoupon),
- accrualDays=Coupon_accrualDays(cflCoupon),
- accrualDayCounter=DayCounter_name(Coupon_dayCounter(cflCoupon)),
- accruedAmount=Coupon_accruedAmount(self = cflCoupon, todaysDate),
- rate=InterestRate_rate(cflCouponFixIr), rateDayCount=DayCounter_name(InterestRate_dayCounter(cflCouponFixIr))
- ))
-}
-print(df)
-
-
-
-# %%
-floating_leg = swap$overnightLeg()
-
-# %%
-df = NULL
-for (i in seq(1, floating_leg$size())) {
- cfl = floating_leg[i][[1]]
- cflCoupon = as_coupon(cfl)
- cflCouponFloat = as_floating_rate_coupon(cfl)
- cflCouponFloatIdx = FloatingRateCoupon_index(cflCouponFloat)
-
-
- df = rbind(df, data.frame(date=Date_ISO(CashFlow_date(cfl)), amount=CashFlow_amount(cfl),
- accrualStartDate=Date_ISO(Coupon_accrualStartDate(cflCoupon)),
- accrualEndDate=Date_ISO(Coupon_accrualEndDate(cflCoupon)),
- accrualPeriod=Coupon_accrualPeriod(cflCoupon),
- accrualDays=Coupon_accrualDays(cflCoupon),
- accrualDayCounter=DayCounter_name(Coupon_dayCounter(cflCoupon)),
- accruedAmount=Coupon_accruedAmount(self = cflCoupon, todaysDate),
- spread=FloatingRateCoupon_spread(cflCouponFloat),
- gearing=FloatingRateCoupon_gearing(cflCouponFloat),
- adjFix=FloatingRateCoupon_adjustedFixing(cflCouponFloat),
- dtFix=Date_ISO(FloatingRateCoupon_fixingDate(cflCouponFloat)),
- convexityAdj=FloatingRateCoupon_convexityAdjustment(cflCouponFloat)
- ))
-}
-
-print(df)
-
diff --git a/R/demo/cds.R b/R/demo/cds.R
deleted file mode 100644
index 5cf66ff3..00000000
--- a/R/demo/cds.R
+++ /dev/null
@@ -1,116 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- DateParser_parseISO("2007-05-15")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays <- 3
-settlementDate <- Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', Date_ISO(todaysDate), "\n")
-cat('Settlement Date: ', Date_ISO(settlementDate), "\n")
-
-risk_free_rate = YieldTermStructureHandle(FlatForward(todaysDate, 0.01, Actual365Fixed()))
-
-# ### CDS parameters
-
-recovery_rate = 0.5
-quoted_spreads = c(0.0150, 0.0150, 0.0150, 0.0150)
-
-tenors = PeriodVector()
-tenors$append(Period(3, "Months"))
-tenors$append(Period(6, "Months"))
-tenors$append(Period(1, "Years"))
-tenors$append(Period(2, "Years"))
-
-maturities = DateVector()
-for (i in seq(1, tenors$size())) {
- maturities$append(
- Calendar_adjust(calendar,
- Calendar_advance(calendar, todaysDate, tenors[i][[1]]),
- "Following")
- )
-}
-
-instruments = DefaultProbabilityHelperVector()
-for (i in seq(1, length(quoted_spreads))) {
- s = quoted_spreads[i]
- tenor = tenors[i][[1]]
-
- it = SpreadCdsHelper(
- QuoteHandle(SimpleQuote(s)),
- tenor,
- 0,
- calendar,
- "Quarterly",
- "Following",
- DateGeneration_TwentiethIMM_get(),
- Actual365Fixed(),
- recovery_rate,
- risk_free_rate
- )
-
- instruments$append(it)
-}
-
-hazard_curve = PiecewiseFlatHazardRate(todaysDate, instruments, Actual365Fixed())
-
-print("Calibrated hazard rate values: ")
-for (i in seq(1, hazard_curve$dates()$size())) {
- print(paste("hazard rate on ",
- Date_ISO(hazard_curve$dates()[i][[1]]),
- "is ",
- HazardRateCurve_hazardRates(hazard_curve)[i]))
-}
-
-print(paste("1Y survival probability:",
- DefaultProbabilityTermStructure_survivalProbability(hazard_curve, Calendar_advance(calendar, todaysDate, Period(1, "Years"))),
- "expected 0.9704 "
-))
-
-print(paste("2Y survival probability:",
- DefaultProbabilityTermStructure_survivalProbability(hazard_curve, Calendar_advance(calendar, todaysDate, Period(2, "Years"))),
- "expected 0.9418 "
-))
-
-# ### Reprice instruments
-
-nominal = 1000000.0
-probability = DefaultProbabilityTermStructureHandle(hazard_curve)
-
-# We'll create a cds for every maturity:
-
-print("Repricing of quoted CDSs employed for calibration: ")
-for (i in seq(1, length(quoted_spreads))) {
- maturity = maturities[i][[1]]
- s = quoted_spreads[i]
- tenor = tenors[i][[1]]
-
- schedule = Schedule(
- todaysDate,
- maturity,
- Period(3, "Months"), # "Quarterly",
- calendar,
- "Following",
- "Unadjusted",
- DateGeneration_TwentiethIMM_get(),
- F
- )
-
- cds = CreditDefaultSwap(Protection_Seller_get(), nominal, s, schedule, "Following", Actual365Fixed())
- engine = MidPointCdsEngine(probability, recovery_rate, risk_free_rate)
- cds$setPricingEngine(engine)
-
- print(paste("fair spread: ", Period___str__(tenor), cds$fairSpread()))
- print(paste(" NPV: ", cds$NPV()))
- print(paste(" default leg: ", cds$defaultLegNPV()))
- print(paste(" coupon leg: ", cds$couponLegNPV()))
- print("")
-
-}
-
diff --git a/R/demo/curves.R b/R/demo/curves.R
deleted file mode 100644
index 5cc8af6f..00000000
--- a/R/demo/curves.R
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-suppressMessages(library(QuantLib))
-
-
-bToday = QuantLib::Date(31, "August", 2022)
-QuantLib::Settings_setEvaluationDate(self = QuantLib::Settings_instance(), d = bToday)
-print(Settings_instance()$getEvaluationDate())
-
-bufDates = QuantLib::DateVector()
-QuantLib::DateVector_append(self = bufDates, x = Date(31, "August", 2022))
-QuantLib::DateVector_append(self = bufDates, x = Date(30, "September", 2022))
-QuantLib::DateVector_size(self = bufDates)
-
-bCurve = QuantLib::DiscountCurve(dates = bufDates , discounts = c(1.0, 1.0), dayCounter = Actual360())
-
-
diff --git a/R/demo/european-option.R b/R/demo/european-option.R
deleted file mode 100644
index 4e8fb8b4..00000000
--- a/R/demo/european-option.R
+++ /dev/null
@@ -1,94 +0,0 @@
-
-## expanded to follow european-option.py
-
-suppressMessages(library(QuantLib))
-
-# global data
-todaysDate <- Date(15, "May", 1998)
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-settlementDate <- Date(17, "May", 1998)
-riskFreeRate <- FlatForward(settlementDate, 0.05, Actual365Fixed())
-
-# option parameters
-exercise <- EuropeanExercise(Date(17, "May", 1999))
-payoff <- PlainVanillaPayoff("Call", 8.0)
-
-# market data
-underlying <- SimpleQuote(7.0)
-volatility <- BlackConstantVol(todaysDate, TARGET(), 0.10, Actual365Fixed())
-dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
-
-process <- BlackScholesMertonProcess(QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility))
-
-cat(sprintf("%17s %8s %6s %6s\n", "method", "value", "errest", "error"))
-cat(rep("=", 43), "\n", sep="")
-report <- function(method, x, dx=NA) {
- err <- abs(x - refValue) # refValue is a global
- cat(sprintf("%17s %8.5f %6.4f %6.4f\n", method, x, dx, err))
- invisible(NULL)
-}
-
-option <- VanillaOption(payoff, exercise)
-invisible(option$setPricingEngine(AnalyticEuropeanEngine(process)))
-value <- option$NPV()
-refValue <- value
-report("analytic", value)
-
-invisible(option$setPricingEngine(IntegralEngine(process)))
-report('integral', option$NPV())
-
-## method: finite differences
-timeSteps <- 801
-gridPoints <- 800
-
-invisible(option$setPricingEngine(FdBlackScholesVanillaEngine(process,timeSteps,gridPoints)))
-report('finite diff.', option$NPV())
-
-
-## method: binomial
-timeSteps <- 801
-
-invisible(option$setPricingEngine(BinomialJRVanillaEngine(process,timeSteps)))
-report('binomial (JR)', option$NPV())
-
-invisible(option$setPricingEngine(BinomialCRRVanillaEngine(process,timeSteps)))
-report('binomial (CRR)', option$NPV())
-
-invisible(option$setPricingEngine(BinomialEQPVanillaEngine(process,timeSteps)))
-report('binomial (EQP)', option$NPV())
-
-invisible(option$setPricingEngine(BinomialTrigeorgisVanillaEngine(process,timeSteps)))
-report('bin. (Trigeorgis)', option$NPV())
-
-invisible(option$setPricingEngine(BinomialTianVanillaEngine(process,timeSteps)))
-report('binomial (Tian)', option$NPV())
-
-invisible(option$setPricingEngine(BinomialLRVanillaEngine(process,timeSteps)))
-report('binomial (LR)', option$NPV())
-
-## method: Monte Carlo
-invisible(option$setPricingEngine(MCLDEuropeanEngine(process,
- timeSteps = 1,
- timeStepsPerYear=NA,
- brownianBridge=FALSE,
- antitheticVariate=FALSE,
- requiredSamples=NULL,
- requiredTolerance = 0.02,
- maxSamples=NULL,
- seed = 42)))
-report('MC (crude)', option$NPV()) #, option$errorEstimate())
-
-invisible(option$setPricingEngine(MCLDEuropeanEngine(process,
- timeSteps = 1,
- timeStepsPerYear=NA,
- brownianBridge=FALSE,
- antitheticVariate=FALSE,
- requiredSamples = 32768,
- requiredTolerance = 0.02,
- maxSamples=NULL,
- seed=42)))
-report('MC (Sobol)', option$NPV())
-
diff --git a/R/demo/fd-option.R b/R/demo/fd-option.R
deleted file mode 100644
index 9d373c17..00000000
--- a/R/demo/fd-option.R
+++ /dev/null
@@ -1,23 +0,0 @@
-
-suppressMessages(library(QuantLib))
-
-quote <- function(x) { sapply(x, function(x1) {
- todaysDate <- Date(15, "May", 1998)
- invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
- settlementDate <- Date(17, "May", 1998)
- riskFreeRate <- FlatForward(settlementDate, 0.05, Actual365Fixed())
- exercise <- EuropeanExercise(Date(17, "May", 1999))
- payoff <- PlainVanillaPayoff("Call", 8.0)
- underlying <- SimpleQuote(x1)
- volatility <- BlackConstantVol(todaysDate, TARGET(), 0.10, Actual365Fixed())
- dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
- process <- BlackScholesMertonProcess(QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility))
- option <- VanillaOption(payoff, exercise)
- invisible(option$setPricingEngine(s_arg2=FdBlackScholesVanillaEngine(process, 25)))
- option$NPV()
-})}
-
-curve(quote,xlim=c(1,20))
diff --git a/R/demo/gaussian1d-models.R b/R/demo/gaussian1d-models.R
deleted file mode 100644
index f9b647e6..00000000
--- a/R/demo/gaussian1d-models.R
+++ /dev/null
@@ -1,361 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- DateParser_parseISO("2014-04-30")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays <- 3
-settlementDate <- Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', Date_ISO(todaysDate), "\n")
-cat('Settlement Date: ', Date_ISO(settlementDate), "\n")
-
-refDate = todaysDate
-
-# ### Calculations
-
-# This exercise tries to replicate the Quantlib C++ `Gaussian1dModel` example on how to use the GSR and Markov Functional model.
-
-# We assume a multicurve setup, for simplicity with flat yield term structures.
-#
-# The discounting curve is an Eonia curve at a level of 2% and the forwarding curve is an Euribor 6m curve at a level of 2.5%.
-#
-# For the volatility we assume a flat swaption volatility at 20%.
-
-
-forward6mQuote = QuoteHandle(SimpleQuote(0.025))
-oisQuote = QuoteHandle(SimpleQuote(0.02))
-volQuote = QuoteHandle(SimpleQuote(0.2))
-
-# %%
-dc = Actual365Fixed()
-yts6m = FlatForward(refDate, forward6mQuote, dc)
-ytsOis = FlatForward(refDate, oisQuote, dc)
-yts6m$enableExtrapolation()
-ytsOis$enableExtrapolation()
-
-hyts6m = RelinkableYieldTermStructureHandle(yts6m)
-t0_curve = YieldTermStructureHandle(yts6m)
-t0_Ois = YieldTermStructureHandle(ytsOis)
-euribor6m = Euribor6M(hyts6m)
-swaptionVol = ConstantSwaptionVolatility(0, calendar, "ModifiedFollowing", volQuote, Actual365Fixed())
-
-
-# %%
-effectiveDate = Calendar_advance(calendar, refDate, 2, "Days")
-print(Date_ISO(effectiveDate))
-
-maturityDate = Calendar_advance(calendar, effectiveDate, 10, "Years")
-print(Date_ISO(maturityDate))
-
-# %%
-fixedSchedule = Schedule(effectiveDate,
- maturityDate,
- Period(1, "Years"),
- calendar,
- "ModifiedFollowing",
- "ModifiedFollowing",
- DateGeneration_Forward_get(), F)
-
-# %%
-floatSchedule = Schedule(effectiveDate,
- maturityDate,
- Period(6, "Months"),
- calendar,
- "ModifiedFollowing",
- "ModifiedFollowing",
- DateGeneration_Forward_get(), F)
-
-
-# We consider a standard 10-years Bermudan payer swaption with yearly exercises at a strike of 4%.
-
-# %%
-fixedNominal = rep(1, fixedSchedule$size()-1)
-floatingNominal = rep(1, floatSchedule$size()-1)
-strike = rep(0.04, fixedSchedule$size()-1)
-gearing = rep(1, floatSchedule$size()-1)
-spread = rep(0, floatSchedule$size()-1)
-
-# %%
-underlying = NonstandardSwap(
- Swap_Payer_get(),
- fixedNominal, floatingNominal, fixedSchedule, strike,
- Thirty360(Thirty360_BondBasis_get()), floatSchedule,
- euribor6m, gearing, spread, Actual360(), F, F, "ModifiedFollowing")
-
-# %%
-exerciseDates = Schedule_dates(self = fixedSchedule, .copy = T)
-for (i in seq(0, exerciseDates$size()-1)) { # C Style vector numbering
- DateVector___setitem__(exerciseDates, i, Calendar_advance(calendar, DateVector___getitem__(exerciseDates, i), -2, "Days"))
-}
-
-DateVector___delitem__(exerciseDates, 0)
-DateVector___delitem__(exerciseDates, DateVector___len__(exerciseDates)-1)
-for (i in seq(1, exerciseDates$size())) { # R style vector numbering
- print(exerciseDates[i][[1]])
-}
-
-exercise = BermudanExercise(exerciseDates)
-swaption = NonstandardSwaption(underlying,exercise,Settlement_Physical_get())
-
-# The model is a one factor Hull White model with piecewise volatility adapted to our exercise dates.
-#
-# The reversion is just kept constant at a level of 1%.
-
-stepDates = DateVector(exerciseDates)
-DateVector___delitem__(stepDates, DateVector___len__(stepDates)-1)
-
-sigmas = QuoteHandleVector()
-for (i in seq(1, 9)) {
- QuoteHandleVector_append(sigmas, QuoteHandle(SimpleQuote(0.01)))
-}
-
-reversion = QuoteHandleVector()
-QuoteHandleVector_append(reversion, QuoteHandle(SimpleQuote(0.01)))
-
-#
-# The model's curve is set to the 6m forward curve.
-# Note that the model adapts automatically to other curves where appropriate
-# (e.g. if an index requires a different forwarding curve) or where explicitly specified (e.g. in a swaption pricing engine).
-
-
-gsr = Gsr(t0_curve, stepDates, sigmas, reversion)
-swaptionEngine = Gaussian1dSwaptionEngine(gsr, 64, 7.0, T, F, t0_Ois)
-nonstandardSwaptionEngine = Gaussian1dNonstandardSwaptionEngine(
- gsr, 64, 7.0, T, F, QuoteHandle(SimpleQuote(0)), t0_Ois)
-
-# %%
-swaption$setPricingEngine(nonstandardSwaptionEngine)
-
-# %%
-swapBase = EuriborSwapIsdaFixA(Period(10, 'Years'), t0_curve, t0_Ois)
-basket = swaption$calibrationBasket(swapBase, swaptionVol, 'Naive')
-
-# %%
-for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- BlackCalibrationHelper_setPricingEngine(basket_i, swaptionEngine)
-}
-
-
-# %%
-method = LevenbergMarquardt()
-ec = EndCriteria(1000, 10, 1e-8, 1e-8, 1e-8)
-
-# %%
-gsr$calibrateVolatilitiesIterative(basket, method, ec)
-
-
-# %% [markdown]
-# The engine can generate a calibration basket in two modes.
-#
-# The first one is called Naive and generates ATM swaptions adapted to the exercise dates of the swaption and its maturity date. The resulting basket looks as follows:
-
-# %%
-basket_data = function(basket) {
- df = NULL
- for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- h = as_swaption_helper(basket_i)
- hopt = SwaptionHelper_swaption(h)
- df = rbind(df, data.frame(expiry=Date_ISO(SwaptionHelper_swaptionExpiryDate(h)),
- maturity=Date_ISO(SwaptionHelper_swaptionMaturityDate(h)),
- nominal=SwaptionHelper_swaptionNominal(h),
- strike=SwaptionHelper_swaptionStrike(h),
- optType=Swaption_type(hopt)
-
- ))
- }
- df
-}
-
-print(basket_data(basket))
-
-
-
-
-#
-# Let's calibrate our model to this basket.
-# We use a specialized calibration method calibrating the sigma function one by one to the calibrating vanilla swaptions. The result of this is as follows:
-
-# %%
-calibration_data = function(basket, volatilities) {
- # volatilities = gsr$volatility()
- df = NULL
- for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- vola_i = volatilities[i][[1]]
- h = as_swaption_helper(basket_i)
- hopt = SwaptionHelper_swaption(h)
- modelPrice = basket_i$modelValue()
- modelImpVol = BlackCalibrationHelper_impliedVolatility(self = basket_i, targetValue = modelPrice, accuracy = 1e-6, maxEvaluations = 1000, minVol = 0.0, maxVol = 2.0)
- marketPrice = basket_i$marketValue()
-
- df = rbind(df, data.frame(expiry=Date_ISO(SwaptionHelper_swaptionExpiryDate(h)),
- modelSigma=vola_i,
- modelPrice=modelPrice,
- marketPrice=marketPrice,
- modelImpVol=modelImpVol,
- marketImpVol=QuoteHandle_value(basket_i$volatility())
- ))
- }
-
- df
-}
-
-print(calibration_data(basket, gsr$volatility()))
-
-# %% [markdown]
-# Bermudan swaption NPV (ATM calibrated GSR):
-
-# %%
-print(swaption$NPV())
-
-
-#
-# There is another mode to generate a calibration basket called `MaturityStrikeByDeltaGamma`.
-# This means that the maturity, the strike and the nominal of the calibrating swaptions are obtained matching the NPV,
-# first derivative and second derivative of the swap you will exercise into at at each bermudan call date.
-# The derivatives are taken with respect to the model's state variable.
-#
-# Let's try this in our case.
-
-# %%
-basket = swaption$calibrationBasket(swapBase, swaptionVol, 'MaturityStrikeByDeltaGamma')
-print(basket_data(basket))
-
-# %%
-for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- BlackCalibrationHelper_setPricingEngine(basket_i, swaptionEngine)
-}
-
-
-# %% [markdown]
-# The calibrated nominal is close to the exotics nominal. The expiries and maturity dates of the vanillas are the same as in the case above. The difference is the strike which is now equal to the exotics strike.
-#
-# Let's see how this affects the exotics NPV. The recalibrated model is:
-
-# %%
-gsr$calibrateVolatilitiesIterative(basket, method, ec)
-print(calibration_data(basket, gsr$volatility()))
-
-# %% [markdown]
-# Bermudan swaption NPV (deal strike calibrated GSR):
-
-# %%
-print(swaption$NPV())
-
-#
-# We can do more complicated things.
-# Let's e.g. modify the nominal schedule to be linear amortizing and see what the effect on the generated calibration basket is:
-
-# %%
-for (i in seq(1,fixedSchedule$size()-1)) {
- tmp = 1.0 - i/ (fixedSchedule$size())
- fixedNominal[i] = tmp
- floatingNominal[i*2-1] = tmp
- floatingNominal[i*2] = tmp
-}
-
-# %%
-underlying2 = NonstandardSwap(Swap_Payer_get(),
- fixedNominal, floatingNominal, fixedSchedule, strike,
- Thirty360(Thirty360_BondBasis_get()), floatSchedule,
- euribor6m, gearing, spread, Actual360(), F, F, "ModifiedFollowing")
-
-# %%
-swaption2 = NonstandardSwaption(underlying2, exercise, Settlement_Physical_get())
-
-# %%
-swaption2$setPricingEngine(nonstandardSwaptionEngine)
-basket = swaption2$calibrationBasket(swapBase, swaptionVol, 'MaturityStrikeByDeltaGamma')
-
-# %%
-print(basket_data(basket))
-
-#
-# The notional is weighted over the underlying exercised into and the maturity is adjusted downwards. The rate, on the other hand, is not affected.
-
-#
-# You can also price exotic bond's features.
-# If you have e.g. a Bermudan callable fixed bond you can set up the call right as a swaption
-# to enter into a one leg swap with notional reimbursement at maturity.
-# The exercise should then be written as a rebated exercise paying the notional in case of exercise. The calibration basket looks like this:
-
-# %%
-fixedNominal2 = rep(1, fixedSchedule$size()-1)
-floatingNominal2 = rep(0, fixedSchedule$size()*2-2) #null the second leg
-
-# %%
-underlying3 = NonstandardSwap(Swap_Receiver_get(),
- fixedNominal2, floatingNominal2, fixedSchedule, strike,
- Thirty360(Thirty360_BondBasis_get()), floatSchedule,
- euribor6m, gearing, spread, Actual360(), F, T, "ModifiedFollowing")
-
-# %%
-rebateAmount = rep(-1, exerciseDates$size())
-exercise2 = RebatedExercise(exercise, rebateAmount, 2, calendar)
-swaption3 = NonstandardSwaption(underlying3, exercise2, Settlement_Physical_get())
-
-# %%
-oas0 = SimpleQuote(0)
-oas100 = SimpleQuote(0.01)
-oas = RelinkableQuoteHandle(oas0)
-
-# %%
-nonstandardSwaptionEngine2 = Gaussian1dNonstandardSwaptionEngine(
- gsr, 64, 7.0, T, F, oas, t0_curve) # Change discounting to 6m
-
-# %%
-swaption3$setPricingEngine(nonstandardSwaptionEngine2)
-basket = swaption3$calibrationBasket(swapBase, swaptionVol, 'MaturityStrikeByDeltaGamma')
-
-# %%
-print(basket_data(basket))
-
-# %% [markdown]
-# Note that nominals are not exactly 1.0 here. This is because we do our bond discounting on 6m level while the swaptions are still discounted on OIS level. (You can try this by changing the OIS level to the 6m level, which will produce nominals near 1.0).
-#
-# The NPV of the call right is (after recalibrating the model):
-
-# %%
-for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- BlackCalibrationHelper_setPricingEngine(basket_i, swaptionEngine)
-}
-
-# %%
-gsr$calibrateVolatilitiesIterative(basket, method, ec)
-
-# %%
-print(swaption3$NPV())
-
-# %% [markdown]
-# Up to now, no credit spread is included in the pricing. We can do so by specifying an oas in the pricing engine. Let's set the spread level to 100bp and regenerate the calibration basket.
-
-# %%
-oas$linkTo(oas100)
-basket = swaption3$calibrationBasket(swapBase, swaptionVol, 'MaturityStrikeByDeltaGamma')
-print(basket_data(basket))
-
-# %% [markdown]
-# The adjusted basket takes the credit spread into account. This is consistent to a hedge where you would have a margin on the float leg around 100bp,too.
-
-# %%
-for (i in seq(1, basket$size())) {
- basket_i = basket[i][[1]]
- BlackCalibrationHelper_setPricingEngine(basket_i, swaptionEngine)
-}
-
-# %%
-gsr$calibrateVolatilitiesIterative(basket, method, ec)
-
-# %%
-print(swaption3$NPV())
-
diff --git a/R/demo/global-bootstrap.R b/R/demo/global-bootstrap.R
deleted file mode 100644
index 3abe69ab..00000000
--- a/R/demo/global-bootstrap.R
+++ /dev/null
@@ -1,152 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- DateParser_parseISO("2019-09-26")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays <- 2
-settlementDate <- Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', Date_ISO(todaysDate), "\n")
-cat('Settlement Date: ', Date_ISO(settlementDate), "\n")
-
-spot = settlementDate
-
-# %% [markdown]
-# ### Data
-#
-# We'll use the following data as input:
-
-# %%
-refMktRates = c(
- -0.373,
- -0.388,
- -0.402,
- -0.418,
- -0.431,
- -0.441,
- -0.45,
- -0.457,
- -0.463,
- -0.469,
- -0.461,
- -0.463,
- -0.479,
- -0.4511,
- -0.45418,
- -0.439,
- -0.4124,
- -0.37703,
- -0.3335,
- -0.28168,
- -0.22725,
- -0.1745,
- -0.12425,
- -0.07746,
- 0.0385,
- 0.1435,
- 0.17525,
- 0.17275,
- 0.1515,
- 0.1225,
- 0.095,
- 0.0644
-)
-
-# ### Market instruments
-
-# %%
-index = Euribor6M()
-
-# The first market rate is for the 6-months deposit...
-
-# %%
-helpers = RateHelperVector()
-
-helpers$append(
- DepositRateHelper(
- refMktRates[1] / 100.0, Period(6, "Months"), 2, calendar, "ModifiedFollowing", T, Actual360()
- )
-)
-
-# ...the next 12 are for FRAs...
-
-# %%
-for (i in seq(2, 13)) {
- helpers$append(
- FraRateHelper(refMktRates[i] / 100.0, i + 1, index)
- )
-}
-
-# ...and the others are swap rates.
-
-# %%
-swapTenors = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 20, 25, 30, 35, 40, 45, 50)
-
-for (i in seq(14, length(refMktRates))) {
- r = refMktRates[i]
- tenor = swapTenors[i-13]
- helpers$append(
- SwapRateHelper(
- r / 100.0, Period(tenor, "Years"), calendar, "Annual", "ModifiedFollowing", Thirty360(Thirty360_BondBasis_get()), index
- )
- )
-}
-
-# We'll also add a few synthetic helpers:
-
-# %%
-additional_helpers = RateHelperVector()
-for (i in seq(0, 6)){
- additional_helpers$append(
- FraRateHelper(-0.004, 12 + i, index)
- )
-}
-
-# %%
-additional_dates = DateVector()
-for (i in seq(0, 4)){
- additional_dates$append(
- Calendar_advance(calendar, spot, Period(i+1, "Months"))
- )
-}
-
-
-
-# ### Global bootstrap
-#
-# This curve takes into account the market instruments, as well as the passed additional ones.
-
-# %%
-curve = GlobalLinearSimpleZeroCurve(
- spot, helpers, Actual365Fixed(), GlobalBootstrap(additional_helpers, additional_dates, 1.0e-4)
-)
-curve$enableExtrapolation()
-
-
-# ### Report
-df = NULL
-for (i in seq(1, helpers$size())) {
- h = helpers[i][[1]]
- pillar = RateHelper_pillarDate(h)
-
- day_counter = Actual360()
- compounding = "Simple"
- if (i > 13) {
- day_counter = Thirty360(Thirty360_BondBasis_get())
- compounding = "SimpleThenCompounded"
- }
-
- r = YieldTermStructure_zeroRate(curve, pillar, day_counter, compounding, "Annual")
-
- df = rbind(df, data.frame(
- pillar=Date_ISO(pillar), zeroRate=InterestRate_rate(r)*100.0
- ))
-}
-print(df)
-
diff --git a/R/demo/graph.R b/R/demo/graph.R
deleted file mode 100644
index a4c8f39e..00000000
--- a/R/demo/graph.R
+++ /dev/null
@@ -1,24 +0,0 @@
-
-suppressMessages(library(QuantLib))
-
-quote <- function(x) { sapply(x, function(x1) {
- todaysDate <- Date(15, "May", 1998)
- Settings_instance()$setEvaluationDate(d=todaysDate)
- settlementDate <- Date(17, "May", 1998)
- riskFreeRate <- FlatForward(settlementDate, 0.05, Actual365Fixed())
- exercise <- EuropeanExercise(Date(17, "May", 1999))
- payoff <- PlainVanillaPayoff("Call", 8.0)
- underlying <- SimpleQuote(x1)
- volatility <- BlackConstantVol(todaysDate, TARGET(), 0.10, Actual365Fixed())
- dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
- process <- BlackScholesMertonProcess(QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility))
- option <- VanillaOption(payoff, exercise)
- Instrument_setPricingEngine(option, s_arg2=AnalyticEuropeanEngine(process))
- value <- option$NPV()
- value
-})}
-
-curve(quote,xlim=c(1,20))
diff --git a/R/demo/scatter.R b/R/demo/scatter.R
deleted file mode 100644
index ac581fb0..00000000
--- a/R/demo/scatter.R
+++ /dev/null
@@ -1,41 +0,0 @@
-
-suppressMessages(library(QuantLib))
-
-spot<-seq(10.0,95.00,len=20)
-vol<-0.5
-g<-expand.grid(spot=spot,vol=vol)
-
-todaysDate <- Date(15, "May", 1998)
-Settings_instance()$setEvaluationDate(d=todaysDate)
-settlementDate <- Date(17, "May", 1998)
-riskQuote <- SimpleQuote(0.05)
-riskFreeRate <- FlatForward(settlementDate, QuoteHandle(riskQuote),
- Actual365Fixed())
-exercise <- EuropeanExercise(Date(17, "May", 1999))
-payoff <- PlainVanillaPayoff("Call", 50.0)
-dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
-underlying <- SimpleQuote(10.0)
-volatilityQuote <- SimpleQuote(0.05)
-volatility <- BlackConstantVol(todaysDate, TARGET(),
- QuoteHandle(volatilityQuote),
- Actual365Fixed())
-process <- BlackScholesMertonProcess(QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility))
-engine <- AnalyticEuropeanEngine(process)
-option <- VanillaOption(payoff, exercise)
-option$setPricingEngine(s_arg2=engine)
-
-t <- mapply(function(x,y) {
- underlying$setValue(value=x)
- volatilityQuote$setValue(value=y)
- list(NPV=option$NPV(), gamma=option$gamma(),
- delta=option$delta(), vega=option$vega())},
- g$spot, g$vol, SIMPLIFY=FALSE)
-
-g$NPV <- sapply(1:length(t), function(x) t[[x]]$NPV)
-g$gamma <- sapply(1:length(t), function(x) t[[x]]$gamma)
-g$delta <- sapply(1:length(t), function(x) t[[x]]$delta)
-g$vega <- sapply(1:length(t), function(x) t[[x]]$vega)
-pairs(g)
diff --git a/R/demo/swap.R b/R/demo/swap.R
deleted file mode 100644
index 7e6e300a..00000000
--- a/R/demo/swap.R
+++ /dev/null
@@ -1,340 +0,0 @@
-
-# inspired by python example with the same name
-
-suppressMessages(library(QuantLib))
-
-## global data
-calendar <- TARGET()
-
-todaysDate <- DateParser_parseISO("2001-09-06")
-invisible(Settings_instance()$setEvaluationDate(d=todaysDate))
-
-settlementDays = 2
-settlementDate = Calendar_advance(calendar, todaysDate, settlementDays, "Days")
-
-cat('Today : ', Date_ISO(todaysDate), "\n")
-cat('Settlement Date: ', Date_ISO(settlementDate), "\n")
-
-
-# ### Market quotes
-
-# %%
-deposits = list(
- "3M" = 0.0363
-)
-
-# %%
-FRAs = list(
- "3x6" = 0.037125,
- "6x9" = 0.037125,
- "9x12" =0.037125
-)
-
-
-# %%
-futures = list(
- "2001-12-19" = 96.2875,
- "2002-03-20" = 96.7875,
- "2002-06-19" = 96.9875,
- "2002-09-18" = 96.6875,
- "2002-12-18" = 96.4875,
- "2003-03-19" = 96.3875,
- "2003-06-18" = 96.2875,
- "2003-09-17" = 96.0875
-)
-
-# %%
-swaps = list(
-# "2Y" = 0.037125,
- "3Y" = 0.0398,
- "5Y" = 0.0443,
- "10Y" = 0.05165,
- "15Y" = 0.055175
-
-)
-
-allHelpers_DepoFutSwap = RateHelperVector()
-allHelpers_DepoFraSwap = RateHelperVector()
-
-# Rate Helpers - Depos
-
-for (it in names(deposits)) {
- itVal = deposits[[it]]
-
- dayCounter = Actual360()
-
- dh = DepositRateHelper(
- QuoteHandle(SimpleQuote(itVal)),
- PeriodParser_parse(it),
- settlementDays,
- calendar,
- "ModifiedFollowing",
- F,
- dayCounter
- )
-
- RateHelperVector_append(allHelpers_DepoFutSwap, dh)
- RateHelperVector_append(allHelpers_DepoFraSwap, dh)
-}
-
-# Rate Helpers - FRAs
-
-for (it in names(FRAs)) {
- itVal = FRAs[[it]]
-
- itSplit = strsplit(x = it, split = "x", fixed = T)[[1]]
- n = as.numeric(itSplit[1])
- m = as.numeric(itSplit[2])
-
- dayCounter = Actual360()
- months = 3
-
- dh = FraRateHelper(
- QuoteHandle(SimpleQuote(itVal)), n, m, settlementDays, calendar, "ModifiedFollowing", F, dayCounter
- )
-
- RateHelperVector_append(allHelpers_DepoFraSwap, dh)
-}
-
-
-# Rate Helpers - Futures
-
-for (it in names(futures)) {
- itVal = futures[[it]]
-
- dayCounter = Actual360()
- months = 3
-
- dh = FuturesRateHelper(
- QuoteHandle(SimpleQuote(itVal)),
- DateParser_parseISO(it),
- months,
- calendar,
- "ModifiedFollowing",
- T,
- dayCounter,
- QuoteHandle(SimpleQuote(0.0))
- )
-
- RateHelperVector_append(allHelpers_DepoFutSwap, dh)
-}
-
-
-#
-# The discount curve for the swaps will come from elsewhere.
-# -> A real application would use some kind of risk-free curve; here we're using a flat one for convenience.
-#
-
-# %%
-discountTermStructure = YieldTermStructureHandle(FlatForward(settlementDate, 0.04, Actual360()))
-
-# %%
-
-fixedLegFrequency = "Annual"
-fixedLegTenor = PeriodParser_parse("1Y")
-fixedLegAdjustment = "Unadjusted"
-fixedLegDayCounter = Thirty360(Thirty360_BondBasis_get())
-floatingLegFrequency = "Quarterly"
-floatingLegTenor = PeriodParser_parse("3M")
-floatingLegAdjustment = "ModifiedFollowing"
-
-for (it in names(swaps)) {
- itVal = swaps[[it]]
-
- dh = SwapRateHelper(
- QuoteHandle(SimpleQuote(itVal)),
- PeriodParser_parse(it),
- calendar,
- fixedLegFrequency,
- fixedLegAdjustment,
- fixedLegDayCounter,
- Euribor3M(),
- QuoteHandle(),
- PeriodParser_parse("0D"),
- discountTermStructure
- )
-
- RateHelperVector_append(allHelpers_DepoFutSwap, dh)
- RateHelperVector_append(allHelpers_DepoFraSwap, dh)
-}
-
-# ### Term structure construction
-
-printCurve <- function(curve, helpers) {
- df = NULL
- for (i in seq(1, helpers$size())) {
- h = helpers[i][[1]]
- pillar = RateHelper_pillarDate(h)
-
- day_counter = Actual365Fixed()
- compounding = "Continuous"
-
- r = YieldTermStructure_zeroRate(curve, pillar, day_counter, compounding, "Annual")
- disc = YieldTermStructure_discount(curve, pillar)
-
- df = rbind(df, data.frame(
- pillar=Date_ISO(pillar), zeroRate=InterestRate_rate(r)*100.0, df=disc, impliedRate=RateHelper_impliedQuote(h)
- ))
- }
- print(df)
-}
-
-
-# %%
-forecastTermStructure = RelinkableYieldTermStructureHandle()
-
-# %%
-depoFuturesSwapCurve = PiecewiseFlatForward(settlementDate, allHelpers_DepoFutSwap, Actual360())
-printCurve(depoFuturesSwapCurve, allHelpers_DepoFutSwap)
-
-
-# %%
-depoFraSwapCurve = PiecewiseFlatForward(settlementDate, allHelpers_DepoFraSwap, Actual360())
-printCurve(depoFraSwapCurve, allHelpers_DepoFraSwap)
-
-
-
-# ### Swap pricing
-
-# %%
-swapEngine = DiscountingSwapEngine(discountTermStructure)
-
-# %%
-nominal = 1000000
-length = 5
-maturity = Calendar_advance(calendar, settlementDate, length, "Years")
-payFixed = T
-
-# %%
-fixedLegFrequency = "Annual"
-fixedLegAdjustment = "Unadjusted"
-fixedLegDayCounter = Thirty360(Thirty360_BondBasis_get())
-fixedRate = swaps[["5Y"]] # 0.04
-
-# %%
-floatingLegFrequency = "Quarterly"
-spread = 0.0
-fixingDays = 2
-index = Euribor3M(forecastTermStructure)
-floatingLegAdjustment = "ModifiedFollowing"
-floatingLegDayCounter = index$dayCounter()
-
-# %%
-fixedSchedule = Schedule(
- settlementDate,
- maturity,
- fixedLegTenor,
- calendar,
- fixedLegAdjustment,
- fixedLegAdjustment,
- DateGeneration_Forward_get(),
- F
-)
-floatingSchedule = Schedule(
- settlementDate,
- maturity,
- floatingLegTenor,
- calendar,
- floatingLegAdjustment,
- floatingLegAdjustment,
- DateGeneration_Forward_get(),
- F
-)
-
-# We'll build a 5-years swap starting spot...
-
-# %%
-spot = VanillaSwap(
- Swap_Payer_get(),
- nominal,
- fixedSchedule,
- fixedRate,
- fixedLegDayCounter,
- floatingSchedule,
- index,
- spread,
- floatingLegDayCounter
-)
-spot$setPricingEngine(swapEngine)
-
-
-
-# ...and one starting 1 year forward.
-
-# %%
-forwardStart = Calendar_advance(calendar, settlementDate, 1, "Years")
-forwardEnd = Calendar_advance(calendar, forwardStart, length, "Years")
-fixedSchedule = Schedule(
- forwardStart,
- forwardEnd,
- fixedLegTenor,
- calendar,
- fixedLegAdjustment,
- fixedLegAdjustment,
- DateGeneration_Forward_get(),
- F
-)
-floatingSchedule = Schedule(
- forwardStart,
- forwardEnd,
- floatingLegTenor,
- calendar,
- floatingLegAdjustment,
- floatingLegAdjustment,
- DateGeneration_Forward_get(),
- F
-)
-
-# %%
-forward = VanillaSwap(
- Swap_Payer_get(),
- nominal,
- fixedSchedule,
- fixedRate,
- fixedLegDayCounter,
- floatingSchedule,
- index,
- spread,
- floatingLegDayCounter
-)
-forward$setPricingEngine(swapEngine)
-
-
-# We'll price them both on the bootstrapped curves.
-#
-# This is the quoted 5-years market rate; we expect the fair rate of the spot swap to match it.
-
-# %%
-print(swaps["5Y"])
-
-showSwap <- function(swap) {
- print(paste("NPV = ", swap$NPV()))
- print(paste("Fair spread = ", (swap$fairSpread()*100)))
- print(paste("Fair rate = ", (swap$fairRate()*100)))
-}
-
-
-# %% [markdown]
-# These are the results for the 5-years spot swap on the deposit/futures/swap curve...
-
-# %%
-forecastTermStructure$linkTo(depoFuturesSwapCurve)
-showSwap(spot)
-
-# ...and these are on the deposit/fra/swap curve.
-
-# %%
-forecastTermStructure$linkTo(depoFraSwapCurve)
-showSwap(spot)
-
-# %% [markdown]
-# The same goes for the 1-year forward swap, except for the fair rate not matching the spot rate.
-
-# %%
-forecastTermStructure$linkTo(depoFuturesSwapCurve)
-showSwap(forward)
-
-# %%
-forecastTermStructure$linkTo(depoFraSwapCurve)
-showSwap(forward)
-
diff --git a/R/demo/wireframe.R b/R/demo/wireframe.R
deleted file mode 100644
index 2257db75..00000000
--- a/R/demo/wireframe.R
+++ /dev/null
@@ -1,60 +0,0 @@
-
-suppressMessages(library(QuantLib))
-library(lattice)
-library(grid)
-
-spot<-seq(10.0,95.00,len=20)
-vol<-seq(0.20,1.0,len=20)
-g<-expand.grid(spot=spot,vol=vol)
-
-todaysDate <- Date(15, "May", 1998)
-Settings_instance()$setEvaluationDate(d=todaysDate)
-settlementDate <- Date(17, "May", 1998)
-riskQuote <- SimpleQuote(0.05)
-riskFreeRate <- FlatForward(settlementDate, QuoteHandle(riskQuote),
- Actual365Fixed())
-exercise <- EuropeanExercise(Date(17, "May", 1999))
-payoff <- PlainVanillaPayoff("Call", 50.0)
-dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
-underlying <- SimpleQuote(10.0)
-
-volatilityQuote <- SimpleQuote(0.05)
-volatility <- BlackConstantVol(todaysDate, TARGET(),
- QuoteHandle(volatilityQuote),
- Actual365Fixed())
-process <- BlackScholesMertonProcess(QuoteHandle(underlying),
- YieldTermStructureHandle(dividendYield),
- YieldTermStructureHandle(riskFreeRate),
- BlackVolTermStructureHandle(volatility))
-engine <- AnalyticEuropeanEngine(process)
-option <- VanillaOption(payoff, exercise)
-option$setPricingEngine(s_arg2=engine)
-
-t <- mapply(function(x,y) {
-underlying$setValue(value=x)
-volatilityQuote$setValue(value=y)
-list(NPV=option$NPV(), gamma=option$gamma(),
- delta=option$delta(), vega=option$vega())},
- g$spot, g$vol, SIMPLIFY=FALSE)
-
-g$NPV <- sapply(1:length(t), function(x) t[[x]]$NPV)
-g$gamma <- sapply(1:length(t), function(x) t[[x]]$gamma)
-g$delta <- sapply(1:length(t), function(x) t[[x]]$delta)
-g$vega <- sapply(1:length(t), function(x) t[[x]]$vega)
-par(mfrow = c(2,3))
-plot <- vector("list",10)
-plot[[1]] <- wireframe(NPV ~ spot*vol, g, drape=TRUE)
-plot[[2]] <- wireframe(gamma ~ spot*vol, g, drape=TRUE)
-plot[[3]] <- wireframe(delta ~ spot*vol, g, drape=TRUE)
-plot[[4]] <- wireframe(vega ~ spot*vol, g, drape=TRUE)
-
-grid.newpage()
-pushViewport(viewport(layout=grid.layout(2,2)))
-for (i in 1:4) {
-pushViewport(viewport(layout.pos.col=((i - 1) %% 2) + 1,
- layout.pos.row=((i - 1) %/% 2) + 1))
- print(plot[[i]], newpage=FALSE)
- popViewport()
-}
-popViewport()
-
diff --git a/R/src/Makevars b/R/src/Makevars
deleted file mode 100644
index fd0e9215..00000000
--- a/R/src/Makevars
+++ /dev/null
@@ -1,2 +0,0 @@
-PKG_CPPFLAGS=`quantlib-config --cflags`
-PKG_LIBS=`quantlib-config --libs`
diff --git a/README.md b/README.md
index 38758031..4b8167af 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,18 @@
-QuantLib-Risks: Risk-enabled QuantLib Python Bindings
-=====================================================
+QuantLib-Risks: Risk-enabled QuantLib for Python
+================================================
-[![Download source](https://img.shields.io/github/v/release/auto-differentiation/QuantLib-Risks?label=source&sort=semver)](https://github.com/auto-differentiation/QuantLib-Risks/releases/latest)
+[![Download source](https://img.shields.io/github/v/release/auto-differentiation/QuantLib-Risks-Py?label=source&sort=semver)](https://github.com/auto-differentiation/QuantLib-Risks-Py/releases/latest)
[![PyPI version](https://img.shields.io/pypi/v/QuantLib-Risks?label=PyPI)](https://pypi.org/project/QuantLib-Risks)
---
-This fork of [QuantLib-SWIG](https://github.com/lballabio/QuantLib-SWIG) builds QuantLib Python bindings with automatic differentiation, enabling
+This repository builds QuantLib Python bindings with automatic differentiation, enabling
fast risks calculation with QuantLib in Python.
-It wraps [quantlib-xad](https://github.com/auto-differentiation/quantlib-xad)
+It wraps [C++ QuantLib-Risks](https://github.com/auto-differentiation/QuantLib-Risks-Cpp)
in Python.
+It is based on [QuantLib-SWIG](https://github.com/lballabio/QuantLib-SWIG) and
+is kept in sync with it.
## Getting Started
@@ -22,9 +24,14 @@ pip install QuantLib-Risks
## Getting Help
-For documentation and other resources, see https://auto-differentiation.github.io/quantlib .
+For documentation and other resources, see https://auto-differentiation.github.io/quantlib-risks/python/ .
-If you have found an issue, want to report a bug, or have a feature request, please raise a [GitHub issue](https://github.com/auto-differentiation/XAD/issues).
+If you have found an issue, want to report a bug, or have a feature request, please raise a [GitHub issue](https://github.com/auto-differentiation/QuantLib-Risks-Py/issues).
+
+## Related Projects
+
+- XAD Comprehensive automatic differentiation in [Python](https://github.com/auto-differentiation/xad-py) and [C++](https://github.com/auto-differentiation/xad)
+- QuantLib-Risks: Fast risk evaluations in [Python](https://github.com/auto-differentiation/QuantLib-Risks-Py) and [C++](https://github.com/auto-differentiation/QuantLib-Risks-Cpp)
## Contributing
diff --git a/SWIG/tape.i b/SWIG/tape.i
index 58f82854..634870ae 100644
--- a/SWIG/tape.i
+++ b/SWIG/tape.i
@@ -1,5 +1,5 @@
/******************************************************************************
- * Tape activation functions to ensure an xad-autodiff global tape instance
+ * Tape activation functions to ensure an xad global tape instance
* matches the one in QuantLib-Risks.
*
* This file is part of QuantLib-Risks, a Python wrapper for QuantLib enabled
diff --git a/Scala/Makefile.am b/Scala/Makefile.am
deleted file mode 100644
index 8120b860..00000000
--- a/Scala/Makefile.am
+++ /dev/null
@@ -1,46 +0,0 @@
-
-EXAMPLES = CPIBond EquityOptions HestonModelCalibration HestonMonteCarlo ObserverPattern Optimizer RandomNumbers Swing
-
-SWIGFLAGS =
-
-if JAVA_AUTOLOAD
-SWIGFLAGS += -DJAVA_AUTOLOAD
-endif
-
-if JAVA_FINALIZER
-SWIGFLAGS += -DJAVA_FINALIZER
-endif
-
-if JAVA_AUTOCLOSEABLE
-SWIGFLAGS += -DJAVA_AUTOCLOSEABLE
-endif
-
-if HAVE_JAVA
-if BUILD_JAVA
-if HAVE_SCALA
-if BUILD_SCALA
-
-examples/%.class: examples/%.scala
- $(SCALAC) -cp ../Java/QuantLib.jar -language:postfixOps examples/$*.scala
-
-.PHONY: $(EXAMPLES)
-
-check-local: $(EXAMPLES)
-
-$(EXAMPLES): $(EXAMPLES:%=examples/%.class)
- LD_LIBRARY_PATH=../Java $(SCALA) -cp ".:../Java/QuantLib.jar" examples.$@
-
-EXTRA_DIST = README.txt
-
-endif
-endif
-endif
-endif
-
-
-dist-hook:
- mkdir -p $(distdir)/examples
- cp ./examples/*.scala $(distdir)/examples
-
-clean-local:
- rm -f examples/*.class
diff --git a/Scala/README.txt b/Scala/README.txt
deleted file mode 100644
index c00e909f..00000000
--- a/Scala/README.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-QuantLib-Scala interface uses (or more precise is) the QuantLib-Java module.
-
-Instructions for building the QuantLib-Java module under Eclipse are
-available at
-.
-
-On Linux systems, the module can be build by supplying the location of
-the JDK to configure, as in (for example)
-
-./configure --with-jdk-include=/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include \
- --with-jdk-system-include=usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux
-
-and by running 'make' afterwards.
-
diff --git a/Scala/examples/CPIBond.scala b/Scala/examples/CPIBond.scala
deleted file mode 100644
index 9a6cc784..00000000
--- a/Scala/examples/CPIBond.scala
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- Copyright (C) 2014 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.Month._
-import org.quantlib.{Array => QArray, _}
-
-case class Datum(date: Date, rate: Double)
-
-object CPIBond {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI")
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- doIt
- }
-
- def doIt() = {
- val startTime = System.currentTimeMillis
-
- val calendar = new UnitedKingdom()
- val dayCounter = new ActualActual(ActualActual.Convention.ISDA);
- val convention = BusinessDayConvention.ModifiedFollowing
-
- val today = new Date(25, November, 2009)
- val evaluationDate = calendar.adjust(today)
- Settings.instance().setEvaluationDate(evaluationDate)
-
- val yTS = new YieldTermStructureHandle(
- new FlatForward(evaluationDate, 0.05, dayCounter))
-
- val from = new Date(20, July, 2007);
- val to = new Date(20, November, 2009);
- val tenor = new Period(1, TimeUnit.Months)
- val rpiSchedule = new Schedule(from, to, tenor, calendar,
- convention, convention,
- DateGeneration.Rule.Backward, false)
-
- val cpiTS = new RelinkableZeroInflationTermStructureHandle
- val inflationIndex = new UKRPI(false, cpiTS)
- val fixData = Array(206.1, 207.3, 208.0, 208.9, 209.7, 210.9,
- 209.8, 211.4, 212.1, 214.0, 215.1, 216.8,
- 216.5, 217.2, 218.4, 217.7, 216,
- 212.9, 210.1, 211.4, 211.3, 211.5,
- 212.8, 213.4, 213.4, 213.4, 214.4)
-
- for (i <- 0 until fixData.size) {
- inflationIndex.addFixing(rpiSchedule.date(i), fixData(i))
- }
-
- val observationLag = new Period(2, TimeUnit.Months)
- val zciisData = Array(
- Datum(new Date(25, November, 2010), 3.0495 ),
- Datum(new Date(25, November, 2011), 2.93 ),
- Datum(new Date(26, November, 2012), 2.9795 ),
- Datum(new Date(25, November, 2013), 3.029 ),
- Datum(new Date(25, November, 2014), 3.1425 ),
- Datum(new Date(25, November, 2015), 3.211 ),
- Datum(new Date(25, November, 2016), 3.2675 ),
- Datum(new Date(25, November, 2017), 3.3625 ),
- Datum(new Date(25, November, 2018), 3.405 ),
- Datum(new Date(25, November, 2019), 3.48 ),
- Datum(new Date(25, November, 2021), 3.576 ),
- Datum(new Date(25, November, 2024), 3.649 ),
- Datum(new Date(26, November, 2029), 3.751 ),
- Datum(new Date(27, November, 2034), 3.77225),
- Datum(new Date(25, November, 2039), 3.77 ),
- Datum(new Date(25, November, 2049), 3.734 ),
- Datum(new Date(25, November, 2059), 3.714 )
- )
-
- val zeroSwapHelpers = new ZeroHelperVector
- zciisData map { datum => zeroSwapHelpers add
- new ZeroCouponInflationSwapHelper(
- new QuoteHandle(new SimpleQuote(datum.rate/100d)), observationLag,
- datum.date, calendar, convention, dayCounter, inflationIndex,
- CPI.InterpolationType.AsIndex, yTS) }
-
- cpiTS linkTo new PiecewiseZeroInflation(
- evaluationDate, calendar, dayCounter, observationLag,
- inflationIndex.frequency, zciisData(0).rate/100d, zeroSwapHelpers)
-
- val notional = 1000000d;
-
- val fixedRates = new DoubleVector()
- fixedRates add 0.1
-
- val fixedDayCounter = new Actual365Fixed
- val fixedPaymentConvention = BusinessDayConvention.ModifiedFollowing
- val fixedPaymentCalendar = new UnitedKingdom
- val contractObservationLag = new Period(3, TimeUnit.Months)
- val observationInterpolation = CPI.InterpolationType.Flat
- val settlementDays = 3
- val growthOnly = true
-
- val baseCPI = 206.1
- val startDate = new Date(2, October, 2007)
- val endDate = new Date(2, October, 2052)
-
- val fixedSchedule = new Schedule(startDate, endDate,
- new Period(6, TimeUnit.Months), fixedPaymentCalendar,
- BusinessDayConvention.Unadjusted,
- BusinessDayConvention.Unadjusted,
- DateGeneration.Rule.Backward, false)
-
- val bond = new CPIBond(settlementDays, notional, growthOnly,
- baseCPI, contractObservationLag,
- inflationIndex, observationInterpolation,
- fixedSchedule, fixedRates, fixedDayCounter,
- fixedPaymentConvention, new Date)
-
- bond setPricingEngine new DiscountingBondEngine(yTS)
- println("clean price: " + bond.cleanPrice + " \t exec time: " +
- (System.currentTimeMillis - startTime)/1000d)
-
- cpiTS reset // break cyclic reference between cpiTS, zeroSwapHelpers and inflationIndex
- }
-}
\ No newline at end of file
diff --git a/Scala/examples/EquityOptions.scala b/Scala/examples/EquityOptions.scala
deleted file mode 100644
index 998b1d51..00000000
--- a/Scala/examples/EquityOptions.scala
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- Copyright (C) 2011 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import scala.actors.Actor
-import org.quantlib.{Array => QArray, _}
-
-
-/**
- * EquityOption Test app - simple multithreading Scala version of
- * QuantLib/Examples/EquityOption
- * to illustrate use of Quantlib through supplied SWIG interfaces.
- *
- * You need to run this using the Java Jar file and JNI library
- */
-
-
-class VanillaPricingService(payoff: PlainVanillaPayoff,
- exercise: Exercise) extends Actor {
- start()
-
- def act() {
- react {
- case (engine: PricingEngine) => {
-
- // copy instrument data to ensure thread safe execution
-
- val t = exercise exerciseType match {
- case Exercise.Type.European => new EuropeanExercise(
- exercise.dates().get(0))
- case Exercise.Type.Bermudan => new BermudanExercise(
- exercise.dates());
- case Exercise.Type.American =>
- new AmericanExercise(
- exercise.dates get 0, exercise.dates().get(
- (exercise.dates.size() - 1).toInt))
- }
- val instrument = new VanillaOption(
- new PlainVanillaPayoff(payoff.optionType, payoff.strike),
- exercise)
- instrument.setPricingEngine(engine)
- reply(instrument.NPV())
- }
- }
- }
-}
-
-object SimpleFactory {
- val optionType = Option.Type.Put
- val strike = 40.0
- val underlying = 36.0
- val riskFreeRate = 0.06
- val dividendYield = 0.00
- val volatility = 0.2
-
- val calendar = new TARGET()
- val dayCounter = new Actual365Fixed()
- val settlementDate = new Date(17, Month.May, 1998)
-
- def bsProcess() : BlackScholesMertonProcess = {
- val flatVolatility = new BlackVolTermStructureHandle(
- new BlackConstantVol(settlementDate, calendar,
- volatility, dayCounter))
- new BlackScholesMertonProcess(spot, divYield,
- rTS, flatVolatility)
- }
-
- def hestonProcess() : HestonProcess = {
- new HestonProcess(rTS, divYield, spot, volatility*volatility,
- 1.0, volatility*volatility, 0.0001, 0.0)
- }
-
- def batesProcess() : BatesProcess = {
- new BatesProcess(rTS, divYield, spot, volatility*volatility,
- 1.0, volatility*volatility, 0.0001, 0.0,
- 1e-14, 1e-14, 1e-14)
- }
- private def rTS : YieldTermStructureHandle = {
- new YieldTermStructureHandle(
- new FlatForward(settlementDate, riskFreeRate, dayCounter))
- }
- private def divYield : YieldTermStructureHandle = {
- new YieldTermStructureHandle(
- new FlatForward(settlementDate, dividendYield, dayCounter))
- }
- private def spot : QuoteHandle = {
- new QuoteHandle(new SimpleQuote(underlying))
- }
-}
-
-object EquityOptions {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI");
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- val beginTime = System.currentTimeMillis()
-
- val optionType = Option.Type.Put
- val strike = 40.0
- val todaysDate = new Date(15, Month.May, 1998)
- val settlementDate = SimpleFactory.settlementDate
- Settings.instance setEvaluationDate todaysDate
-
- val maturity = new Date(17, Month.May, 1999)
- val dayCounter = new Actual365Fixed()
- val calendar = new TARGET()
-
- // define European, Bermudan, and American exercises
- val exerciseDates = new DateVector()
- (1 to 4).foreach(i => exerciseDates add settlementDate.
- add(new Period(3*i, TimeUnit.Months)))
-
- val europeanExercise = new EuropeanExercise(maturity)
- val bermudanExercise = new BermudanExercise(exerciseDates)
- val americanExercise = new AmericanExercise(settlementDate, maturity)
-
- val payoff = new PlainVanillaPayoff(optionType, strike)
-
- // Black-Scholes for European
- val analyticEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new AnalyticEuropeanEngine(SimpleFactory.bsProcess())
-
- val hestonModel = new HestonModel(SimpleFactory.hestonProcess())
-
- // Heston for European
- val analyticHestonNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new AnalyticHestonEngine(new HestonModel(
- SimpleFactory.hestonProcess()))
-
- val fdEuropeanHestonNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new FdHestonVanillaEngine(new HestonModel(
- SimpleFactory.hestonProcess()), 50, 150)
-
- val fdAmericanHestonNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new FdHestonVanillaEngine(new HestonModel(
- SimpleFactory.hestonProcess()), 100, 150)
-
- val fdBermudanHestonNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new FdHestonVanillaEngine(new HestonModel(
- SimpleFactory.hestonProcess()), 100, 150)
-
- val batesModel = new BatesModel(SimpleFactory.batesProcess())
-
- val cosHestonNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new COSHestonEngine(new HestonModel(
- SimpleFactory.hestonProcess()))
-
- // Bates for European
- val analyticBatesNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BatesEngine(new BatesModel(
- SimpleFactory.batesProcess()))
-
- val fdEuropeanBatesNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new FdBatesVanillaEngine(new BatesModel(
- SimpleFactory.batesProcess()), 50, 150)
-
- val fdAmericanBatesNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new FdBatesVanillaEngine(new BatesModel(
- SimpleFactory.batesProcess()))
-
- val fdBermudanBatesNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new FdBatesVanillaEngine(new BatesModel(
- SimpleFactory.batesProcess()))
-
- // Barone-Adesi and Whaley approximation for American
- val baroneAdesiWhaleyNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BaroneAdesiWhaleyApproximationEngine(SimpleFactory.bsProcess())
-
- // Bjerksund and Stensland approximation for American
- val bjerksundStenslandNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BjerksundStenslandApproximationEngine(SimpleFactory.bsProcess())
-
- // Integral
- val integralNpv = new VanillaPricingService(payoff,europeanExercise) !!
- new IntegralEngine(SimpleFactory.bsProcess())
-
- // Finite Difference
- var timeSteps : Int = 801;
- val fdEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new FdBlackScholesVanillaEngine(SimpleFactory.bsProcess(),
- timeSteps, timeSteps-1)
- val fdBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new FdBlackScholesVanillaEngine(SimpleFactory.bsProcess(),
- timeSteps, timeSteps-1)
- val fdAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new FdBlackScholesVanillaEngine(SimpleFactory.bsProcess(),
- timeSteps, timeSteps-1)
-
- // Binomial method
- val jarrowRuddEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialJRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val jarrowRuddBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialJRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val jarrowRuddAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialJRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val coxRossRubinsteinEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialCRRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val coxRossRubinsteinBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialCRRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val coxRossRubinsteinAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialCRRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val additiveEqpEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialEQPVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val additiveEqpBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialEQPVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val additiveEqpAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialEQPVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val trigeirgisEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialTrigeorgisVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val trigeirgisBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialTrigeorgisVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val trigeirgisAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialTrigeorgisVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val tianEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialTianVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val tianBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialTianVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val tianAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialTianVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val leisenReimerEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialTianVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val leisenReimerBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialLRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val leisenReimerAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialLRVanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val joshiEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new BinomialJ4VanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val joshiBermudanNpv =
- new VanillaPricingService(payoff, bermudanExercise) !!
- new BinomialJ4VanillaEngine(SimpleFactory.bsProcess(), timeSteps)
- val joshiAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new BinomialJ4VanillaEngine(SimpleFactory.bsProcess(), timeSteps)
-
- // Monte-Carlo methods
- timeSteps = 1;
- val americanTimeSteps = 25
- val mcSeed = 42;
- val nSamples = 32768; // 2^15
- val maxSamples = 1048576; // 2^20
-
- val pseudoMcEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new MCPREuropeanEngine(SimpleFactory.bsProcess(),
- timeSteps,
- QuantLib.nullInt(),
- true, false,
- nSamples, 0.02, maxSamples, mcSeed)
-
- val pseudoMcAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new MCPRAmericanEngine(SimpleFactory.bsProcess(),
- americanTimeSteps,
- QuantLib.nullInt(),
- true, false,
- nSamples, 0.02, maxSamples, mcSeed)
-
- val quasiMcEuropeanNpv =
- new VanillaPricingService(payoff, europeanExercise) !!
- new MCLDEuropeanEngine(SimpleFactory.bsProcess(),
- timeSteps,
- QuantLib.nullInt(),
- false, false,
- nSamples, 0.02, maxSamples, mcSeed)
-
- val quasiMcAmericanNpv =
- new VanillaPricingService(payoff, americanExercise) !!
- new MCLDAmericanEngine(SimpleFactory.bsProcess(),
- americanTimeSteps,
- QuantLib.nullInt(),
- true, false,
- nSamples, 0.02, maxSamples, mcSeed)
-
-
- // write column headings
- printf("\n%-35s %-14s %-14s %-14s\n" + "="*76+ "\n",
- "Method", "European", "Bermudan", "American")
-
- val fmt = "%34s %13.9f %13.9f %13.9f\n";
- printf(fmt, "Black-Scholes", analyticEuropeanNpv(),
- Double.NaN, Double.NaN)
- printf(fmt, "Heston Semi-Analytic", analyticHestonNpv(),
- Double.NaN, Double.NaN)
- printf(fmt, "Heston Finite-Difference",
- fdEuropeanHestonNpv(), fdBermudanHestonNpv(), fdAmericanHestonNpv())
- printf(fmt, "COS Heston Method", cosHestonNpv(),
- Double.NaN, Double.NaN)
- printf(fmt, "Bates Semi-Analytic", analyticBatesNpv(),
- Double.NaN, Double.NaN)
- printf(fmt, "Bates Finite-Difference",
- fdEuropeanBatesNpv(), fdBermudanBatesNpv(), fdAmericanBatesNpv())
- printf(fmt, "Barone-Adesi/Whaley", Double.NaN, Double.NaN,
- baroneAdesiWhaleyNpv());
- printf(fmt, "Bjerksund/Stensland", Double.NaN, Double.NaN,
- bjerksundStenslandNpv())
- printf(fmt, "Integral", integralNpv(),
- Double.NaN, Double.NaN)
- printf(fmt, "Finite differences", fdEuropeanNpv(),fdBermudanNpv(),
- fdAmericanNpv())
- printf(fmt, "Binomial Jarrow-Rudd",jarrowRuddEuropeanNpv(),
- jarrowRuddBermudanNpv(),jarrowRuddAmericanNpv())
- printf(fmt, "Binomial Cox-Ross-Rubinstein",
- coxRossRubinsteinEuropeanNpv(),
- coxRossRubinsteinBermudanNpv(),
- coxRossRubinsteinAmericanNpv())
- printf(fmt, "Additive equiprobabilities",additiveEqpEuropeanNpv(),
- additiveEqpBermudanNpv(),additiveEqpAmericanNpv())
- printf(fmt, "Binomial Trigeorgis", trigeirgisEuropeanNpv(),
- trigeirgisBermudanNpv(),trigeirgisAmericanNpv())
- printf(fmt, "Binomial Tian", tianEuropeanNpv(),
- tianBermudanNpv(),tianAmericanNpv())
- printf(fmt, "Binomial Leisen-Reimer", leisenReimerEuropeanNpv(),
- leisenReimerBermudanNpv(), leisenReimerAmericanNpv())
- printf(fmt, "Binomial Joshi", joshiEuropeanNpv(),
- joshiBermudanNpv(), joshiAmericanNpv())
- printf(fmt, "MC (crude)", pseudoMcEuropeanNpv(),
- Double.NaN, pseudoMcAmericanNpv())
- printf(fmt, "MC (Sobol)", quasiMcEuropeanNpv(),
- Double.NaN, quasiMcAmericanNpv())
-
- val msecs = (System.currentTimeMillis()-beginTime)
- println("Run completed in "+msecs+" ms.")
- }
-}
-
diff --git a/Scala/examples/HestonModelCalibration.scala b/Scala/examples/HestonModelCalibration.scala
deleted file mode 100644
index 947a6d57..00000000
--- a/Scala/examples/HestonModelCalibration.scala
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- Copyright (C) 2012 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-object HestonModelCalibration {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI")
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- val calendar = new TARGET();
- val dayCounter = new Actual365Fixed();
- val settlementDate = new Date(5, Month.July, 2002);
- Settings.instance setEvaluationDate settlementDate
-
- val rates = new DoubleVector()
- List(0.0357,0.0357,0.0349,0.0341,0.0355,
- 0.0359,0.0368,0.0386,0.0401).foreach(i => rates.add(i))
-
- val dates = new DateVector()
- val maturityInDays = Vector(0, 13, 41, 75, 165, 256, 345, 524, 703)
- maturityInDays.foreach(i => dates.add(settlementDate.add(i)))
-
- val rTS = new YieldTermStructureHandle(
- new ZeroCurve(dates, rates, dayCounter))
-
- val divTS = new YieldTermStructureHandle(
- new FlatForward(settlementDate, 0.0, dayCounter))
-
- val s0 = new QuoteHandle(new SimpleQuote(4468.17))
-
- val vols = Vector(
- 0.6625,0.4875,0.4204,0.3667,0.3431,0.3267,0.3121,0.3121,
- 0.6007,0.4543,0.3967,0.3511,0.3279,0.3154,0.2984,0.2921,
- 0.5084,0.4221,0.3718,0.3327,0.3155,0.3027,0.2919,0.2889,
- 0.4541,0.3869,0.3492,0.3149,0.2963,0.2926,0.2819,0.2800,
- 0.4060,0.3607,0.3330,0.2999,0.2887,0.2811,0.2751,0.2775,
- 0.3726,0.3396,0.3108,0.2781,0.2788,0.2722,0.2661,0.2686,
- 0.3550,0.3277,0.3012,0.2781,0.2781,0.2661,0.2661,0.2681,
- 0.3428,0.3209,0.2958,0.2740,0.2688,0.2627,0.2580,0.2620,
- 0.3302,0.3062,0.2799,0.2631,0.2573,0.2533,0.2504,0.2544,
- 0.3343,0.2959,0.2705,0.2540,0.2504,0.2464,0.2448,0.2462,
- 0.3460,0.2845,0.2624,0.2463,0.2425,0.2385,0.2373,0.2422,
- 0.3857,0.2860,0.2578,0.2399,0.2357,0.2327,0.2312,0.2351,
- 0.3976,0.2860,0.2607,0.2356,0.2297,0.2268,0.2241,0.2320 )
-
- val strikes = Vector(
- 3400,3600,3800,4000,4200,4400,4500,4600,4800,5000,5200,5400,5600)
-
- val v0 = 0.1
- val kappa= 1.0
- val theta= 0.1
- val sigma= 0.5
- val rho = -0.5
-
- val hestonProcess = new HestonProcess(rTS, divTS, s0, v0,
- kappa, theta, sigma, rho)
-
- val hestonModel = new HestonModel(hestonProcess)
- val analyticHestonEngine = new AnalyticHestonEngine(hestonModel, 64);
-
-
- val calibrationHelpers = new CalibrationHelperVector()
-
- for (s <- (0 to 12)) {
- for (m <- (1 to 8)) {
- val vol = new QuoteHandle(new SimpleQuote(vols(s*8+m-1)))
- val maturityInWeeks = ((maturityInDays(m)+3)/7d).toInt
- val maturity = new Period(maturityInWeeks, TimeUnit.Weeks)
-
- val helper = new HestonModelHelper(
- maturity, calendar, s0.value,
- strikes(s), vol, rTS, divTS,
- BlackCalibrationHelper.CalibrationErrorType.ImpliedVolError)
-
- helper setPricingEngine(analyticHestonEngine)
-
- calibrationHelpers.add(helper)
- }
- }
-
- val helpers = for (i <- 0 until calibrationHelpers.size().toInt)
- yield(calibrationHelpers.get(i))
-
- val optimizerMethod = new LevenbergMarquardt(1e-8, 1e-8, 1e-8)
- hestonModel.calibrate(calibrationHelpers, optimizerMethod,
- new EndCriteria(400, 40, 1.0e-8, 1.0e-8, 1.0e-8))
-
- val sse = helpers map {h => 100*h.calibrationError} map {e => e*e} sum;
- printf("error= %f\n",sse)
-
- val params = hestonModel.params
- printf("v0 = %f\n",params.get(4))
- printf("kappa= %f\n",params.get(1))
- printf("theta= %f\n",params.get(0))
- printf("sigma= %f\n",params.get(2))
- printf("rho = %f\n", params.get(3))
- }
-}
diff --git a/Scala/examples/HestonMonteCarlo.scala b/Scala/examples/HestonMonteCarlo.scala
deleted file mode 100644
index 46f3f854..00000000
--- a/Scala/examples/HestonMonteCarlo.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2012 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-object HestonMonteCarlo {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI")
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- val dayCounter = new ActualActual(ActualActual.Convention.ISDA);
- val settlementDate = new Date(27, Month.December, 2004)
- Settings.instance setEvaluationDate settlementDate
-
- val exerciseDate = new Date(28, Month.March, 2005)
- val maturity = dayCounter.yearFraction(settlementDate, exerciseDate)
-
- val payoff = new PlainVanillaPayoff(Option.Type.Call, 1.05)
- val exercise = new EuropeanExercise(exerciseDate)
- val vanillaOption = new VanillaOption(payoff, exercise)
-
- val rTS = new YieldTermStructureHandle(
- new FlatForward(settlementDate, 0.0225, dayCounter))
-
- val divTS = new YieldTermStructureHandle(
- new FlatForward(settlementDate, 0.02, dayCounter))
-
- val s0 = new QuoteHandle(new SimpleQuote(1.0))
-
- val v0 = 0.1
- val kappa = 3.16
- val theta = 0.09
- val sigma = 0.4
- val rho = -0.2
-
- val hestonProcess = new HestonProcess(rTS, divTS, s0, v0,
- kappa, theta, sigma, rho)
-
- val hestonModel = new HestonModel(hestonProcess)
- val analyticEngine = new AnalyticHestonEngine(hestonModel)
- vanillaOption.setPricingEngine(analyticEngine)
-
- val timeSteps = 10
- val grsg = new GaussianRandomSequenceGenerator(
- new UniformRandomSequenceGenerator(
- 2*timeSteps, new UniformRandomGenerator(1234)))
-
- val grid = new TimeGrid(maturity, timeSteps)
- val times = new DoubleVector()
- (0L until grid.getSize).foreach(i => times add(grid elementAt i))
- val gen = new GaussianMultiPathGenerator(hestonProcess, times, grsg)
-
- val stat = new IncrementalStatistics()
- for (i <- (0 until 50000)) {
- stat.add(0.5*( payoff.getValue(gen.next.value at 0 back)
- +payoff.getValue(gen.antithetic.value at 0 back())))
- }
-
- printf("Semi-Analytic: %f\n", vanillaOption.NPV())
- printf("Monte-Carlo : %f +/-%f\n", stat.mean(), stat.errorEstimate())
- }
-}
\ No newline at end of file
diff --git a/Scala/examples/ObserverPattern.scala b/Scala/examples/ObserverPattern.scala
deleted file mode 100644
index 8311c77f..00000000
--- a/Scala/examples/ObserverPattern.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (C) 2018 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-
-/**
- * Check the thread- and gc safeness of QL's observer pattern.
- * This program is likely to fail if QL was compiled with
- * QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN not being set.
- *
- * You need to run this using the Java Jar file and JNI library
- */
-
-
-object ObserverPattern {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI");
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
-
- val quote = new SimpleQuote(100d)
- (0 until 100).par.foreach{j =>
- (0 until 10000).par.foreach{i =>
- val underlying = new QuoteHandle(quote)
- quote.setValue(quote.value())
- if (i == 534) System.gc
- }
- }
- }
-}
-
diff --git a/Scala/examples/Optimizer.scala b/Scala/examples/Optimizer.scala
deleted file mode 100644
index 5061c4f3..00000000
--- a/Scala/examples/Optimizer.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 2015 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-object Optimizer {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI")
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- val costFunction = new CostFunctionDelegate {
- override def value(x: QArray) : Double = {
- val v = values(x)
- (0L until v.size()) map { i => v.get(i)*v.get(i) } sum
- }
-
- override def values(x: QArray): QArray = {
- val r = new QArray(2)
- r.set(0L, math.exp(x.get(0))-1d)
- r.set(1L, x.get(1) + x.get(0))
- r
- }
- }
-
- def optimize(m: OptimizationMethod, name: String) = {
- val result = new Optimizer().solve(costFunction, new NoConstraint, m,
- new EndCriteria(400, 40, 1.0e-8, 1.0e-8, 1.0e-8), new QArray(2L, 1d))
-
- println(name + "\t" + "%5.3g".format(costFunction.value(result)))
- }
-
- println("Optimization method Target value")
- optimize(new LevenbergMarquardt, "Levenberg-Marquardt")
- optimize(new Simplex(0.1), "Simplex ")
- optimize(new ConjugateGradient, "ConjugateGradient ")
- optimize(new SteepestDescent, "SteepestDescent ")
- optimize(new BFGS, "BFGS ")
- optimize(new DifferentialEvolution, "DifferentialEvolution")
- }
-}
\ No newline at end of file
diff --git a/Scala/examples/RandomNumbers.scala b/Scala/examples/RandomNumbers.scala
deleted file mode 100644
index 297e1db4..00000000
--- a/Scala/examples/RandomNumbers.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright (C) 2011 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-object RandomNumbers {
- def main(args: Array[String]) : Unit = {
-
- try {
- System.loadLibrary("QuantLibJNI")
- }
- catch {
- case ex: UnsatisfiedLinkError => {
- println("please check your LD_LIBRARY_PATH variable")
- throw ex
- }
- }
-
- val rng = new GaussianRandomGenerator(
- new UniformRandomGenerator(12345))
-
- val fmt = "%8d %10.6f %10.6f %10.6f %10.6f\n"
- printf(" #rngs\t mean(expected) error(expected)\tmean\t error\n");
- (1 to 10).foreach(i => {
- val nRngs = 1024*(1 << i)
- val st = new IncrementalStatistics()
-
- (0 until nRngs).foreach(_ => st.add(rng.nextValue()))
-
- printf(fmt, nRngs, 0.0, 1/scala.math.sqrt(nRngs),
- st.mean(), st.errorEstimate())
- } )
- }
-}
\ No newline at end of file
diff --git a/Scala/examples/Swing.scala b/Scala/examples/Swing.scala
deleted file mode 100644
index 7151afba..00000000
--- a/Scala/examples/Swing.scala
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2018 Klaus Spanderen
-
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- . The license is also available online at
- .
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
-*/
-
-package examples;
-
-import org.quantlib.{Array => QArray, _}
-
-object Swing {
- def main(args: Array[String]) : Unit = {
- val todaysDate = new Date(30, Month.September, 2018)
- val dc = new Actual365Fixed
-
- val riskFreeRate = new FlatForward(todaysDate, 0.0, dc)
- val dividendYield = new FlatForward(todaysDate, 0.0, dc)
-
- val underlying = new SimpleQuote(30.0)
- val vol = new BlackConstantVol(todaysDate, new TARGET, 0.20, dc)
-
- val exerciseDates = new DateVector
- (0 until 31).foreach(i => exerciseDates.add(
- new Date(1, Month.January, 2019).add(new Period(i, TimeUnit.Days))))
-
- val swingOption = new VanillaSwingOption(
- new VanillaForwardPayoff(Option.Type.Call, underlying.value),
- new SwingExercise(exerciseDates), 0, exerciseDates.size)
-
- val bsProcess = new BlackScholesMertonProcess(
- new QuoteHandle(underlying),
- new YieldTermStructureHandle(dividendYield),
- new YieldTermStructureHandle(riskFreeRate),
- new BlackVolTermStructureHandle(vol))
-
- swingOption.setPricingEngine(new FdSimpleBSSwingEngine(bsProcess))
-
- println(f"Black Scholes Price: ${swingOption.NPV}%2.4f")
-
-
- val x0 = 0d
- val x1 = 0d
-
- val beta = 4d
- val eta = 4d
- val jumpIntensity = 1d
- val speed = 1d
- val volatility = 0.1
-
- val curveShape = new DoublePairVector()
- (0 until exerciseDates.size.toInt).foreach{i =>
- val t = dc.yearFraction(todaysDate, exerciseDates.get(i))
- val gs = math.log(underlying.value) -
- volatility*volatility/(4*speed)*(1-math.exp(-2*speed*t)) -
- jumpIntensity/beta*math.log((eta-math.exp(-beta*t))/(eta-1.0))
-
- curveShape.add(new DoublePair(t, gs))
- }
-
- val ouProcess = new ExtendedOrnsteinUhlenbeckProcess(
- speed, volatility, x0, new UnaryFunctionDelegate() {
- override def value(x: Double): Double = x0
- })
-
- val jProcess = new ExtOUWithJumpsProcess(
- ouProcess, x1, beta, jumpIntensity, eta)
-
- swingOption.setPricingEngine(new FdSimpleExtOUJumpSwingEngine(
- jProcess, riskFreeRate, 25, 25, 200, curveShape))
-
- println(f"Kluge Model Price : ${swingOption.NPV}%2.4f")
- }
-}
diff --git a/acinclude.m4 b/acinclude.m4
deleted file mode 100644
index f331d7c1..00000000
--- a/acinclude.m4
+++ /dev/null
@@ -1,16 +0,0 @@
-AC_DEFUN([QL_CHECK_CXXFLAGS],
-[AC_MSG_CHECKING([whether $CXX accepts warning flags])
- AC_REQUIRE([AC_PROG_CC])
- ql_original_CXXFLAGS=$CXXFLAGS
- ql_more_CXXFLAGS="-fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings"
- CXXFLAGS="$ql_original_CXXFLAGS $ql_more_CXXFLAGS"
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[]],
- [[]])],
- [AC_MSG_RESULT([yes])
- AC_SUBST([CXXWARNINGFLAGS], [$ql_more_CXXFLAGS])],
- [AC_MSG_RESULT([no])
- ])
- CXXFLAGS="$ql_original_CXXFLAGS"
-])
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index aa44b100..00000000
--- a/autogen.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# Run this to generate all the auto-generated files needed by the GNU
-# configure program
-
-autoreconf --force --install
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 36452e86..00000000
--- a/configure.ac
+++ /dev/null
@@ -1,171 +0,0 @@
-# Process this file with autoconf to produce a configure script.
-AC_INIT([QuantLib-SWIG], [1.33],
- [quantlib-dev@lists.sourceforge.net],
- [QuantLib-SWIG])
-AC_PREREQ(2.50)
-AC_CONFIG_AUX_DIR([config])
-AM_INIT_AUTOMAKE([foreign])
-
-AC_COPYRIGHT([Copyright (C) 2005, 2006, 2007, 2008 StatPro Italia srl
-
-This file is part of QuantLib, a free-software/open-source library
-for financial quantitative analysts and developers - http://quantlib.org/
-
-QuantLib is free software: you can redistribute it and/or modify it
-under the terms of the QuantLib license. You should have received a
-copy of the license along with this program; if not, please email
-. The license is also available online at
-.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the license for more details.])
-
-# check target
-AC_MSG_CHECKING([system])
-target=`uname`
-AC_MSG_RESULT([$target])
-
-# check compiler
-AC_LANG([C++])
-
-QL_CHECK_CXXFLAGS
-
-# check for QuantLib
-AC_MSG_CHECKING([for QuantLib])
-ql_version=`quantlib-config --version`
-AC_MSG_RESULT([$ql_version])
-
-# check for tools
-AC_PATH_PROG([SWIG], [swig])
-if test "x$SWIG" != x; then
- SWIG_VERSION=`swig -version 2>&1|grep Version|cut -d" " -f3`
- SWIG_MAJOR=${SWIG_VERSION%%.*}
- if test ${SWIG_MAJOR} = "2"; then
- AC_MSG_WARN([You have SWIG $SWIG_VERSION installed, but at least SWIG 3.0.1 is recommended. Some features may not work. ])
- #SWIG=
- fi
-fi
-
-AC_PATH_PROG([PYTHON], [python3 python])
-AM_CONDITIONAL(HAVE_PYTHON, test "x${PYTHON}" != "x")
-AC_ARG_ENABLE([python],
- AS_HELP_STRING([--disable-python],
- [If disabled, the Python module
- will not be built]),
- [build_python=$enableval],
- [build_python=yes])
-AM_CONDITIONAL(BUILD_PYTHON, test "$build_python" != "no")
-
-AC_PATH_PROGS([DOTNET], [dotnet])
-AM_CONDITIONAL(HAVE_DOTNET, test "x${DOTNET}" != "x")
-AC_ARG_ENABLE([csharp],
- AS_HELP_STRING([--disable-csharp],
- [If disabled, the C# module
- will not be built]),
- [build_dotnet=$enableval],
- [build_dotnet=yes])
-AM_CONDITIONAL(BUILD_DOTNET, test "$build_dotnet" != "no")
-
-AC_PATH_PROG([R], [R])
-AM_CONDITIONAL(HAVE_R, test "x${R}" != "x")
-AC_ARG_ENABLE([r],
- AS_HELP_STRING([--disable-r],
- [If disabled, the R module
- will not be built]),
- [build_r=$enableval],
- [build_r=yes])
-AM_CONDITIONAL(BUILD_R, test "$build_r" != "no")
-# sanitized version for stricter R checks
-AC_SUBST([PACKAGE_VERSION_FOR_R],["${PACKAGE_VERSION%-*}"])
-
-AC_PATH_PROG([JAVAC], [javac])
-AC_PATH_PROG([JAR], [jar])
-AC_PATH_PROG([JAVA], [java])
-AM_CONDITIONAL(HAVE_JAVA, test "x${JAVAC}" != "x" && test "x${JAR}" != "x")
-AC_ARG_ENABLE([java],
- AS_HELP_STRING([--disable-java],
- [If disabled, the Java module
- will not be built]),
- [build_java=$enableval],
- [build_java=yes])
-AM_CONDITIONAL(BUILD_JAVA, test "$build_java" != "no")
-AC_ARG_ENABLE([java-autoload],
- AS_HELP_STRING([--disable-java-autoload],
- [If disabled, the Java JNI shared library
- will not be automatically loaded]),
- [java_autoload=$enableval],
- [java_autoload=yes])
-AM_CONDITIONAL(JAVA_AUTOLOAD, test "$java_autoload" != "no")
-
-AC_ARG_ENABLE([java-finalizer],
- AS_HELP_STRING([--disable-java-finalizer],
- [If disabled, the finalizers
- will not be generated. Be careful.]),
- [java_finalizer=$enableval],
- [java_finalizer=yes])
-AM_CONDITIONAL(JAVA_FINALIZER, test "$java_finalizer" != "no")
-
-AC_ARG_ENABLE([java-autocloseable],
- AS_HELP_STRING([--enable-java-autocloseable],
- [If enabled, the java Objects will implement AutoCloseable]),
- [java_autocloseable=$enableval],
- [java_autocloseable=no])
-AM_CONDITIONAL(JAVA_AUTOCLOSEABLE, test "$java_autocloseable" != "no")
-
-
-AC_ARG_WITH([jdk-include],
- AS_HELP_STRING([--with-jdk-include=INCLUDE_PATH],
- [Supply the location of JDK header files]),
- [ql_jdk_include_path="`cd ${withval} 2>/dev/null && pwd`"],
- [ql_jdk_include_path=""])
-if test [ -n "$ql_jdk_include_path" ] ; then
- AC_SUBST([JDK_INCLUDE],["-I${ql_jdk_include_path}"])
-fi
-AC_ARG_WITH([jdk-system-include],
- AS_HELP_STRING([--with-jdk-system-include=INCLUDE_PATH],
- [Supply the location of system-dependent JDK header files]),
- [ql_jdk_sys_include_path="`cd ${withval} 2>/dev/null && pwd`"],
- [ql_jdk_sys_include_path=""])
-if test [ -n "$ql_jdk_sys_include_path" ] ; then
- AC_SUBST([JDK_SYSTEM_INCLUDE],["-I${ql_jdk_sys_include_path}"])
-fi
-
-
-AC_PATH_PROG([SCALAC], [scalac])
-AC_PATH_PROG([SCALA], [scala])
-AM_CONDITIONAL(HAVE_SCALA, test "x${SCALAC}" != "x" && test "x${JAR}" != "x")
-AC_ARG_ENABLE([scala],
- AS_HELP_STRING([--disable-scala],
- [If disabled, the scala examples
- will not be built]),
- [build_scala=$enableval],
- [build_scala=yes])
-AM_CONDITIONAL(BUILD_SCALA, test "$build_scala" != "no")
-
-# flags
-
-case "$target" in
-Darwin)
- AC_SUBST([SHARED_LIB],[${SHARED_LIB='-dynamiclib'}])
- AC_SUBST([SHARED_LIB_EXTENSION],[${SHARED_LIB_EXTENSION='dylib'}])
- AC_SUBST([JNILIB_EXTENSION],[${JNILIB_EXTENSION='jnilib'}]) ;;
-*)
- AC_SUBST([SHARED_LIB],[${SHARED_LIB='-shared'}])
- AC_SUBST([SHARED_LIB_EXTENSION],[${SHARED_LIB_EXTENSION='so'}])
- AC_SUBST([JNILIB_EXTENSION],[${JNILIB_EXTENSION='so'}]) ;;
-esac
-
-
-# done, output the configured files
-AC_CONFIG_FILES([
- Makefile
- CSharp/Makefile
- Java/Makefile
- Python/Makefile
- Python/setup.py
- R/Makefile
- R/DESCRIPTION
- Scala/Makefile])
-AC_OUTPUT
-
diff --git a/dockerfiles/ci.base.Dockerfile b/dockerfiles/ci.base.Dockerfile
deleted file mode 100644
index 5da231b4..00000000
--- a/dockerfiles/ci.base.Dockerfile
+++ /dev/null
@@ -1,24 +0,0 @@
-ARG tag=rolling
-FROM ghcr.io/lballabio/quantlib-devenv:${tag}
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN apt-get update \
- && DEBIAN_FRONTEND=noninteractive apt-get install -y libpcre2-dev \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
-
-ENV swig_version=4.1.1
-
-RUN wget http://downloads.sourceforge.net/project/swig/swig/swig-${swig_version}/swig-${swig_version}.tar.gz \
- && tar xfz swig-${swig_version}.tar.gz \
- && rm swig-${swig_version}.tar.gz \
- && cd swig-${swig_version} \
- && ./configure --prefix=/usr CXXFLAGS=-O3 \
- && make -j 4 && make install \
- && cd .. && rm -rf swig-${swig_version}
-
-RUN mkdir /QuantLib
-COPY QuantLib /QuantLib
-
-CMD bash
diff --git a/dockerfiles/ci.csharp.Dockerfile b/dockerfiles/ci.csharp.Dockerfile
deleted file mode 100644
index e49ff52b..00000000
--- a/dockerfiles/ci.csharp.Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:threadsafe
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN cd /tmp \
- && wget https://dot.net/v1/dotnet-install.sh \
- && bash dotnet-install.sh --install-dir /usr/local/bin/ -c 6.0
diff --git a/dockerfiles/ci.default.Dockerfile b/dockerfiles/ci.default.Dockerfile
deleted file mode 100644
index 2607f6d5..00000000
--- a/dockerfiles/ci.default.Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:base
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN cd /QuantLib \
- && ./autogen.sh \
- && ./configure --enable-throwing-in-cycles --enable-unity-build --disable-static --disable-test-suite --enable-skip-examples CC=clang CXX=clang++ CXXFLAGS='-O3 -g0' \
- && make -j 4 install \
- && cd .. && rm -rf /QuantLib
-
-RUN ldconfig
-
-CMD bash
diff --git a/dockerfiles/ci.java.Dockerfile b/dockerfiles/ci.java.Dockerfile
deleted file mode 100644
index d5b9b211..00000000
--- a/dockerfiles/ci.java.Dockerfile
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:threadsafe
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN apt-get update \
- && DEBIAN_FRONTEND=noninteractive apt-get install -y default-jdk \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
-
diff --git a/dockerfiles/ci.python.Dockerfile b/dockerfiles/ci.python.Dockerfile
deleted file mode 100644
index 90253252..00000000
--- a/dockerfiles/ci.python.Dockerfile
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:default
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN apt-get update \
- && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-dev python3-pip python3-venv \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
diff --git a/dockerfiles/ci.r.Dockerfile b/dockerfiles/ci.r.Dockerfile
deleted file mode 100644
index ea67a63d..00000000
--- a/dockerfiles/ci.r.Dockerfile
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:default
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN apt-get update \
- && DEBIAN_FRONTEND=noninteractive apt-get install -y r-base-dev texlive \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
-
diff --git a/dockerfiles/ci.scala.Dockerfile b/dockerfiles/ci.scala.Dockerfile
deleted file mode 100644
index 64be030e..00000000
--- a/dockerfiles/ci.scala.Dockerfile
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:java
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN apt-get update \
- && DEBIAN_FRONTEND=noninteractive apt-get install -y scala \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
-
diff --git a/dockerfiles/ci.threadsafe.Dockerfile b/dockerfiles/ci.threadsafe.Dockerfile
deleted file mode 100644
index 2af6507d..00000000
--- a/dockerfiles/ci.threadsafe.Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM ghcr.io/lballabio/quantlib-swig-devenv:base
-MAINTAINER Luigi Ballabio
-LABEL Description="A development environment for building QuantLib-SWIG on Travis CI"
-
-RUN cd /QuantLib \
- && ./autogen.sh \
- && ./configure --enable-thread-safe-observer-pattern --enable-throwing-in-cycles --enable-unity-build --disable-static --disable-test-suite --enable-skip-examples CC=clang CXX=clang++ CXXFLAGS='-O3 -g0' \
- && make -j 4 install \
- && cd .. && rm -rf /QuantLib
-
-RUN ldconfig
-
-CMD bash
diff --git a/lib/QuantLib-Risks-Cpp b/lib/QuantLib-Risks-Cpp
new file mode 160000
index 00000000..7aeba1d3
--- /dev/null
+++ b/lib/QuantLib-Risks-Cpp
@@ -0,0 +1 @@
+Subproject commit 7aeba1d3b83fda5286020cc9d2ca206a8f9bed69
diff --git a/lib/quantlib-xad b/lib/quantlib-xad
deleted file mode 160000
index 646fc90b..00000000
--- a/lib/quantlib-xad
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 646fc90ba9f0e4e2287fec83ccd00e1b91659619
diff --git a/tools/check_copyrights.sh b/tools/check_copyrights.sh
deleted file mode 100755
index 97ca7d28..00000000
--- a/tools/check_copyrights.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-#
-# Run this from the main QuantLib-SWIG directory
-
-grep -rI --exclude='Makefile*' "Copyright \(.*\)" CSharp Java Python R Scala SWIG | ./tools/collect_copyrights.py > LICENSE.TXT
-
diff --git a/tools/collect_copyrights.py b/tools/collect_copyrights.py
deleted file mode 100755
index 331f3ac6..00000000
--- a/tools/collect_copyrights.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/python
-
-import re
-import sys
-
-regex1 = re.compile(r"Copyright \(.*\) ([0-9]{4}-[0-9]{4}) (.+)$")
-regex2 = re.compile(r"Copyright \(.*\) (([0-9]{4})(, [0-9]{4})*) (.+)$")
-
-copyrights = {}
-
-for line in sys.stdin:
- m1 = regex1.search(line)
- m2 = regex2.search(line)
- if m1 is None and m2 is None:
- sys.stderr.write("Could not parse '%s'\n" % line.strip())
- continue
- if m1:
- first, last = [int(y) for y in m1.groups()[0].split("-")]
- years = range(first, last + 1)
- owner = m1.groups()[-1].strip()
- elif m2:
- years = [int(y) for y in m2.groups()[0].split(", ")]
- owner = m2.groups()[-1].strip()
- s = copyrights.get(owner, set())
- for y in years:
- s.add(y)
- copyrights[owner] = s
-
-for owner in copyrights:
- s = copyrights[owner]
- l = [y for y in s]
- l.sort()
- copyrights[owner] = l
-
-copyrights = [(years, owner) for owner, years in copyrights.items()]
-copyrights.sort()
-
-lines = [" Copyright (C) %s %s" % (", ".join([str(y) for y in years]), owner) for years, owner in copyrights]
-
-print(
- """QuantLib-SWIG is
-%s
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- Neither the names of the copyright holders nor the names of the QuantLib
- Group and its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE."""
- % ("\n".join(lines))
-)
diff --git a/tools/prebuild_ql-risks.sh b/tools/prebuild_ql-risks.sh
index 5915cd56..b6b12e7d 100755
--- a/tools/prebuild_ql-risks.sh
+++ b/tools/prebuild_ql-risks.sh
@@ -52,7 +52,7 @@ elif [ "$QLR_PYTHON_VERSION" == "cp312" ] ; then
fi
export QL_DIR=$(pwd)/lib/QuantLib
-export QLXAD_DIR=$(pwd)/lib/quantlib-xad
+export QLRISKS_DIR=$(pwd)/lib/QuantLib-Risks-Cpp
export XAD_DIR=$(pwd)/lib/XAD
export QLSWIG_DIR=$(pwd)
@@ -105,7 +105,7 @@ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git log | grep -q "Uses Real in GemoetricBrownianMotionProcess instead of double" || (git fetch --all && git cherry-pick 6bb9c1f18ff6d4c47f06a66136fb83411207e67c)
if [ "$machine" != "macos" ] ; then
- cp -f "$QLXAD_DIR/presets/CMakeUserPresets.json" .
+ cp -f "$QLRISKS_DIR/presets/CMakeUserPresets.json" .
cmake --preset "$QL_PRESET" \
-DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
-DXAD_ENABLE_TESTS=OFF \
@@ -125,8 +125,8 @@ else
$CCACHE_OPTION \
-DCMAKE_BUILD_TYPE=Release \
-DQLXAD_DISABLE_AAD=OFF \
- -DQL_EXTERNAL_SUBDIRECTORIES="$XAD_DIR;$QLXAD_DIR" \
- -DQL_EXTRA_LINK_LIBRARIES="quantlib-xad" \
+ -DQL_EXTERNAL_SUBDIRECTORIES="$XAD_DIR;$QLRISKS_DIR" \
+ -DQL_EXTRA_LINK_LIBRARIES="QuantLib-Risks" \
-DQL_NULL_AS_FUNCTIONS=ON \
-DXAD_NO_THREADLOCAL=ON
fi