1010
1111Similar to QuantLib-SWIG, ORE-SWIG intends to provide the means
1212to use the ORE libraries side by side with QuantLib from a
13- number of languages including Python, Ruby, Perl, Java and C#.
13+ number of languages including Python, Ruby, Perl, Java and C#.
14+
15+ Tutorials
16+ ---------
17+
18+ For a series of in depth tutorials on installing and/or building python
19+ wrappers and wheels, please refer to this document: [ Tutorials
20+ Index] ( tutorials.00.index.md ) . For a general overview on using the ORE python
21+ wrapper, continue reading below.
1422
1523Download and usage
1624------------------
@@ -23,8 +31,8 @@ The ORE-SWIG project directory contains QuantExt-SWIG, OREData-SWIG and
2331OREAnalytics-SWIG folders. Within the ORE-SWIG project directory, pull
2432in the QuantLib-SWIG project by running
2533
26- git submodule init
27- git submodule update
34+ git submodule init
35+ git submodule update
2836
2937Prerequisite for building the wrappers is building the latest ORE release
3038following the steps outlined in ORE's user guide, e.g. using CMake.
@@ -34,100 +42,98 @@ Ninja: Edit the top level CMakeLists.txt to select/deselect
3442specific library/language folders, create a subdirectory "build",
3543change to the build directory, and run
3644
37- cmake \
38- -G Ninja \
39- -D ORE=<ORE Root Directory> \
40- [-D BOOST_ROOT=<Top level boost include directory> ] \
41- [-D BOOST_LIB=<Location of the compiled boost libraries> ] \
42- [-D PYTHON_LIBRARY=<Full name including path to the 'libpython*' library> ] \
43- [-D PYTHON_INCLUDE_DIR=<Directory that contains Python.h> ] \
44- ..
45- ninja
46-
45+ cmake \
46+ -G Ninja \
47+ -D ORE=<ORE Root Directory> \
48+ [-D BOOST_ROOT=<Top level boost include directory> ] \
49+ [-D BOOST_LIB=<Location of the compiled boost libraries> ] \
50+ [-D PYTHON_LIBRARY=<Full name including path to the 'libpython*' library> ] \
51+ [-D PYTHON_INCLUDE_DIR=<Directory that contains Python.h> ] \
52+ ..
53+ ninja
4754
4855To build on Windows using CMake and an existing Visual Studio installation you can e.g. run
4956this from the top-level oreswig directory
5057
51- mkdir builddir
52- cmake -G "Visual Studio 15 2017" \
53- -A x64 \
54- -D SWIG_DIR=C:\dev\swigwin\Lib \
55- -D SWIG_EXECUTABLE=C:\dev\swigwin\swig.exe \
56- -D ORE:PATHNAME=C:\dev\ORE\master \
57- -D BOOST_ROOT=C:\dev\boost \
58- -S OREAnalytics-SWIG/Python \
59- -B builddir
60- cmake --build builddir -v
58+ mkdir builddir
59+ cmake -G "Visual Studio 15 2017" \
60+ -A x64 \
61+ -D SWIG_DIR=C:\dev\swigwin\Lib \
62+ -D SWIG_EXECUTABLE=C:\dev\swigwin\swig.exe \
63+ -D ORE:PATHNAME=C:\dev\ORE\master \
64+ -D BOOST_ROOT=C:\dev\boost \
65+ -S OREAnalytics-SWIG/Python \
66+ -B builddir
67+ cmake --build builddir -v
6168
6269To try e.g. an OREAnalytics Python example, update your PYTHONPATH so
6370that it includes the directory that contains the newly built python module and
6471associated native library (both in
6572ORE-SWIG/build/OREAnalytics-SWIG/Python), change to
6673ORE-SWIG/OREAnalytics-SWIG/Python/Examples and run
6774
68- python ore.py
75+ python ore.py
6976
7077You can also try the IPython example in the same directory: Launch
7178
72- jupyter notebook
79+ jupyter notebook
7380
7481wait for your browser to open, select ore.ipy from the list of files
7582and then run all cells.
7683
7784Also note the test suite in ORE-SWIG/OREAnalytics-SWIG/Python/test:
7885
79- python OREAnalyticsTestSuite.py
86+ python OREAnalyticsTestSuite.py
8087
8188When the QuantExt-SWIG and OREData-SWIG modules are built as well (edit top-level CMakeLists.txt)
8289then similar test suites in ORE-SWIG/OREData-SWIG/Python/test and ORE-SWIG/QuantExt-SWIG/Python/test
8390can be run
8491
85- python OREDataTestSuite.py
86- python QuantExtTestSuite.py
92+ python OREDataTestSuite.py
93+ python QuantExtTestSuite.py
8794
8895To try a simple OREAnalytics Java example, change to
89- ORE-SWIG/OREAnalytics-SWIG/Java/Examples and run
90-
91- java -Djava.library.path=../../../build/OREAnalytics-SWIG/Java \
92- -jar ../../../build/OREAnalytics-SWIG/Java/ORERunner.jar \
93- Input/ore.xml
96+ ORE-SWIG/OREAnalytics-SWIG/Java/Examples and run
9497
98+ java -Djava.library.path=../../../build/OREAnalytics-SWIG/Java \
99+ -jar ../../../build/OREAnalytics-SWIG/Java/ORERunner.jar \
100+ Input/ore.xml
95101
96- Python Bindings on Windows
102+ Python Bindings on Windows
97103--------------------------
98104
99105On Windows you can also use the following steps to build the Python
100106bindings using the provided setup.py script:
101107
102- 1. Include SWIG path to the Path environment variable, e.g.
103- set Path=%Path%;C:\swigwin-3.0.12
104-
105- 2. Add PYTHON_INCLUDE and PYTHON_LIB variables to the system environment, e.g.
106- set PYTHON_INCLUDE="C:\Users\Name\AppData\Local\Continuum\anaconda3\include"
107- set PYTHON_LIB="C:\Users\Name\AppData\Local\Continuum\anaconda3\libs"
108-
109- 3. Add BOOST_ROOT and BOOST_LIB variables to the system environment, e.g.
110- set BOOST_ROOT=C:\repos\boost_1_65_1
111- set BOOST_LIB=C:\repos\boost_1_65_1\lib\x64\lib\lib
112-
113- 4. Add ORE_DIR and QL_DIR variables to the system environment, e.g.
114- set ORE_DIR=C:\dev\ORE
115-
116- 5. Change to directory OREAnalytics-SWIG/Python and run the following
117- python scripts to build and install ORE Analytics Python module:
118- cd Python
119- python setup.py wrap
120- python setup.py build
121- python setup.py install
122-
123- 6. Try examples (all work):
124- cd Examples
125- python ore.py
126- python swap.py
127- python market.py
128- python commodityforward.py
129- python conventions.py
130- python portfolio.py
108+ 1. Include SWIG path to the Path environment variable, e.g.
109+ set Path=%Path%;C:\swigwin-3.0.12
110+
111+ 2. Add PYTHON_INCLUDE and PYTHON_LIB variables to the system environment, e.g.
112+ set PYTHON_INCLUDE="C:\Users\Name\AppData\Local\Continuum\anaconda3\include"
113+ set PYTHON_LIB="C:\Users\Name\AppData\Local\Continuum\anaconda3\libs"
114+
115+ 3. Add BOOST_ROOT and BOOST_LIB variables to the system environment, e.g.
116+ set BOOST_ROOT=C:\repos\boost_1_65_1
117+ set BOOST_LIB=C:\repos\boost_1_65_1\lib\x64\lib\lib
118+
119+ 4. Add ORE_DIR and QL_DIR variables to the system environment, e.g.
120+ set ORE_DIR=C:\dev\ORE
121+
122+ 5. Change to directory OREAnalytics-SWIG/Python and run the following
123+ python scripts to build and install ORE Analytics Python module:
124+ cd Python
125+ python setup.py wrap
126+ python setup.py build
127+ python setup.py install
128+
129+ 6. Try examples (all work):
130+ cd Examples
131+ python ore.py
132+ python swap.py
133+ python market.py
134+ python commodityforward.py
135+ python conventions.py
136+ python portfolio.py
131137
132138Contributing
133139------------
0 commit comments