Giter Club home page Giter Club logo

pyql's Introduction

PyQL - QuantLib Cython wrappers

This library is a new set of wrappers using Cython on top of QuantLib. It currently focuses on useful simple objects like Date, Calendar but might be extended to more complex wrappers if needed.

This work started on QuantLib version 1.1 and 1.2 and is now requiring version 1.5 at least and supports QuantLib 1.8.

It offers support for Python 2 and 3.

Prerequisites

Building the library

See the Getting started document for the full details.

Documentation

Documentation is pretty rough. A current build of the documentation is rendered at https://docs.enthought.com/pyql.

pyql's People

Contributors

davidastephens avatar dpinte avatar ducky427 avatar edschofield avatar kevingivens avatar kjordahl avatar linkedrank avatar phenaff avatar razbill avatar smallnamespace avatar thrasibule avatar timgates42 avatar tonyroberts 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  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

pyql's Issues

Compiling error on Win7x64, MSVC 10.0 Express, 32-bit, Python 3.4.1 32bit, QL1.4, Boost 1.55.0

The following transcript looks like a Py2to3 C API problem:

...

building 'quantlib.indexes.libor' extension
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -DHAVE_CONFIG_H -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -
DNOMINMAX -DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECAT
E -D_SCL_SECURE_NO_WARNINGS -IC:\users\stefan\documents\dev\QuantLib-1.4 -IC:\bo
ost_1_55_0 -I. -I./cpp_layer -IC:\Users\stefan\anaconda3\lib\site-packages\numpy
\core\include -IC:\Users\stefan\anaconda3\lib\site-packages\numpy\core\include -
IC:\Users\stefan\anaconda3\include -IC:\Users\stefan\anaconda3\include /Tpquantl
ib\indexes\libor.cpp /Fobuild\temp.win32-3.4\Release\quantlib\indexes\libor.obj
/GR /FD /Zm250 /EHsc
libor.cpp
quantlib\indexes\libor.cpp(1918) : error C3861: 'PyString_AsString': identifier
not found
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN
cl.exe' failed with exit status 2

Install issue on Mac

Hi guys,

I have an install issue on Mac (Mac OS 10.9.4). I've installed QuantLib 1.3 and it works fine (example runs). Its located under opt/local, so I've added the opt/local/include and opt/local/lib directories into the setup.py file.

I then 'make build' and 'make install', and the pyql seems to install under my site-packages folder. It installs under a folder called quantlib-0.1-py2.7-macosx-10.5-x86_64.egg (bunch of .so files under a subfolder called quantlib). If I try to import currency (or any other module) it does not find it. However, if I supplement the pythonpath to go insider the folder mentioned above, and then import currency, I get the following message:

ImportError: dlopen(/Users/barnarson/anaconda/lib/python2.7/site-packages/quantlib-0.1-py2.7-macosx-10.5-x86_64.egg/quantlib/currency.so, 2): Symbol not found: _ZN8QuantLib8Currency4DataC1ERKSsS3_iS3_S3_iRKNS_8RoundingES3_RKS0
Referenced from: /Users/barnarson/anaconda/lib/python2.7/site-packages/quantlib-0.1-py2.7-macosx-10.5-x86_64.egg/quantlib/currency.so
Expected in: flat namespace
in /Users/barnarson/anaconda/lib/python2.7/site-packages/quantlib-0.1-py2.7-macosx-10.5-x86_64.egg/quantlib/currency.so

Can you give me any hint as to what might have gone wrong?

P.S. I appreciate your work, the project is outstanding.

Some tests failing on Ubuntu install.

Hi,

I installed pyql according to the instructions on a Ubuntu machine. Nearly all of the tests passed except for a few. See below.

Any ideas on how I can fix this?

Thanks!

=====================================================================
ERROR: test_at (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1740)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_dates (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1740)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_iter_dates (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1740)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_previous_next_reference_date (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1740)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_size (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1740)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

----------------------------------------------------------------------
Ran 168 tests in 112.408s

FAILED (errors=5, skipped=1)
make: *** [tests] Error 1

PyQL building issues

Hi, I followed all the steps in the documents, and I also checked previous issues some other guys may have had, but still I can't build the library correctly, here's the messages I got from building.

setting.hpp is patched, quantlib is built, def generated, then quantlib built again.
Then I add folders containing .lib, .dll and folders containing .obj to the PATH
I also modified setup.py so that all directories can be correctly found, then I built
with MSVC. Still got the errors below...

Could you tell me are there any steps I went wrong? Thanks~


C:\Users...\Documents\GitHub\pyql>cmd.exe
Microsoft Windows Version 6.3.9600 2013 Microsoft Corporation. All rights reserved.

C:\Users...\Documents\GitHub\pyql>python setup.py build --compiler=msvc
C:\Users...\Documents\GitHub\pyql
setup.py
C:\Python27\lib\distutils\extension.py:133: UserWarning: Unknown Extension optio
ns: 'cython_directives'
warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib\instruments\credit_default_s
wap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\credit
default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\option
.pyx
running build
running build_py
running build_ext
building 'quantlib.cashflow' extension
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe /c /nolo
go /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32
_ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX
-DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_SCL_S
ECURE_NO_WARNINGS -IE:\Projects\QuantLib-1.5 -ID:\Modules\boost -I. -I./cpp_l
ayer -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -I
C:\Python27\PC /Tpquantlib\cashflow.cpp /Fobuild\temp.win-amd64-2.7\Release\quan
tlib\cashflow.obj /GR /FD /Zm250 /EHsc
cashflow.cpp
c:\python27\include\pymath.h(22) : warning C4273: 'round' : inconsistent dll lin
kage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(51
6) : see previous definition of 'round'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xtgmath.h(206) :
warning C4273: 'round' : inconsistent dll linkage
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(51
6) : see previous definition of 'round'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\link.exe /DLL /
nologo /INCREMENTAL:NO /LIBPATH:E:\Projects\QuantLib-1.5\build\vc120\Win32\Re
lease /LIBPATH:E:\Projects\QuantLib-1.5\lib /LIBPATH:. /LIBPATH:C:\Python27\l
ibs /LIBPATH:C:\Python27\PCbuild\amd64 QuantLib.lib /EXPORT:initcashflow build\t
emp.win-amd64-2.7\Release\quantlib\cashflow.obj /OUT:build\lib.win-amd64-2.7\qua
ntlib\cashflow.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\quantlib\cashflow.li
b /MANIFESTFILE:build\temp.win-amd64-2.7\Release\quantlib\cashflow.pyd.manifest
/subsystem:windows
cashflow.obj : warning LNK4197: export 'initcashflow' specified multiple times;
using first specification
Creating library build\temp.win-amd64-2.7\Release\quantlib\cashflow.lib and o
bject build\temp.win-amd64-2.7\Release\quantlib\cashflow.exp
cashflow.obj : error LNK2019: unresolved external symbol "public: cdecl QuantL
ib::Date::Date(void)" (??0Date@QuantLib@@qeaa@XZ) referenced in function "struct
_object * __cdecl __pyx_pf_8quantlib_8cashflow_8CashFlow_4date___get
(struct _
_pyx_obj_8quantlib_8cashflow_CashFlow *)" (?pyx_pf_8quantlib_8cashflow_8CashFl
ow_4date___get
@@YAPEAU_object@@PEAU__pyx_obj_8quantlib_8cashflow_CashFlow@@@z)

