Giter VIP home page Giter VIP logo

quantlib-swig's Introduction

quantlib-swig's People

Contributors

andlla avatar bnalgo avatar bohlseb avatar dependabot[bot] avatar eddelbuettel avatar eltoder avatar fabrice-lecuyer avatar gbfredrik avatar github-actions[bot] avatar gouthambs avatar ignacioanguita avatar jacek-bator avatar jackgillett101 avatar klausspanderen avatar lballabio avatar marcin-rybacki avatar marcinole avatar martinrosstmc avatar mdelmedico avatar mgroncki avatar miguelandrs avatar mlungwitz avatar nijazk avatar pcaspers avatar prasadsom avatar ralfkonrad avatar rglarix avatar slusek avatar westonsteimel avatar zywina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantlib-swig's Issues

Add AmericanOption that takes Date as a number: Python

Valuing Intraday options is exceptionally difficult with the current Vanilla Option. There should be handling date time without QL.Date is much easier. It also makes calculating all the greeks much much easier than with the current ql.VanillaOption

Calendar Invalid on Python

This is odd. Seems like something going wrong with one of the offsets.

Tested on Python 3.3

In [534]: cal = ql.UnitedStates()
In [535]: cal.isHoliday(ql.Date(25, 3, 2016))
Out[535]: False
In [536]: cal.isHoliday(ql.Date(25, 3, 2017))
Out[536]: True

Implement Closable and give option to remove finalize method

Hi Luigi,

Any objection to taking a patch that will cause the Java proxy classes to implementation Closeable? Also with a separate option for removal of the SWIG javafinalize typemap? Under high performance scenarios the impact of finalizers is crushing. try/catch with resources is the easiest way to handle native resources.

configure cannot find quantlib-config

./configure apparently does not honour --prefix and/or --exec-prefix properly since quantlib-config should be found from the location project QuanLib installed it.

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-linux-gnu-strip... x86_64-linux-gnu-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking system... Linux
checking for style of include used by make... GNU
checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-linux-gnu-gcc accepts -g... yes
checking for x86_64-linux-gnu-gcc option to accept ISO C89... none needed
checking whether x86_64-linux-gnu-gcc understands -c and -o together... yes
checking dependency style of x86_64-linux-gnu-gcc... none
checking for x86_64-linux-gnu-g++... x86_64-linux-gnu-g++
checking whether we are using the GNU C++ compiler... yes
checking whether x86_64-linux-gnu-g++ accepts -g... yes
checking dependency style of x86_64-linux-gnu-g++... none
checking whether x86_64-linux-gnu-g++ accepts warning flags... yes
checking for QuantLib... ./configure: line 4033: quantlib-config: command not found

... despite I definitely have it installed under the location I told QuantLib should install it.

AmortizingBond

Hi, it's posible to add this type of bond to the Python library or is there any documentation on how to add them?

Thanks in advance.

Hard-coded 2-Jan-2018 maturity in bonds.py and ratehelpers.py breaks Python tests

We've just passed this date which was hard-coded into the test files 9 years ago. This results in bond.notional() and bond.nextCouponRate() both returning 0.0, which I guess makes sense since the bond has matured.

I've managed to run the tests successfully by arbitrarily overriding the global evaluation date to 2-Jan-2010 instead of the current system date. Adding

QuantLib.Settings.instance().setEvaluationDate(QuantLib.Date(2,1,2010))

to FixedRateBondTest's setUp method does the trick.

COSHestonEngine not available in Python Wrapper

Under Python 3.6, QuantLib doesn't recognise the COSHestonEngine.
Sample code:

import QuantLib as ql
ql.COSHestonEngine

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-cc96c8f4e92f> in <module>()
----> 1 ql.COSHestonEngine

AttributeError: module 'QuantLib' has no attribute 'COSHestonEngine'

As far as I understand, the Python call just to be linked to the C++ code. If I knew C++, I would do it myself but unfortunately I don't. Many thanks to whoever could link it.

compile error with java extension

compile errors with gcc 5.4.0 , quantlib1.11 on my ubuntu. While on my mac pro with the save version has no errors