cashflow.obj : error LNK2019: unresolved external symbol "public: cdecl QuantL
ib::SimpleCashFlow::SimpleCashFlow(double,class QuantLib::Date const &)" (??0Sim
pleCashFlow@QuantLib@@qeaa@NAEBVDate@1@@z) referenced in function "int __cdecl _
_pyx_pf_8quantlib_8cashflow_14SimpleCashFlow___init
(struct *pyx_obj_8quantlib
_8cashflow_SimpleCashFlow ,double,struct __pyx_obj_8quantlib_4time_4date_Date *
)" (?__pyx_pf_8quantlib_8cashflow_14SimpleCashFlow___init
@@YAHPEAU__pyx_obj_8q
uantlib_8cashflow_SimpleCashFlow@@NPEAU__pyx_obj_8quantlib_4time_4date_Date@@@z)

build\lib.win-amd64-2.7\quantlib\cashflow.pyd : fatal error LNK1120: 2 unresolve
d externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN
amd64\link.exe' failed with exit status 1120

Work on overloaded Constructors?

A lot of QL classes have overloaded constructors, e.g. FixedRateBond, Schedule, etc. It seems like PyQL went down the route of exposing the simplest constructor, but sometimes I have the need for the more generic version (e.g. for Schedule, I want to define cashflows on specific dates rather than the default start, end, tenor).

Have you given any thought to how you want to handle the overloaded constructors? Some options would be:

  1. default args on __init__
  2. making them class methods
  3. or some classes, wrapping the QL helper classes
  4. An uglier option would be changing ___init___ to take args/kwargs and dynamically dispatching, but that's very un-Pythonic

If you have some guidance for me, I'd be happy to wrap up the constructor signatures I'm interested in and submit a PR.

Build issue on Travis-CI

Appeared with #101

See https://travis-ci.org/enthought/pyql/jobs/83023598

quantlib/time/date.cpp:11382:188: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’
quantlib/time/date.cpp:11400:245: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’
quantlib/time/date.cpp:11418:302: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’

I can't reproduce on OSX.

Issue building on Mac

All libraries are installed properly including QuantLib and Boost and still getting issues:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running build_ext
building '' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_CONFIG_H -I/opt/local/include -I. -I./cpp_layer -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/
.c -o build/temp.macosx-10.9-intel-2.7/quantlib/.o
clang: error: no such file or directory: 'quantlib/
.c'
clang: error: no input files
error: command 'cc' failed with exit status 1

1.7.x Compatibility?

Will this work with 1.7.x? Getting a bunch of warnings during DLL compilation process.

Issues during install

Hi-
I am trying to install pyQL wrapper but am having trouble just BUILDING the pyQL files.
I installed QuantLib, Boost and successfully ran the QuantLib test file- I compiled using MS Visual Studio 2013 - the release 64bit.
Python is the Anaconda build, incl Cython etc, on a Win7 SP1 64-bit machine.
The setup.py has been amended as follows

elif sys.platform == 'win32':
# With MSVC2008, the library is called QuantLib.lib but with MSVC2010, the
# naming is QuantLib-vc100-mt
if sys.version_info >= (3, 0):
    QL_LIBRARY = 'QuantLib-vc120-x64'
INCLUDE_DIRS = [
    r'C:\QuantLib-1.5',  # QuantLib headers 
    r'C:\local\boost_1_57_0', # Boost headers
    r"C:\local\boost_1_57_0\lib64-msvc-12.0", 
    '.',
    SUPPORT_CODE_INCLUDE
]
LIBRARY_DIRS = [
    r"C:\QuantLib-1.5\build\vc120\x64\Release", # for the dll lib
    r"C:\QuantLib-1.5\lib",
    r"C:\local\boost_1_57_0\libs",
    r"C:\local\boost_1_57_0\lib64-msvc-12.0", 
    '.',
    r'.\dll',
]

Unfortunately, when I navigate to the folder to where pyQL-master has been extracted to and run command "python setup.py build" I get the following errors...

C:\Anaconda3\pyql-master>python setup.py build
C:\Anaconda3\lib\distutils\extension.py:132: UserWarning: Unknown Extension opti
ons: 'cython_directives'
  warnings.warn(msg)
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\credit
_default_swap.pyx
missing cimport in module 'quantlib.time': quantlib\instruments\credit_default_s
wap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\option
.pyx
running build
running build_py
running build_ext
building 'quantlib.cashflow' extension
C:\Anaconda3\Scripts\gcc.bat -mdll -O -Wall -D__WIN32__ -DWIN32 -DNDEBUG -D_WIND
OWS -DNOMINMAX -DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEP
RECATE -D_SCL_SECURE_NO_WARNINGS -IC:\QuantLib-1.5 -IC:\local\boost_1_57_0 -IC:\
local\boost_1_57_0\lib64-msvc-12.0 -I. -I./cpp_layer -IC:\Anaconda3\lib\site-pac
kages\numpy\core\include -IC:\Anaconda3\include -IC:\Anaconda3\include -c quantl
ib\cashflow.cpp -o build\temp.win-amd64-3.4\Release\quantlib\cashflow.o /GR /FD
/Zm250 /EHsc
gcc.exe: error: /GR: No such file or directory
gcc.exe: error: /FD: No such file or directory
gcc.exe: error: /Zm250: No such file or directory
gcc.exe: error: /EHsc: No such file or directory
error: command 'C:\\Anaconda3\\Scripts\\gcc.bat' failed with exit status 1

Installation issues OS X 10.10.5

Thanks for making such an awesome library.

I am having some issues with installing the library on OS X 10.10.5. The make completes successfully, but many tests fail with

failed to import test module: quantlib...

Any ideas on how to fix or troubleshoot the issue?

Circular import in IborIndex

There is a circular import in the index classes, where Libor and Euribor import IborIndex (as they derive from it), while IborIndex imports its derived classes for use in the class method from_name. This causes e.g. the following statement to fail:

from quantlib.indexes.libor import Libor

One solution would be to make the class method from_name into a function (defined in a separate file).

How to install pyql on Windows 7 x64?

I am running on Win 7 x64 version. On my machine I have already installed Boost 1.51 and Quantlib 1.2. Now I want to install pyql on top of them. My python version is 2.7.3 with cython 1.7.

As usual I run the command "python setup.py install". The error pops up. The error messge reads:

quantlib\currency.cpp:1871:59: warning: unknown conversion type character 'z' in
format
quantlib\currency.cpp:1871:59: warning: format '%s' expects type 'char*', but ar
gument 5 has type 'Py_ssize_t'
quantlib\currency.cpp:1871:59: warning: unknown conversion type character 'z' in
format
quantlib\currency.cpp:1871:59: warning: too many arguments for format
error: command 'gcc' failed with exit status 1

I have correctly set up my boost and quantlib including and lib path in the setup script.

Issue installing PyQL on Mac

i have similar issue installing PyQL on Mac where i have Cython-0.16, patched as instructed, QuantLib-1.3 and a recent version of boost installed. There should be no problem with my boost and QuantLib installation as i can compile QuantLib examples with no issues. i am on OS X 10.9.1 Maverick.

The error message is shown below (right at the bottom). Can you help? Thanks.

Chees-iMac:pyql-master fusionic$ python setup.py build
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running build
running build_py
creating build
creating build/lib.macosx-10.9-intel-2.7
creating build/lib.macosx-10.9-intel-2.7/quantlib
copying quantlib/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib
copying quantlib/compounding.py -> build/lib.macosx-10.9-intel-2.7/quantlib
creating build/lib.macosx-10.9-intel-2.7/quantlib/indexes
copying quantlib/indexes/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/indexes
copying quantlib/indexes/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/indexes
creating build/lib.macosx-10.9-intel-2.7/quantlib/instruments
copying quantlib/instruments/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/instruments
copying quantlib/instruments/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/instruments
creating build/lib.macosx-10.9-intel-2.7/quantlib/market
copying quantlib/market/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/market
copying quantlib/market/market.py -> build/lib.macosx-10.9-intel-2.7/quantlib/market
creating build/lib.macosx-10.9-intel-2.7/quantlib/math
copying quantlib/math/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/math
creating build/lib.macosx-10.9-intel-2.7/quantlib/mlab
copying quantlib/mlab/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/mlab
copying quantlib/mlab/fixed_income.py -> build/lib.macosx-10.9-intel-2.7/quantlib/mlab
copying quantlib/mlab/option_pricing.py -> build/lib.macosx-10.9-intel-2.7/quantlib/mlab
copying quantlib/mlab/term_structure.py -> build/lib.macosx-10.9-intel-2.7/quantlib/mlab
copying quantlib/mlab/util.py -> build/lib.macosx-10.9-intel-2.7/quantlib/mlab
creating build/lib.macosx-10.9-intel-2.7/quantlib/models
copying quantlib/models/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/models
creating build/lib.macosx-10.9-intel-2.7/quantlib/pricingengines
copying quantlib/pricingengines/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/pricingengines
copying quantlib/pricingengines/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/pricingengines
creating build/lib.macosx-10.9-intel-2.7/quantlib/processes
copying quantlib/processes/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/processes
copying quantlib/processes/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/processes
creating build/lib.macosx-10.9-intel-2.7/quantlib/reference
copying quantlib/reference/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/reference
copying quantlib/reference/data_structures.py -> build/lib.macosx-10.9-intel-2.7/quantlib/reference
copying quantlib/reference/names.py -> build/lib.macosx-10.9-intel-2.7/quantlib/reference
creating build/lib.macosx-10.9-intel-2.7/quantlib/sim
copying quantlib/sim/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/sim
creating build/lib.macosx-10.9-intel-2.7/quantlib/termstructures
copying quantlib/termstructures/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures
creating build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_bonds.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_business_day_convention.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_calendar.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_cashflows.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_cds.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_currrencies.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_date.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_daycounter.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_heston_model.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_indexes.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_interest_rate.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_market.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_mlab.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_notebooks.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_payoff.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_piecewise_yield_curve.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_process.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_rate_helpers.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_reference.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_schedule.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_settings.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_simulate.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_swap.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_termstructures.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_util.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/test_vanilla_option.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
copying quantlib/test/unittest_tools.py -> build/lib.macosx-10.9-intel-2.7/quantlib/test
creating build/lib.macosx-10.9-intel-2.7/quantlib/time
copying quantlib/time/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/time
copying quantlib/time/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/time
creating build/lib.macosx-10.9-intel-2.7/quantlib/util
copying quantlib/util/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/util
copying quantlib/util/converter.py -> build/lib.macosx-10.9-intel-2.7/quantlib/util
copying quantlib/util/enums.py -> build/lib.macosx-10.9-intel-2.7/quantlib/util
copying quantlib/util/prettyprint.py -> build/lib.macosx-10.9-intel-2.7/quantlib/util
copying quantlib/util/rates.py -> build/lib.macosx-10.9-intel-2.7/quantlib/util
creating build/lib.macosx-10.9-intel-2.7/quantlib/market/conventions
copying quantlib/market/conventions/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/market/conventions
copying quantlib/market/conventions/swap.py -> build/lib.macosx-10.9-intel-2.7/quantlib/market/conventions
creating build/lib.macosx-10.9-intel-2.7/quantlib/models/equity
copying quantlib/models/equity/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/models/equity
creating build/lib.macosx-10.9-intel-2.7/quantlib/pricingengines/vanilla
copying quantlib/pricingengines/vanilla/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/pricingengines/vanilla
creating build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/credit
copying quantlib/termstructures/credit/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/credit
copying quantlib/termstructures/credit/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/credit
creating build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/volatility
copying quantlib/termstructures/volatility/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/volatility
copying quantlib/termstructures/volatility/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/volatility
creating build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/yields
copying quantlib/termstructures/yields/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/yields
copying quantlib/termstructures/yields/api.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/yields
creating build/lib.macosx-10.9-intel-2.7/quantlib/time/calendars
copying quantlib/time/calendars/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/time/calendars
creating build/lib.macosx-10.9-intel-2.7/quantlib/time/daycounters
copying quantlib/time/daycounters/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/time/daycounters
creating build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/volatility/equityfx
copying quantlib/termstructures/volatility/equityfx/init.py -> build/lib.macosx-10.9-intel-2.7/quantlib/termstructures/volatility/equityfx
running build_ext
building '' extension
creating build/temp.macosx-10.9-intel-2.7
creating build/temp.macosx-10.9-intel-2.7/quantlib
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_CONFIG_H -I/opt/local/include -I. -I./cpp_layer -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/
.c -o build/temp.macosx-10.9-intel-2.7/quantlib/.o
clang: error: no such file or directory: 'quantlib/
.c'
clang: error: no input files
error: command 'cc' failed with exit status 1
Chees-iMac:pyql-master fusionic$ python setup.py build
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running build
running build_py
running build_ext
building '' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_CONFIG_H -I/opt/local/include -I. -I./cpp_layer -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/
.c -o build/temp.macosx-10.9-intel-2.7/quantlib/.o
clang: error: no such file or directory: 'quantlib/
.c'
clang: error: no input files
error: command 'cc' failed with exit status 1

Install Issue

I am having an issue with a linked library that is not working during the build process.

running build_ext
building 'quantlib.index' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I. -I/home/_/QuantLib-1.4 -I./cpp_layer -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c quantlib/index.cpp -o build/temp.linux-x86_64-2.7/quantlib/index.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/quantlib/index.o -L/usr/local/lib -L/home/
_/QuantLib-1.4/lib -lQuantLib -o build/lib.linux-x86_64-2.7/quantlib/index.so
/usr/bin/ld: cannot find -lQuantLib
collect2: error: ld returned 1 exit status
error: command 'c++' failed with exit status 1

I have changed the setup.py INCLUDE_DIRS and LIBRARY_DIRS lists to include my Quantlib install directory.

Any Ideas?

Thank You in advance

EDIT: Iam an idiot. 1) ./configure 2) sudo make build 3) sudo make install. this genius forgot step 3

make_zero_coupon.py not working out of the box!

to make it work had to perform the following changes which I don't know if they are fully valid:

diff --git a/examples/make_zero_coupon.py b/examples/make_zero_coupon.py
index 6004ffb..2d72510 100644
--- a/examples/make_zero_coupon.py
+++ b/examples/make_zero_coupon.py
@@ -15,14 +15,13 @@ from __future__ import print_function

 from quantlib.settings import Settings
 from quantlib.termstructures.yields.rate_helpers import DepositRateHelper, SwapRateHelper