g++ -c quantlib_wrap.cpp -fno-strict-aliasing -fPIC -g -O2 -I/opt/jdk1.8.0_141/include -I/opt/jdk1.8.0_141/include/linux quantlib-config --cflags -o quantlib_wrap.o
quantlib_wrap.cpp:8196:199: error: reference to 'LogCubic' is ambiguous
Ptr__SWIG_0(std::vector< Date > const &dates,std::vector< Rate > const &yields,DayCounter const &dayCounter,Calendar const &calendar=Calendar(),LogCubic co
^
quantlib_wrap.cpp:1773:7: note: candidates are: class LogCubic
class LogCubic : public QuantLib::LogCubic {
^
In file included from /usr/local/include/ql/termstructures/yield/discountcurve.hpp:32:0,
from /usr/local/include/ql/termstructures/yield/bootstraptraits.hpp:29,
from /usr/local/include/ql/termstructures/yield/piecewiseyieldcurve.hpp:31,
from /usr/local/include/ql/experimental/termstructures/multicurvesensitivities.hpp:28,
from /usr/local/include/ql/experimental/termstructures/all.hpp:4,
from /usr/local/include/ql/experimental/all.hpp:25,
from /usr/local/include/ql/quantlib.hpp:43,
from quantlib_wrap.cpp:723:
/usr/local/include/ql/math/interpolations/loginterpolation.hpp:94:11: note: class QuantLib::LogCubic
class LogCubic {
^
quantlib_wrap.cpp:8196:199: error: 'LogCubic' has not been declared
Ptr__SWIG_0(std::vector< Date > const &dates,std::vector< Rate > const &yields,DayCounter const &dayCounter,Calendar const &calendar=Calendar(),LogCubic co
^
quantlib_wrap.cpp:8196:217: error: reference to 'LogCubic' is ambiguous
ector< Date > const &dates,std::vector< Rate > const &yields,DayCounter const &dayCounter,Calendar const &calendar=Calendar(),LogCubic const &i=LogCubic(),

Exposing ASX dates and futures

Hi,
I'm considering making a pull request to expose ASX dates and futures.
This would be done by updating dates.i to add the ASX struct, add futures.i to expose the Futures struct, in ratehelpers.i update the 4 FuturesRateHelper constructors to add the Futures.Type input, and include the new files in ql.i.
Also maybe expose the 2 additional FuturesRateHelper(..., d1, d2, ...) constructors while I'm at it.
As I'm using SWIG for C# within VS14, I can include the SWIG generated files (ASX.cs and Futures.cs) in the QuantLib_vc14.sln solution file (and maybe the previous versions), but that would be as far as I could go in terms of integration.
Note this would be my first contribution ever, so guidance would be appreciated.
Would you consider/accept this?
F.

generating pep513 manylinux1 wheels

Wanted to share what I have done. I could have made a PR, but since I dont know the flow of how to generate pypi packages for this project is, I will just describe what I have done.

I have generated the following wheels:

QuantLib_Python-1.12-cp27-cp27mu-manylinux1_x86_64.whl
QuantLib_Python-1.12-cp36-cp36m-manylinux1_x86_64.whl

I did

docker pull quay.io/pypa/manylinux1_x86_64
docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash

That gives me a shell on the docker container designed for generating manylinux1 packages(based on an ancient centos5).
In that shell I ran the following

boost_version=1.66.0
boost_dir=boost_1_66_0
quantlib_version=1.12
quantlib_swig_version=1.12

cd /tmp
wget --no-check-certificate https://dl.bintray.com/boostorg/release/$boost_version/source/$boost_dir.tar.gz -O $boost_dir.tar.gz \
    && tar xfz $boost_dir.tar.gz \
    && rm -f $boost_dir.tar.gz \
    && cd $boost_dir \
    && ./bootstrap.sh \
    && ./b2 --without-python --prefix=/usr -j 4 link=shared runtime-link=shared install \
    && cd .. && ldconfig

cd /tmp
wget --no-check-certificate http://downloads.sourceforge.net/project/quantlib/QuantLib/$quantlib_version/QuantLib-$quantlib_version.tar.gz \
    && tar xfz QuantLib-$quantlib_version.tar.gz \
    && rm -f QuantLib-$quantlib_version.tar.gz \
    && cd QuantLib-$quantlib_version \
    && ./configure --prefix=/usr --disable-static CXXFLAGS=-O3 \
    && make -j 4 && make check && make install \
    && cd .. && ldconfig


export CPATH=/opt/python/cp27-cp27mu/include/python2.7
export PATH=/opt/python/cp27-cp27mu/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Needed to increase memory of docker container for this to compile
cd /tmp
wget --no-check-certificate http://downloads.sourceforge.net/project/quantlib/QuantLib/$quantlib_swig_version/other\ languages/QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && tar xfz QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && rm -f QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && cd QuantLib-SWIG-$quantlib_swig_version \
    && ./configure --disable-perl --disable-ruby --disable-csharp --disable-r --disable-java \
    && make && make -C Python check

cd /tmp/QuantLib-SWIG-$quantlib_swig_version

#Some patches where needed
cp LICENSE.txt Python/LICENSE.txt
#in Python/setup.py change '../LICENSE.TXT' to 'LICENSE.TXT'

# Compile wheels
pip wheel /tmp/QuantLib-SWIG-$quantlib_swig_version/Python -w /io/wheelhouse2.7/

# Bundle external shared libraries into the wheels
for whl in /io/wheelhouse2.7/*.whl; do
    auditwheel repair "$whl" -w /io/wheelhouse_manylinux1/
done

rm -rf /tmp/QuantLib-SWIG-$quantlib_swig_version


export CPATH=/opt/python/cp36-cp36m/include/python3.6m
export PATH=/opt/python/cp36-cp36m/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

cd /tmp
wget --no-check-certificate http://downloads.sourceforge.net/project/quantlib/QuantLib/$quantlib_swig_version/other\ languages/QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && tar xfz QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && rm -f QuantLib-SWIG-$quantlib_swig_version.tar.gz \
    && cd QuantLib-SWIG-$quantlib_swig_version \
    && ./configure --disable-perl --disable-ruby --disable-csharp --disable-r --disable-java \
    && make && make -C Python check 

cd /tmp/QuantLib-SWIG-$quantlib_swig_version

#Some patches where needed
cp LICENSE.txt Python/LICENSE.txt
#in Python/setup.py change '../LICENSE.TXT' to 'LICENSE.TXT'

# Compile wheels
pip wheel /tmp/QuantLib-SWIG-$quantlib_swig_version/Python -w /io/wheelhouse3.6/

# Bundle external shared libraries into the wheels
for whl in /io/wheelhouse3.6/*.whl; do
    auditwheel repair "$whl" -w /io/wheelhouse_manylinux1/
done

Of some reason the QuantLib_Python-1.12-cp27-cp27mu-manylinux1_x86_64.whl got the name QuantLib_Python-1.12-cp27-cp27m-manylinux1_x86_64.whl. I just renamed it and ran the tests on an ubuntu trusty for both py2.7 and py3.6 and the tests passed.

The compile time is hideous(about 3 hours on my macbookair), but could be cut down by preparing an image based on quay.io/pypa/manylinux1_x86_64 with a new boost version.

All this could be moved to travis, so that each push generates new manylinux1 wheels, but once again I am not sure how you want to handle it.

QuantLib was not compiled with intraday support

Greetings,

Compiled QuantLib v1.11 on Mac 10.12.6 with standard options from documentation with intraday support enabled:

./configure --with-boost-include=/usr/local/include/ \
            --with-boost-lib=/usr/local/lib/ --prefix=/usr/local/ \
            CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9' \
            LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9' \
            --enable-intraday

Installed QuantLib for Anaconda Python 3.6.2:

pip install QuantLib-Python

Tried to create an intraday ql.Date object which fails:

>>> import QuantLib as ql
>>> import datetime as dt
>>> now = dt.datetime.today()
>>> ql.Date(now.day, now.month, now.year, now.hour, now.minute, now.second)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jason/anaconda3/lib/python3.6/site-packages/QuantLib/QuantLib.py", line 433, in __init__
    this = _QuantLib.new_Date(*args)
RuntimeError: QuantLib was not compiled with intraday support

Is this is a bug or am I doing something wrong?

(Cross posted on Stack Overflow)

Gaussian1d calibration

HI,
What would the QuantLIb object representing ATM vols surface fit for Gaussian1d calibration?
Best,
Michal

Check latest SWIG version

The last few releases were generated with SWIG 3.0.10.
SWIG 3.0.12 is available and could be used.

This probably doesn't require any modifications in the code.

BlackSwaptionEngine - displacement ignored

I'm having trouble using the BlackSwaptionEngine with displacement. While the displacement can be passed to the ql.BlackSwaptionEngine, swap.blackPrice returns an error indicating that the displacement is ignored (this is QuantLib 1.12 on Linux).

forward_rate = -0.01
day_count = ql.Thirty360()
todays_date = ql.Date(20, 10, 2017)
spot_curve = ql.FlatForward(todays_date,
                            ql.QuoteHandle(ql.SimpleQuote(forward_rate)),
                            day_count)
termstruct = ql.YieldTermStructureHandle(spot_curve)
displacement = 0.5
eng = ql.BlackSwaptionEngine(termstruct, ql.QuoteHandle(ql.SimpleQuote(0.1)), ql.Actual365Fixed(), displacement)
index = ql.USDLibor(ql.Period(3, ql.Months), termstruct)
swap = ql.SwaptionHelper(ql.Period(2, ql.Years), ql.Period(3, ql.Years), 
                  ql.QuoteHandle(ql.SimpleQuote(0.15)), index, index.tenor(), index.dayCounter(), 
                  index.dayCounter(), termstruct)
swap.setPricingEngine(eng)
swap.blackPrice(0.1)
RuntimeErrorTraceback (most recent call last)
<ipython-input-125-7c601816769d> in <module>()
     13                   index.dayCounter(), termstruct)
     14 swap.setPricingEngine(eng)
---> 15 swap.blackPrice(0.1)

/opt/conda/envs/main/lib/python2.7/site-packages/QuantLib/QuantLib.py in blackPrice(self, volatility)
  10116 
  10117     def blackPrice(self, volatility):
> 10118         return _QuantLib.CalibrationHelper_blackPrice(self, volatility)
  10119 
  10120     def volatility(self):

RuntimeError: strike + displacement (-0.00984189 + 0) must be non-negative

Am I missing something?

make -C Python doesn't work on Centos 7

[root@izuf65t9mwm2pgnjzxzkgxz QuantLib-SWIG]# make -C Python
make: Entering directory /root/QuantLib-SWIG/Python' make all-am make[1]: Entering directory /root/QuantLib-SWIG/Python'
CXXFLAGS="-g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /usr/bin/python36 setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -I/usr/local/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-3.6/QuantLib/quantlib_wrap.o -Wno-unused -g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
QuantLib/quantlib_wrap.cpp: In function ‘PyObject* PyInit__QuantLib()’:
QuantLib/quantlib_wrap.cpp:365795:129: error: lvalue required as unary ‘&’ operand
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustNone",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustNone),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));

... more error output ...

error: command 'gcc' failed with exit status 1
make[1]: *** [.build-stamp] Error 1
make[1]: Leaving directory /root/QuantLib-SWIG/Python' make: *** [all] Error 2 make: Leaving directory /root/QuantLib-SWIG/Python'

Segmentation Fault with Java Examples

I am currently setting up a new project and would like to build a JNI wrapper for QuantLib using cygwin on Windows for some experiments.

I have checked out both QuantLib and QuantLib-SWIG version 1.11. Using boost 1.63 from cygwin, I have configured to build QuantLib using the following parameters:

./configure --enable-thread-safe-observer-pattern --enable-thread-safe-singleton-init --enable-negative-rates --enable-unity-build --enable-error-lines --enable-error-functions --enable-tracing --enable-extra-safety-checks

The build of QuantLib and QuantLib-SWIG (Java only) completed successfully. I can also run the QuantLib examples without problems or crashes.

However, when I run the QuantLib-SWIG Java examples, they crash with a Segmentation Fault. For example with verbose options turned on in JVM:

[Loaded org.quantlib.IborIndex from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.Euribor from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.Euribor6M from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.Thirty360 from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.SwapRateHelper from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.YieldTermStructureHandle from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.RelinkableYieldTermStructureHandle from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.PricingEngine from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.DiscountingBondEngine from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.USDLibor from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.OptionletVolatilityStructure from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.ConstantOptionletVolatility from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.FloatingRateCouponPricer from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.IborCouponPricer from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.BlackIborCouponPricer from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.YieldTermStructure from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded org.quantlib.PiecewiseFlatForward from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded java.lang.Void from C:\Tony\App\jdk1.8.0_144\jre\lib\rt.jar]
[Loaded org.quantlib.QuantLibJNI from file:/C:/Tony/3rdParty/QuantLib-SWIG/Java/QuantLib.jar]
[Loaded java.lang.ClassLoaderHelper from C:\Tony\App\jdk1.8.0_144\jre\lib\rt.jar]
Segmentation fault

Has anybody had success with QuantLib-SWIG Java with cygwin? Or with another compiler in Windows?

I have also read that since QuantLib v1.7, there has been fixes to handle issues with the multi-thread garbage collector. I have checked that the following should have been defined:

#define QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN 1
#define QL_ENABLE_SINGLETON_THREAD_SAFE_INIT 1

However, the version of boost is a standard one from cygwin and I have not recompiled it.

Any help or comments would be greatly appreciated!

Readme Update

A few minor notes to the Linux installation instructions:

  1. The sequence of commands starts with ./autogen.sh.
  2. A note can be also made to the installation of swig itself, e.g. "sudo apt-get install swig" for Ubuntu.
  3. For cases of recent OS installations, it is helpful to mention that the dynamic linker might need to be configured by running "sudo ldconfig", even though this belongs to the QuantLib installation instructions.

Swing options in the Python wrapper

Hi, would it be possible to add swing options to QuantLib-Python from swingoption.cpp please? QuantLib/ql/experimental/commodities/ looks very interesting too. Thanks!

Python wrapper for next and previouscashflowdate

Can we have python wrapper for following Quantlib functions. Those are available in Excel Add In but missing for Python.

CashFlows::previousCashFlowDate and CashFlows::nextCashFlowDate

Would be helpful in Accrued amount computation for more generic class of Bonds.

dealing with class requiring shared_ptr argument

I'm trying to expose the OptimizationMethod input of the FittedBondDiscountCurve::FittingMethod classes but can't get it to work so far.

I have tried the below (and a lot of other attempts and I can't work out how to do it. Any hints would be appreciated

%{
using QuantLib::ExponentialSplinesFitting;
using QuantLib::NelsonSiegelFitting;
using QuantLib::SvenssonFitting;
using QuantLib::CubicBSplinesFitting;
using QuantLib::SimplePolynomialFitting;

typedef boost::shared_ptr<OptimizationMethod> OptimizationMethodPtr;
%}


class ExponentialSplinesFitting : public FittingMethod {
  public:
    ExponentialSplinesFitting(
               bool constrainAtZero = true,
               const Array& weights = Array(),
               const Array& l2 = Array();
               boost::shared_ptr<OptimizationMethod> optimizationMethod = boost::shared_ptr<OptimizationMethod>())
    %extend {
         ExponentialSplinesFitting(
                    bool constrainAtZero,
                    const Array& weights,
                    const Array& l2,
                    OptimizationMethod& optimizationMethod) {
             OptimizationMethodPtr optimizationMethodPtr = boost::make_shared<OptimizationMethod>(optimizationMethod);
             return ExponentialSplinesFitting(constrainAtZero,
                                              weights,
                                              l2,
                                              optimizationMethodPtr);
         }
    }
};

SWIG - old version warning

It would be helpfull to have a warning information if ./configure detects old version of SWIG.
Recently I have successfully compiled the Python module (without errors) on Red Hat Enterprise Linux, where by default swig installed from repositories is 2.0.10. It took quite a long time to determine why I failed some tests while running
$make -C Python check
Compiling and installing recent version from sources (3.0.10) solved all the issues.
Either information about minimum version of swig should be placed somewhere in documentation, or a warning printed out at the end of configure script. Personally, I would very much appreciate such warning.

CashFlows Casting __nonzero__ method does not work in Python 3

From mailing list:

We had provided the wrapped class with a __nonzero__ method so that in Python 2, you can write:

c = as_coupon(cf)
if not c:
    print "not a coupon"

but apparently, that doesn't work in Python 3. As a workaround, you can write explicitly:

c = as_coupon(cf)
if not c.__nonzero__():
    print "not a coupon"

Make memory error when compiling Quantlib SWIG

Running the make command (full one or just -C Python), I the process gets stuck in build/temp.../Quantlib and the system allocated processors resources and memory until it runs out of it. I've tried this a bunch of times and it keeps running the same way but I have no idea why it behaves like this. For completeness, here is the full stack from the beginning until the point where it gets stuck and I interrupt the process:

make: Entering directory '/home/bruno/QuantLib-SWIG-1.8/Python'
make all-am
make[1]: Entering directory '/home/bruno/QuantLib-SWIG-1.8/Python'
CXXFLAGS="-g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /home/bruno/anaconda3/bin/python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/QuantLib
copying QuantLib/init.py -> build/lib.linux-x86_64-3.5/QuantLib
copying QuantLib/QuantLib.py -> build/lib.linux-x86_64-3.5/QuantLib
running build_ext
building 'QuantLib._QuantLib' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/QuantLib
gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/bruno/anaconda3/include/python3.5m -I/usr/local/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-3.5/QuantLib/quantlib_wrap.o -Wno-unused -g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
^Cinterrupted
Makefile:425: recipe for target '.build-stamp' failed
make[1]: *** [.build-stamp] Error 1
Makefile:219: recipe for target 'all' failed
make: *** [all] Interrupt

I don't know if this might be an issue but I use Python 3.5 through anaconda.

build fails with non-standard QuantLib location despite prefix passed directly to setup

This is likely user error (me), but I've searched everywhere and can't find the answer. Here's the command and output from build. Note that quantlib is in /home/aloupos/local, such that /home/aloupos/local/include/ql exists and has version.hpp.

-bash-4.1$ python setup.py install --prefix=/home/aloupos/local
running install
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
g++ -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.6 -I/usr/local/include -I/home/aloupos/local/boost_1_62_0 -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-2.6/QuantLib/quantlib_wrap.o -Wno-unused
QuantLib/quantlib_wrap.cpp:3953:26: error: ql/version.hpp: No such file or directory
QuantLib/quantlib_wrap.cpp:4019:27: error: ql/quantlib.hpp: No such file or directory

...

CSharp: Cannot create MCEuropeanBasketEngine Object

Hi,
I would like to create an object of MCEuropeanBasketEngine which has a constructor overloaded as follows:

public MCEuropeanBasketEngine(StochasticProcessArray process, string traits)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge, bool antitheticVariate)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int requiredSamples)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int requiredSamples, double requiredTolerance)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int requiredSamples, double requiredTolerance, int maxSamples)
public MCEuropeanBasketEngine(StochasticProcessArray process, string traits, uint timeSteps, uint timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int requiredSamples, double requiredTolerance, int maxSamples, int seed) 

I tried minimal parameter sets like

var engine = new MCEuropeanBasketEngine(proc, "pseudorandom")
ERROR: no time steps provided
var engine = new MCEuropeanBasketEngine(proc, "pseudorandom", 5 * 252)
europeanOption.setPricingEngine(engine);
ERROR: neither tolerance nor number of samples set

And all available parameters like

var engine = new MCEuropeanBasketEngine(proc, "pseudorandom", 5 * 252, 0, false, true, 10000, 0.02, 1000000, 42)
ERROR: both time steps and time steps per year were provided

How is it possible to call MCEuropeanBasketEngine using the full Parameter set and pass null to the constructor?

best,
-m

QuantLib.Date operator>= and operator<= not working

Hi,

Are the QuantLib.Date operator>= and operator<= overloads working in the Python implementation?
For instance, I get the following error when comparing two dates:
date1 = ql.Date(1, 1, 2016) date2 = ql.Date(1, 2, 2016) date1 > date2 # False date1 >= date2 # TypeError: unordered types Date() >= Date()

Thanks

make file error on Python3.5

CXXFLAGS="-O3 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /usr/bin/python setup.py build
Traceback (most recent call last):
File "setup.py", line 242, in
license = open('../LICENSE.TXT','r+').read(),
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 1199: ordinal not in range(128)

make -C Python fails for linux

I am writing a dockerfile to automate compiling the python QuantLib package under linux. I am using Debian 6.3.0-18 as a base image. I am using the most recent 1.12 tars of QuantLib and QuantLib-SWIG available from github. The relevant part of the dockerfile looks like this.

...
RUN mkdir -p /QuantLib && tar xzf /${ql_fl} --strip-components=1 -C QuantLib && cd /QuantLib && cmake . && make && make install
RUN apt-get install -y automake autoconf libtool swig
RUN mkdir -p /QuantLib-SWIG && tar xzf /${ql_py_fl} --strip-components=1 -C QuantLib-SWIG && cd /QuantLib-SWIG && cp /QuantLib/quantlib-config.in /usr/bin/quantlib-config && ./autogen.sh && ./configure
RUN cd /QuantLib-SWIG && make -C Python && make -C Python install

The relevant part of the error I get is

gcc: error: @BOOST_INCLUDE@: No such file or directory
gcc: error: @OPENMP_CXXFLAGS@: No such file or directory

I am not sure why these placeholders are not filled. Am I missing something? Below the full output of the last RUN statement.

make: Entering directory '/QuantLib-SWIG/Python'
/usr/bin/swig -python -c++ -modern -outdir QuantLib
-o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
make all-am
make[1]: Entering directory '/QuantLib-SWIG/Python'
CXXFLAGS="-g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /usr/bin/python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/QuantLib
copying QuantLib/init.py -> build/lib.linux-x86_64-2.7/QuantLib
copying QuantLib/QuantLib.py -> build/lib.linux-x86_64-2.7/QuantLib
running build_ext
building 'QuantLib._QuantLib' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/QuantLib
gcc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -I@includedir@ -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-2.7/QuantLib/quantlib_wrap.o @BOOST_INCLUDE@ @OPENMP_CXXFLAGS@ -Wno-unused -g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
gcc: error: @BOOST_INCLUDE@: No such file or directory
gcc: error: @OPENMP_CXXFLAGS@: No such file or directory
error: command 'gcc' failed with exit status 1
Makefile:434: recipe for target '.build-stamp' failed
make[1]: *** [.build-stamp] Error 1
make[1]: Leaving directory '/QuantLib-SWIG/Python'
make: *** [all] Error 2
Makefile:227: recipe for target 'all' failed
make: Leaving directory '/QuantLib-SWIG/Python'
The command '/bin/sh -c cd /QuantLib-SWIG && make -C Python && make -C Python install' returned a non-zero code: 2

Cash-settled swaptions pricing fails in QuantLib-Python 1.14

There is a mismatch between the SWIG interface and the QuantLib library in version 1.14 resulting in a problem with cash-settled swaptions.

Instantiating a swaption with cash settlement type and calling its NPV fails fails on: Settlement::checkTypeAndMethodConsistency with the following error message: "invalid settlement method for cash settlement".

Furthermore, there is currently no way to set the settlementMethod from Python.

Here is a reproducible example:

import QuantLib as ql
today = ql.Date(2, ql.January, 2019)
ql.Settings.instance().evaluationDate = today
# Underlying swap definition
curve = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.03, ql.Actual365Fixed()))
libor_3m = ql.USDLibor(ql.Period('3M'), curve)
calendar = ql.UnitedStates()
effective = calendar.advance(today, 1, ql.Years)
maturity = calendar.advance(effective, 4, ql.Years)
fixed_schedule = ql.Schedule(effective, maturity, ql.Period('6M'), calendar, ql.ModifiedFollowing,
                             ql.ModifiedFollowing, ql.DateGeneration.Forward, False)
float_schedule = ql.Schedule (effective, maturity, ql.Period('3M'), calendar, ql.ModifiedFollowing,
                              ql.ModifiedFollowing, ql.DateGeneration.Forward, False)
swap = ql.VanillaSwap(ql.VanillaSwap.Payer, 1e6, fixed_schedule, 0.03, ql.Actual365Fixed(),
                      float_schedule, libor_3m, 0., ql.Actual360())
# Swaption definition
swaption = ql.Swaption(swap, ql.EuropeanExercise(effective), ql.Settlement.Cash)
engine = ql.BlackSwaptionEngine(curve, ql.QuoteHandle(ql.SimpleQuote(0.1)))
swaption.setPricingEngine(engine)
swaption.NPV()

The same code works fine if you replace ql.Settlement.Cash by ql.Settlement.Physical in the swaption instantiation.

(booked following: https://stackoverflow.com/questions/54012065/cash-settled-swaptions-pricing-in-quantlib-python)

Structure of Variables of Swap Inputs

Hi. I have been trying to implement the Swap Code found in the examples. The question that I have is how can i see what are the returned values of the following constructors from the functions / classes to understand a little bit more about how i can construct term structures using QuantLib

SwapRateHelper
DepositRateHelper

In the Swap example the construction of the term structure is the following
helpers = depositHelpers[:2] + futuresHelpers + swapHelpers[1:]

make -C Python fails for linux(Python 2.7)

make -C Python
make: Entering directory /root/QuantLib-SWIG/Python' make all-am make[1]: Entering directory /root/QuantLib-SWIG/Python'
CXXFLAGS="-g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /usr/bin/python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
gcc -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -I/usr/local/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-2.7/QuantLib/quantlib_wrap.o -Wno-unused -g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
QuantLib/quantlib_wrap.cpp: In function ‘void init_QuantLib()’:
QuantLib/quantlib_wrap.cpp:342939:129: error: lvalue required as unary ‘&’ operand
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustNone",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustNone),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));
^
QuantLib/quantlib_wrap.cpp:1165:89: note: in definition of macro ‘SWIG_NewPointerObj’
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
^
QuantLib/quantlib_wrap.cpp:342939:79: note: in expansion of macro ‘SWIG_as_voidptr’
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustNone",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustNone),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));
^
QuantLib/quantlib_wrap.cpp:342940:133: error: lvalue required as unary ‘&’ operand
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustDigitals",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustDigitals),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));
^
QuantLib/quantlib_wrap.cpp:1165:89: note: in definition of macro ‘SWIG_NewPointerObj’
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
^
QuantLib/quantlib_wrap.cpp:342940:83: note: in expansion of macro ‘SWIG_as_voidptr’
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustDigitals",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustDigitals),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));
^
QuantLib/quantlib_wrap.cpp:342941:128: error: lvalue required as unary ‘&’ operand
SWIG_Python_SetConstant(d, "MarkovFunctional_AdjustYts",SWIG_NewPointerObj(SWIG_as_voidptr(&MarkovFunctional::ModelSettings::AdjustYts),SWIGTYPE_p_MarkovFunctional__ModelSettings__Adjustments, 0 ));

Unable to use solvers

Is there anything that must be done to use the solvers that are available? It doesn't seem like there are any solve() methods being generated. Tried Bisection and Brent.

"make -C Python" failed with strange issue

root@ubuntu:/qlib/QuantLib-SWIG-1.8# make -C Python
make: Entering directory '/qlib/QuantLib-SWIG-1.8/Python'
make all-am
make[1]: Entering directory '/qlib/QuantLib-SWIG-1.8/Python'
CXXFLAGS="-g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /usr/bin/python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/QuantLib
copying QuantLib/init.py -> build/lib.linux-x86_64-2.7/QuantLib
copying QuantLib/QuantLib.py -> build/lib.linux-x86_64-2.7/QuantLib
running build_ext
building 'QuantLib._QuantLib' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/QuantLib
gcc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -I/usr/local/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-x86_64-2.7/QuantLib/quantlib_wrap.o -Wno-unused -g -O2 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See file:///usr/share/doc/gcc-5/README.Bugs for instructions.
error: command 'gcc' failed with exit status 4
Makefile:425: recipe for target '.build-stamp' failed
make[1]: *** [.build-stamp] Error 1
make[1]: Leaving directory '/qlib/QuantLib-SWIG-1.8/Python'
Makefile:219: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory '/qlib/QuantLib-SWIG-1.8/Python'

Expose qlSchedulePreviousDate and qlScheduleNextDate in SWIG

We are exploring quantlib for AI calculations and we used qlSchedulePreviousDate and qlScheduleNextDate in excel while testing/validating. However, our project requires these functions to be available in Java. Can you please expose them in SWIG wrapper?

Unable to compile for Java under Linux

I have been having trouble compiling master under Arch Linux for the last several weeks. I have the latest master of QuantLib and QuantLib SWIG as of the date of posting this. All required dependencies are up to date, as Arch Linux's native package manager utilizes a rolling release model.

The error is below:

quantlib_wrap.cpp: In function ‘jint Java_org_quantlib_QuantLibJNI__1CalibrationHelper_1volatilityType(JNIEnv*, jclass, jlong, jobject)’:
quantlib_wrap.cpp:79465:82: error: passing ‘const QuantLib::CalibrationHelper’ as ‘this’ argument discards qualifiers [-fpermissive]
       result = (VolatilityType)((CalibrationHelper const *)arg1)->volatilityType();
                                                                                  ^
In file included from /usr/local/include/ql/models/model.hpp:32:0,
                 from /usr/local/include/ql/pricingengines/latticeshortratemodelengine.hpp:28,
                 from /usr/local/include/ql/experimental/callablebonds/treecallablebondengine.hpp:28,
                 from /usr/local/include/ql/experimental/callablebonds/all.hpp:9,
                 from /usr/local/include/ql/experimental/all.hpp:7,
                 from /usr/local/include/ql/quantlib.hpp:43,
                 from quantlib_wrap.cpp:723:
/usr/local/include/ql/models/calibrationhelper.hpp:64:24: note:   in call to ‘QuantLib::VolatilityType QuantLib::CalibrationHelper::volatilityType()’
         VolatilityType volatilityType() { return volatilityType_; }
                        ^~~~~~~~~~~~~~
make[1]: *** [Makefile:438: quantlib_wrap.o] Error 1

Please let me know if any further information is required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.