-from quantlib.termstructures.yields.piecewise_yield_curve import \
-    term_structure_factory
+from quantlib.termstructures.yields.piecewise_yield_curve import PiecewiseYieldCurve
 from quantlib.time.api import Date, TARGET, Period, Months, Years, Days
 from quantlib.time.api import (ModifiedFollowing, Unadjusted, Actual360,
                                Thirty360, ActualActual)

 from quantlib.time.api import September, ISDA, today
-from quantlib.currency import USDCurrency
+from quantlib.currency.api import USDCurrency
 from quantlib.quotes import SimpleQuote

 from quantlib.indexes.libor import Libor
@@ -80,7 +79,7 @@ def get_term_structure(df_libor, dtObs):
     for m, period, label in depositData:
         tenor = Period(m, Months)
         rate = df_libor.get_value(dtObs, label)
-        helper = DepositRateHelper(float(rate/100.0), tenor,
+        helper = DepositRateHelper(SimpleQuote(rate/100.0), tenor,
                  settlement_days,
                  calendar, ModifiedFollowing,
                  end_of_month,
@@ -92,27 +91,31 @@ def get_term_structure(df_libor, dtObs):

     liborIndex = Libor('USD Libor', Period(6, Months),
                        settlement_days,
-                       USDCurrency(), calendar,
-                       ModifiedFollowing,
-                       endOfMonth, Actual360())
+                       USDCurrency(),
+                       calendar,
+                       Actual360(),
+                       #ModifiedFollowing,
+                       #endOfMonth, 
+                       )

     spread = SimpleQuote(0)
     fwdStart = Period(0, Days)

     for m, period, label in swapData:
         rate = df_libor.get_value(dtObs, label)
-        helper = SwapRateHelper(SimpleQuote(rate/100.0),
+        helper = SwapRateHelper.from_tenor(SimpleQuote(rate/100.0),
                  Period(m, Years), 
-            calendar, Annual,
-            Unadjusted, Thirty360(),
-            liborIndex, spread, fwdStart)
+                 calendar, Annual,
+                 Unadjusted, Thirty360(),
+                 liborIndex, spread, fwdStart)
+        #helper = SwapRateHelper.from_index(SimpleQuote(rate/100.0),liborIndex)

         rate_helpers.append(helper)

     ts_day_counter = ActualActual(ISDA)
     tolerance = 1.0e-15

-    ts = term_structure_factory('discount', 'loglinear',
+    ts = PiecewiseYieldCurve('discount', 'loglinear',
          settlement_date, rate_helpers,
          ts_day_counter, tolerance)

@@ -120,7 +123,7 @@ def get_term_structure(df_libor, dtObs):

 def zero_curve(ts, dtObs):
     calendar = TARGET()
-    days = range(10, 365*20, 30)
+    days = range(10, 365*17, 30)
     dtMat = [calendar.advance(dateToDate(dtObs), d, Days) for d in days]
     df = np.array([ts.discount(dt) for dt in dtMat])
     dtMat = [QLDateTodate(dt) for dt in dtMat]
@@ -131,7 +134,7 @@ def zero_curve(ts, dtObs):

 if __name__ == '__main__':

-    df_libor = pandas.load('data/df_libor.pkl')
+    df_libor = pandas.read_pickle('data/df_libor.pkl')
     dtObs = df_libor.index

     fig = plt.figure()
@@ -150,7 +153,8 @@ if __name__ == '__main__':
     ax.set_xlim(dtMin, dtMax)
     ax.set_ylim(0.0, 0.1)

-    dtI = dtObs[range(0, len(dtObs)-1, 100)]
+    #dtI = dtObs[range(0, len(dtObs)-1, 100)]
+    dtI = dtObs[range(0, len(dtObs)-1, 99)]
     for dt in dtI:
         ts = get_term_structure(df_libor, dt)
         (dtMat, zc) = zero_curve(ts, dt)

32 Bit vs 64 bit

I'm trying to build my setup.py right and running into a few a issues. From the error I get I think its something with 32vs64 bit compilers. I compiled QL in VC 2008 express which only allowed me to compile in 32. Okay so I lose some speed nbd. But my machine and several other programs I am using are 64 bit. I build the def file with 64 bit MinGW nm. Then when I run the setup.py build with the MS VC++ for python I can get two diffrent errors depending on wether its the 32vs64 bit compilers. With the 32 bit compiler I get "module machine type 'x86' conflictrs with target machine type 'x64'". Then with the 64 bit compiler I get 2 linker errors akin to what I was getting when I built QL with VS2013. Im guessing theres is a conflict somewhere down the line but was wondering if you guys ever had problems with a 32 bit build on 64 bit machines before?

test_cds error

This may be stale code... module enum no longer exists.
Python 2.7.3 / QuanLib 1.8 / Cython 0.24.1

ERROR: quantlib.test.test_cds (unittest.loader.ModuleImportFailure)

ImportError: Failed to import test module: quantlib.test.test_cds
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/loader.py", line 252, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name
import(name)
File "/home/phn/dev/pyql/quantlib/test/test_cds.py", line 8, in
from quantlib.termstructures.credit.api import (
File "/home/phn/dev/pyql/quantlib/termstructures/credit/api.py", line 2, in
from .piecewise_default_curve import PiecewiseDefaultCurve, ProbabilityTrait, Interpolator
File "quantlib/termstructures/credit/piecewise_default_curve.pyx", line 21, in init quantlib.termstructures.credit.piecewise_default_curve (quantlib/termstructures/credit/piecewise_default_curve.cpp:6351)
from enum import IntEnum
ImportError: No module named enum

Missing data in examples/calibrate_heston.py

It appears that the Heston Calibration example (‘calibrate_heston.py’) is missing it’s ‘df_rates.pkl’ file and therefore doesn’t run. I was wondering if you might be able to check the necessary file into the examples/data directory of the project.

python 2.6 format issue

I have followed the instructions to use Cython 0.16, but in the process of installing PyQL I get the error given in the subject line. This was discussed as well on the PyQL Wordpress site comments, http://dpinte.wordpress.com/2012/03/23/pyql/. But I don't think it was resolved.

Please let me know how to proceed.

Below is what I get:

sh-3.2# python setup.py install
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
Traceback (most recent call last):
File "setup.py", line 207, in
ext_modules = collect_extensions(),
File "setup.py", line 173, in collect_extensions
if len(glob.glob('{}/*.pyx'.format(dirpath))) > 0:
ValueError: zero length field name in format

cythonise fails / distribute issue

Hi,

I've installed cython 0.16 with the patch but building fails with:

:~/src/pyql-master$ make build
python setup.py build_ext --inplace
/usr/local/python-2.7.3-64bit/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running build_ext
building '' extension
icc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -O3 -std=c99 -fPIC -I/usr/local/intel-12.1/include -I/usr/local/intel-12.1/mkl/include -I/usr/local/plotutils-2.6/include -I/usr/local/wx2.8.9/include -I/usr/local/python-2.7.3-64bit/include -fPIC -DHAVE_CONFIG_H -I/opt/QuantLib-1.1 -I. -I./cpp_layer -I/usr/local/python-2.7.3-64bit/include/python2.7 -c quantlib/
.c -o build/temp.linux-x86_64-2.7/quantlib/.o
icc: error #10236: File not found: 'quantlib/
.c'
icc: command line error: no files specified; for help type "icc -help"
error: command 'icc' failed with exit status 1
make: *** [build] Error 1

I'm using the Intel C compiler but it's the same result with gcc

Any help would be much appreciated. Thanks!

issue with values in OptionQuotes.py

in the pyql/examples/scripts/OptionQuotes.py a subtle python thing shows up in the call to Compute_IV(..., tMin=1/12, ...) - 1/12 evaluates to 0, so for some datasets that actually HAVE data less then 1/12 we get a nasty error in

b = np.linalg.lstsq(A, y)[0]

Fix: change it to 1/12. to force floating point. Add a decimal point to the 1 or the 12. Yea, it's a python thing ;)

1/12
0
1./12
0.08333333333333333
1/12.
0.08333333333333333

PyrexScanner' object has no attribute 'position'

Cythonizing quantlib/cashflow.pyx
Traceback (most recent call last):
File "setup.py", line 223, in
ext_modules = collect_extensions(),
File "setup.py", line 202, in collect_extensions
for dirpath in cython_extension_directories
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Build/Dependencies.py", line 840, in cythonize
cythonize_one(args[1:])
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Build/Dependencies.py", line 942, in cythonize_one
result = compile([pyx_file], options)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 629, in compile
return compile_multiple(source, options)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 607, in compile_multiple
result = run_pipeline(source, options, context=context)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 438, in run_pipeline
pipeline = Pipeline.create_pyx_pipeline(context, options, result)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Pipeline.py", line 238, in create_pyx_pipeline
create_pipeline(context, mode, exclude_classes=exclude_classes),
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Pipeline.py", line 131, in create_pipeline
from .ParseTreeTransforms import WithTransform, NormalizeTree, PostParse, PxdPostParse
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/ParseTreeTransforms.py", line 1402, in
class AnalyseDeclarationsTransform(EnvTransform):
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/ParseTreeTransforms.py", line 1410, in AnalyseDeclarationsTransform
""", level='c_class', pipeline=[NormalizeTree(None)])
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/TreeFragment.py", line 214, in init
mod = t = parse_from_strings(name, fmt_code, fmt_pxds, level=level, initial_pos=initial_pos)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/TreeFragment.py", line 80, in parse_from_strings
tree = Parsing.p_code(scanner, level=level, ctx=ctx)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Parsing.py", line 3148, in p_code
body = p_statement_list(s, ctx(level = level), first_statement = 1)
File "/home/magnolia/python/lib/python2.7/site-packages/Cython-0.19.1-py2.7-linux-x86_64.egg/Cython/Compiler/Parsing.py", line 1916, in p_statement_list
pos = s.position()
AttributeError: 'Cython.Compiler.Scanning.PyrexScanner' object has no attribute 'position'
make: *
* [build] Error 1

pyql building issue / Cannot assign type 'vector[Rate]' to 'vector[double]'

When I used boost 1.60, quantlib 1.8, and Cython 0.24 to build the latest pyql on windows 10 x64, I had the following error message:

Error compiling Cython file:
------------------------------------------------------------
...
        self._trait = interpolator
        if interpolator == Linear:
            self._thisptr = shared_ptr[_dts.DefaultProbabilityTermStructure](
                new _ihc.InterpolatedHazardRateCurve[_ihc.Linear](
                    _dates, hazard_rates,
                                       ^
------------------------------------------------------------

quantlib\termstructures\credit\interpolated_hazardrate_curve.pyx:51:40: Cannot assign type 'vector[Rate]' to 'vector[double]'

Error compiling Cython file:
------------------------------------------------------------
...
                    c_cal)
            )
        elif interpolator == LogLinear:
            self._thisptr = shared_ptr[_dts.DefaultProbabilityTermStructure](
                new _ihc.InterpolatedHazardRateCurve[_ihc.LogLinear](
                    _dates, hazard_rates,
                                       ^
------------------------------------------------------------

quantlib\termstructures\credit\interpolated_hazardrate_curve.pyx:58:40: Cannot assign type 'vector[Rate]' to 'vector[double]'

Error compiling Cython file:
------------------------------------------------------------
...
                    c_cal)
            )
        elif interpolator == BackwardFlat:
            self._thisptr = shared_ptr[_dts.DefaultProbabilityTermStructure](
                new _ihc.InterpolatedHazardRateCurve[_ihc.BackwardFlat](
                    _dates, hazard_rates,
                                       ^
------------------------------------------------------------

quantlib\termstructures\credit\interpolated_hazardrate_curve.pyx:65:40: Cannot assign type 'vector[Rate]' to 'vector[double]'
Traceback (most recent call last):
  File "setup.py", line 315, in <module>
    ext_modules = collect_extensions(),
  File "setup.py", line 237, in collect_extensions
    , compiler_directives=CYTHON_DIRECTIVES)
  File "D:\Program Files\Python\Python35\lib\site-packages\Cython\Build\Dependencies.py", line 912, in cythonize
    cythonize_one(*args)
  File "D:\Program Files\Python\Python35\lib\site-packages\Cython\Build\Dependencies.py", line 1034, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: quantlib\termstructures\credit\interpolated_hazardrate_curve.pyx

could anyone help me, please? many thanks in advance!

Build issue

Hi,
I have downloaded pyql and Quantlib to a new Linux Mint system ( Linux Mint 17.2 cinnamon 64bit).
I am unable to build pyql with errors similar to 103.
The quantlib has build fine and I can run the examples fine. Please also note i am using Cython 0.23.4.
Any help is much appreciated, the error is attached below :

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c quantlib/time/date.cpp -o build/temp.linux-x86_64-2.7/quantlib/time/date.o
quantlib/time/date.cpp: In function ‘QuantLib::TimeUnit _Pyx_PyInt_As_enum__QuantLib_3a__3a_TimeUnit(PyObject)’:
quantlib/time/date.cpp:11386:188: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’
return (enum QuantLib::TimeUnit) (((enum QuantLib::TimeUnit)-1)(((((enum QuantLib::TimeUnit)digits[1]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[0])));
^
quantlib/time/date.cpp:11404:245: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’
return (enum QuantLib::TimeUnit) (((enum QuantLib::TimeUnit)-1)
(((((((enum QuantLib::TimeUnit)digits[2]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[1]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[0])));
^
quantlib/time/date.cpp:11422:302: error: invalid cast from type ‘QuantLib::Period’ to type ‘QuantLib::TimeUnit’
return (enum QuantLib::TimeUnit) (((enum QuantLib::TimeUnit)-1)_(((((((((enum QuantLib::TimeUnit)digits[3]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[2]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[1]) << PyLong_SHIFT) | (enum QuantLib::TimeUnit)digits[0])));

Installation error: "need more than 2 values to unpack"

Trying to install on my Mac. I successfully installed Boost, Quantlib, and Cython.

When I tried to install Pyql with make build, I got this error message:

python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 223, in 
ext_modules = collect_extensions(),
File "setup.py", line 117, in collect_extensions
'extra_link_args':get_extra_link_args(),
File "setup.py", line 90, in get_extra_link_args
int(item) for item in platform.mac_ver()[0].split('.')]
ValueError: need more than 2 values to unpack

Compiling issues under Windows with MinGW

Hey,

I am encountering problems compiling pyql unted Windows with MinGW (I am forced to use windows on this one). I successfully compiled the QuantLib itself against boost with MinGW, as well as Cython. It is worth noting, that I am working in a python virtualenv. I edited the distutils.cfg to contain

[build]
compiler=mingw32

and fixed the paths to QuantLib and Boost in the setup.py file of pyql.

Now, when I run

python setup.py build --compiler=mingw32

in my virtualenv (with Cython successfully installed via pip; the --compiler=mingw32 option is activated just to make sure...) I get the following output:

(Python27-nitro) C:\Python27-nitro\build\pyql>python setup.py build --compiler=m
ingw32
C:\Python27\Lib\distutils\extension.py:133: UserWarning: Unknown Extension optio
ns: 'pyrex_directives'
  warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib\instruments\credit_default_s
wap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\credit
_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\option
.pyx
running build
running build_py
running build_ext
building 'quantlib.currency' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -IC:\QuantLib -IC:\boost\boo
st_1_53_0 -I. -I./cpp_layer -IC:\Python27\include -IC:\Python27-nitro\PC -c quan
tlib\currency.cpp -o build\temp.win32-2.7\Release\quantlib\currency.o
quantlib\currency.cpp: In function 'void __Pyx_RaiseArgtupleInvalid(const char*,
 int, Py_ssize_t, Py_ssize_t, Py_ssize_t)':
quantlib\currency.cpp:1865:59: warning: unknown conversion type character 'z' in
 format [-Wformat]
quantlib\currency.cpp:1865:59: warning: format '%s' expects argument of type 'ch
ar*', but argument 5 has type 'Py_ssize_t {aka int}' [-Wformat]
quantlib\currency.cpp:1865:59: warning: unknown conversion type character 'z' in
 format [-Wformat]
quantlib\currency.cpp:1865:59: warning: too many arguments for format [-Wformat-
extra-args]
writing build\temp.win32-2.7\Release\quantlib\currency.def
C:\MinGW\bin\g++.exe -shared -s build\temp.win32-2.7\Release\quantlib\currency.o
 build\temp.win32-2.7\Release\quantlib\currency.def -LC:\QuantLib\ql -LC:\boost\
boost_1_53_0\libs -LC:\Python27\Libs -LC:\Python27-nitro\libs -LC:\Python27-nitr
o\PCbuild -lQuantLib -lpython27 -lmsvcr90 -o build\lib.win32-2.7\quantlib\curren
cy.pyd
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot fin
d -lQuantLib
collect2.exe: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

(sorry for the bad line breaking, windooz...)
obviously, this has to fail as the linker call contains the options -lQuantLib -lpython27 -lmsvcr90, but it should fail because of the msvcr90 option, shouldn't it?

And the other compiler warnings also bother me, but this is something to take care of after the linking works...

On the same machine I have a cygwin environment in which it compiled fine (after installing boost in cygwin, cygwin-compiling a cygwin QuantLib etc.) but the tests fail strangely.... but this is another issue. I, however, need to get this working in a windows python installation, which is why I use MinGW.

I'd be very happy about some hints of what I am missing...thanks!

BTW, eventually I'd like to use DataNitro with this Python virtualenv.

generate_symbols

Hey guys been trying to get PYQL to work on windows for the past day or two. I've been following the getting started guided but have been running into a few issues. I can get QuantLib to build but the only the qunatlib part of the solution. Which I think leads to my main issue, where when I try to start the generate_symbols.py I get the error "WindowsError: [Error 2] system cannot find the file specified" this happens durring the first call of the sub process. I Set up the correct file paths for my system and also looked to see if the object files are being built.(Which they are.) I run aground with this and aren't sure where to go. Any help would be appreciated. Thanks.

Euribor positional arguments errors for cds.py and swap.py

Hi, I just started using QuantLib so maybe its a stretch to try and help improve pyql but I found some errors and wanted some help getting them resolved if thats possible :)

In the cds.py example, this code snippet fails because of the Euribor6M() call, which my compiler is telling me takes in one argument, and looking at euribor.pyx, I see that it takes in a variable called Euribor but what does that correspond to?

swapHelpers = [ SwapRateHelper.from_tenor(swaps[(n,unit)], Period(n,unit), calendar, fixedLegFrequency, fixedLegAdjustment, fixedLegDayCounter, Euribor6M()) for n, unit in swaps.keys() ]

Similarly, the swap.py example fails for the same reason. Am I missing something? Thanks for any help, much appreciated.

Can't set daycount convention in Thirty360

In c++ the Thirty360 constructor takes a Thirty360::Convention argument to set the daycount convention and defaults to US if none is supplied. The pyql wrapper has no way to select European daycount.

Error building on Ubuntu 11.10

Hi,
I tried building PyQL on ubuntu 11.10 with Python 2.7. I adjusted INCLUDE_DIRS and LIBRARY_DIRS for my (default) installation of Quantlib.

building '*' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -I/usr/local/include -I/usr/include -I. -I/usr/include/python2.7 -c quantlib/*.c -o build/temp.linux-i686-2.7/quantlib/*.o
gcc: error: quantlib/*.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4

Any ideas on how to solve this?

Cheers

Error building pyqa

Using Python 2.7, installed cython successfully. Using MSVC 11 (Visual Studio 2012) compiler. Getting below error message. Thanks.

C:\pyql-master>python setup.py build
c:\python27\lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'cython_directives'
warnings.warn(msg)
c:\python27\lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib\instruments\credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib\instruments\option.pyx
running build
running build_py
running build_ext
building 'quantlib.cashflow' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\quantlib
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMIN
MAX -DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -IC:\QuantLib-1.4 -IC:\boost155 -I. -I./cpp_laye
r -Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include -Ic:\python27\PC /Tpquantlib\cashflow.cpp /Fobuild\temp.win32-2.7\Release\q
uantlib\cashflow.obj /GR /FD /Zm250 /EHsc
cashflow.cpp
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\QuantLib-1.4\lib /LIBPATH:C:\boost155\sta
ge\lib /LIBPATH:c:\python27\libs /LIBPATH:c:\python27\PCbuild QuantLib.lib /EXPORT:initcashflow build\temp.win32-2.7\Release\quantlib\cashflow.obj /OU
T:build\lib.win32-2.7\quantlib\cashflow.pyd /IMPLIB:build\temp.win32-2.7\Release\quantlib\cashflow.lib /MANIFESTFILE:build\temp.win32-2.7\Release\quan
tlib\cashflow.pyd.manifest /subsystem:windows /machine:I386
LINK : fatal error LNK1181: cannot open input file 'QuantLib.lib'
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe"' failed with exit status 1181

C:\pyql-master>

Can't build pyql on Mac

Hello -

I get the error below. Can you help? I have setuptools installed, cython, and a c++ compiler (as I was able to compile and run the QuantLib example as specified here: http://quantlib.org/install/macosx.shtml

python setup.py build_ext --inplace
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'cython_directives'
warnings.warn(msg)
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/option.pyx
running build_ext
building 'quantlib.cashflow' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/local/include -I/Users/marywilliamson1/Downloads/QuantLib-1.4 -I. -I./cpp_layer -I/Users/marywilliamson1/Documents/projects/pnlbooker/virtualenv/lib/python2.7/site-packages/numpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/cashflow.cpp -o build/temp.macosx-10.9-intel-2.7/quantlib/cashflow.o
In file included from quantlib/cashflow.cpp:361:
/Users/marywilliamson1/Downloads/QuantLib-1.4/ql/time/date.hpp:276:30: warning: implicit
conversion loses integer precision: 'long' to 'Day' (aka 'int') [-Wshorten-64-to-32]
return serialNumber_ - yearOffset(year());
~~~~~~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:2083:18: warning: implicit conversion loses integer precision:
'size_type' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
__pyx_v_size = __pyx_v_leg.size();
~ ^~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:2585:18: warning: implicit conversion loses integer precision:
'size_type' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
__pyx_v_size = __pyx_v_self->_thisptr->get()->size();
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:4778:28: warning: unused function '__Pyx_PyObject_AsString'
[-Wunused-function]
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
^
quantlib/cashflow.cpp:4775:32: warning: unused function '__Pyx_PyUnicode_FromString'
[-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
quantlib/cashflow.cpp:427:29: warning: unused function '__Pyx_Py_UNICODE_strlen'
[-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE _u)
^
quantlib/cashflow.cpp:4897:33: warning: unused function '__Pyx_PyIndex_AsSsize_t'
[-Wunused-function]
static CYTHON_INLINE Py_ssize_t _Pyx_PyIndex_AsSsize_t(PyObject b) {
^
quantlib/cashflow.cpp:4926:33: warning: unused function '__Pyx_PyInt_FromSize_t'
[-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
quantlib/cashflow.cpp:3613:27: warning: unused function '__Pyx_ErrFetch' [-Wunused-function]
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject *_type, PyObject *_value, PyObject *_tb) {
^
quantlib/cashflow.cpp:3956:32: warning: unused function '__Pyx_GetItemInt_List_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:3970:32: warning: unused function '__Pyx_GetItemInt_Tuple_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:4169:26: warning: function '__Pyx_PyInt_As_int' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
^
quantlib/cashflow.cpp:4295:27: warning: function '__Pyx_PyInt_As_long' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
13 warnings generated.
quantlib/cashflow.cpp:4778:28: warning: unused function '_Pyx_PyObject_AsString'
[-Wunused-function]
static CYTHON_INLINE char
__Pyx_PyObject_AsString(PyObject* o) {
^
quantlib/cashflow.cpp:4775:32: warning: unused function '__Pyx_PyUnicode_FromString'
[-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
quantlib/cashflow.cpp:427:29: warning: unused function '__Pyx_Py_UNICODE_strlen'
[-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE _u)
^
quantlib/cashflow.cpp:4897:33: warning: unused function '__Pyx_PyIndex_AsSsize_t'
[-Wunused-function]
static CYTHON_INLINE Py_ssize_t _Pyx_PyIndex_AsSsize_t(PyObject b) {
^
quantlib/cashflow.cpp:4926:33: warning: unused function '__Pyx_PyInt_FromSize_t'
[-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
quantlib/cashflow.cpp:3613:27: warning: unused function '__Pyx_ErrFetch' [-Wunused-function]
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject *_type, PyObject *_value, PyObject **tb) {
^
quantlib/cashflow.cpp:3956:32: warning: unused function '__Pyx_GetItemInt_List_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:3970:32: warning: unused function '__Pyx_GetItemInt_Tuple_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:4169:26: warning: function '__Pyx_PyInt_As_int' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
^
quantlib/cashflow.cpp:4295:27: warning: function '__Pyx_PyInt_As_long' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
10 warnings generated.
c++ -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. -mmacosx-version-min=10.6 build/temp.macosx-10.9-intel-2.7/quantlib/cashflow.o -L/usr/local/lib -lQuantLib -o /Users/marywilliamson1/Downloads/pyql-master/quantlib/cashflow.so -stdlib=libstdc++ -mmacosx-version-min=10.6
ld: library not found for -lQuantLib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1
(virtualenv)marys-mbp:pyql-master marywilliamson1$ c++
clang: error: no input files

gcc Install errors

Installing Distribute fixed the below error - but another error happened
after make build:
/usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running install
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing requirements to quantlib.egg-info/requires.txt
writing quantlib.egg-info/PKG-INFO
writing top-level names to quantlib.egg-info/top_level.txt
writing dependency_links to quantlib.egg-info/dependency_links.txt
reading manifest file 'quantlib.egg-info/SOURCES.txt'
writing manifest file 'quantlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
running build_ext
building '' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7 -c quantlib/
.c -o build/temp.linux-i686-2.7/quantlib/.o
gcc: error: quantlib/
.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4

***** This is the latest error during install *****
building 'quantlib.index' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7 -c quantlib/index.cpp -o build/temp.linux-i686-2.7/quantlib/index.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
quantlib/index.cpp:259:33: fatal error: ql/time/frequency.hpp: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
make: *** [build] Error 1

Extending PyQL - compile issues

Hi,

I am having some issues in extending PyQl with libor market model and would appreciate some help. I am trying to add LiborForwardModelProcess from ql/legacy following existing examples like swap_index but I get some uninformative cython compilation errors. My .pyx file is

include '../types.pxi'

from cython.operator cimport dereference as deref
cimport _lfm_process as _lfmp


from quantlib.index cimport Index
from quantlib.indexes.ibor_index cimport IborIndex
from quantlib.handle cimport shared_ptr

cimport quantlib._index as _in
cimport quantlib.indexes._ibor_index as _ii
cimport quantlib.processes._stochastic_process as _sp
cdef class LiborForwardModelProcess:
    def __cinit__(self):
        pass


    def __init__(self, Size size_, IborIndex ibor_index ):
        self._thisptr = new shared_ptr[_sp.StochasticProcess](
            new _lfmp.LiborForwardModelProcess(size_,
                                               deref(<shared_ptr[_ii.IborIndex]*> ibor_index._thisptr )))

whereas the cpp-cython header is

include '../types.pxi'

from quantlib.handle cimport shared_ptr
from quantlib.termstructures.yields._flat_forward cimport YieldTermStructure
cimport quantlib._quote as _qt
from quantlib.indexes._ibor_index cimport IborIndex
from quantlib.processes._stochastic_process cimport StochasticProcess

cdef extern from 'ql/legacy/libormarketmodels/lfmprocess.hpp' namespace 'QuantLib': 
    cdef cppclass LiborForwardModelProcess(StochasticProcess):
        LiborForwardModelProcess() # empty constructor 
        LiborForwardModelProcess(Size size, shared_ptr[IborIndex]& index) except + 
        #Size size() except +

I am trying to compile this in Ubuntu using Python 2.7 and cython 0.22 but i get the error message :

Error compiling Cython file:

...
def cinit(self):
pass

def __init__(self, Size size_, IborIndex ibor_index ):
    self._thisptr = new shared_ptr[_sp.StochasticProcess](
                                                        ^

quantlib/legacy/lfm_process.pyx:26:61: Cannot convert 'shared_ptr[StochasticProcess] _' to Python object
Traceback (most recent call last):
File "setup.py", line 244, in
ext_modules = collect_extensions(),
File "setup.py", line 218, in collect_extensions
for dirpath in cython_extension_directories
File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 825, in cythonize
cythonize_one(_args[1:])
File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 944, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: quantlib/legacy/lfm_process.pyx

I would have expected some information on the top of hte error message explaining where the error is coming from, does this make any sense ? Many thanks in advance.

Numerical failures for 2 tests on win32

Reported in #63

======================================================================
FAIL: test_smith (quantlib.test.test_heston_model.HestonModelTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\dev\pyql\quantlib\test\test_heston_model.py", line 432, in test_smith
    delta=tolerance)
AssertionError: 15.244970794333526 != 15.1796 within 0.05 delta

======================================================================
FAIL: test_simulate_heston_2 (quantlib.test.test_simulate.SimTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\dev\pyql\quantlib\test\test_simulate.py", line 120, in test_simulate_heston_2
    self.assertAlmostEqual(res[1, -1], 152.50, delta=.1)
AssertionError: 153.26720068021842 != 152.5 within 0.1 delta

----------------------------------------------------------------------
Ran 144 tests in 15.095s

FAILED (failures=2, skipped=1)

Cythonise fails Cannot convert 'string' to Python object

Hi,
I've installed PyQL. I followed every steps in https://github.com/enthought/pyql/blob/master/docs/source/getting_started.rst
But when compiling pyql, I got the issue:

Cythonizing quantlib/interest_rate.pyx

Error compiling Cython file:
------------------------------------------------------------
...
                cpd_str = "simple compounding up to {0} months," \
                              "then  {1} compounding".format(12/self.frequency, freq_str)
        else:
            ValueError('unknown compounding convention ({0})'.format(self.compounding))
        return "{0:.2f} {1} {2}".format(
            self.rate, self._thisptr.get().dayCounter().name(), cpd_str
                                                           ^
------------------------------------------------------------

quantlib/interest_rate.pyx:104:60: Cannot convert 'string' to Python object
Traceback (most recent call last):
  File "setup.py", line 224, in <module>
    ext_modules = collect_extensions(),
  File "setup.py", line 203, in collect_extensions
    ) for dirpath in cython_extension_directories
  File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 543, in cythonize
    cythonize_one(pyx_file, c_file, quiet, options)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 566, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: quantlib/interest_rate.pyx

Help me please.
Many thanks

Using quantlib calendar functions kills my python...

Hi-

I am an amateur Python and pyQL and am having some issues with actually using quantlib's useful in-built date capabilities (including calendars).
The text file with the date functionality doesn't explicitly state how and what to import to make the functions and methods work, so I've been trying to do it myself. In the example I am going to show you all I am trying to do is take today's date, and adjust it backward if its NOT a business day. However, as soon as I run the code, I get the "It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.

from quantlib.time import calendar, date
cal = calendar.UnitedKingdom()
refdate = cal.adjust(date.today(), calendar.Preceding)

Thus we have the crash. I can not replicate this if I use calendar.TARGET().

Thanks,

Failing test with QuantLib 1.4

======================================================================
FAIL: test_holiday_list_acces_and_modification (quantlib.test.test_calendar.TestQuantLibCalendar)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jvkersch/Desktop/Enthought/pyql/quantlib/test/test_calendar.py", line 88, in test_holiday_list_acces_and_modification
    self.assertEquals(8, len(holidays))
AssertionError: 8 != 9

----------------------------------------------------------------------

`c_str` signature discards const-ness.

From https://github.com/enthought/pyql/blob/master/quantlib/time/_calendar.pxd#L9, the following declaration discards the const attribute of the pointer returned by c_str:

cdef extern from "string" namespace "std":
    cdef cppclass string:
        char* c_str()

This causes compilation problems when assigning the result of .c_str() to a local variable. A small fix is to declare the return type as const char * or (possibly) to discard that code and do from libcpp cimport string.

Issue building on Mac

All libraries are installed properly including QuantLib and Boost and still getting issues:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
running build_ext
building '' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_CONFIG_H -I/opt/local/include -I. -I./cpp_layer -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/
.c -o build/temp.macosx-10.9-intel-2.7/quantlib/.o
clang: error: no such file or directory: 'quantlib/
.c'
clang: error: no input files
error: command 'cc' failed with exit status 1

Can`t generate c code files. Cython-0.21.1 Python2.6 QuantLib-1.4

D:\sourcefile\python\pyql\pyql-master>setup.py build
C:\Python26\lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'cython_directiv
es'
warnings.warn(msg)
running build
running build_py
running build_ext
building '' extension
creating build\temp.win32-2.6
creating build\temp.win32-2.6\Release
creating build\temp.win32-2.6\Release\quantlib
d:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBU
G -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX -DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D
CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -IE:\share\workplace\code\QuantLib-1.4 -ID:\boost
\include\boost-1_53 -I. -I./cpp_layer -IC:\Python26\lib\site-packages\numpy\core\include -IC:\Python
26\include -IC:\Python26\PC /Tcquantlib/
.c /Fobuild\temp.win32-2.6\Release\quantlib/
.obj /GR /FD /
Zm250 /EHsc /Z7
*.c
c1 : fatal error C1083: 无法打开源文件:“quantlib/_.c”: Invalid argument
error: command '"d:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit
status 2

Catch underlying QuantLib exception that kills Python server

I'm having trouble catching an exception: basically I've created an invalid CreditDefaultSwap object with a strike = 100 so 10000% (obviously not financially valid)

cdsObject = CreditDefaultSwap(
SELLER, 1.0, 100, cdsSchedule, Following, Actual365Fixed()
)

When I do cdsObject.net_present_value, I get the following error:
libc++abi.dylib: terminating with uncaught exception of type QuantLib::Error: 1st iteration: failed at 1st alive instrument, maturity March 20th, 2015, reference date September 26th, 2014: root not bracketed: f[2.22045e-16,1] -> [1.000000e+02,9.940049e+01]

Looks like it's coming from where the instrument object is calling the pricing engine's NPV() function from the underlying library, but the exception kills my Python webserver even if I try to catch it. Any idea on how to catch this exception or deal with it?

Test Failures on OS X El Capitan

Here are the errors I'm seeing:

======================================================================
ERROR: test_option_quotes (quantlib.test.test_notebooks.NoteBooksTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_notebooks.py", line 162, in test_option_quotes
    option_data_frame = pandas.core.common.load(
AttributeError: module 'pandas.core.common' has no attribute 'load'

======================================================================
ERROR: test_at (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1742)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M
======================================================================
ERROR: test_dates (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1742)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_iter_dates (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1742)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_previous_next_reference_date (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1742)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

======================================================================
ERROR: test_size (quantlib.test.test_schedule.ScheduleMethodTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jianliu/git_projects/lendingclub-explore/src/pyql/quantlib/test/test_schedule.py", line 49, in setUp
    self.convention, self.termination_convention, self.rule
  File "quantlib/time/schedule.pyx", line 49, in quantlib.time.schedule.Schedule.__init__ (quantlib/time/schedule.cpp:1742)
    self._thisptr = new _schedule.Schedule(
RuntimeError: undecidable comparison between 4W and 1M

----------------------------------------------------------------------

The pandas issue seems to be because pandas.core.common.load was deprecated or removed by some point (I'm running pandas=0.17).

As for quantlib, I'm using a fresh build against quantlib HEAD as of today. Everything is compiled using clang against libstdc++ on El Capitan.

I built PyQL using the following:

  1. pip install -e git+https://github.com/enthought/pyql.git#egg=pyql
  2. Edit setup.py to point to right paths -- I'm building against Boost 1.59.0 source
  3. make clean && make build && make tests

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.