I downloaded and installed pyql
using python setup.py install
If I import things I need one by one from pyql
, it works, e.g.,
from quantlib.instruments.api import AmericanExercise,EuropeanExercise, EuropeanOption, \
VanillaOption, Put, Call
from quantlib.instruments.payoffs import PlainVanillaPayoff
However, if I try
import QuantLib as ql
[idf@mail python]$ python bootstrap_yc.py
Traceback (most recent call last):
File "bootstrap_yc.py", line 1, in <module>
import QuantLib as ql
ImportError: No module named QuantLib
[idf@mail python]$
I added the directory of the quantlib
egg file in anaconda to PYTHONPATH
to no avail.
[idf@mail python]$ echo $PYTHONPATH
/home/idf/anaconda2/lib/python2.7/site-packages/quantlib-0.1-py2.7-linux-x86_64.egg/quantlib
[idf@mail python]$
EDIT
I am able to say
from quantlib import *
import quantlib as ql
But then things like
# Deposit rates
depo_maturities = [ql.Period(6,ql.Months), ql.Period(12, ql.Months)]
depo_rates = [5.25, 5.5]
return an error:
[idf@mail python]$ python bootstrap_yc.py
Traceback (most recent call last):
File "bootstrap_yc.py", line 18, in <module>
depo_maturities = [ql.Period(6,ql.Months), ql.Period(12, ql.Months)]
AttributeError: 'module' object has no attribute 'Period'
[idf@mail python]$
I think you're confusing pyql with the Python bindings provided by the QuantLib project. pyql is a separate project, and gives you a
quantlib
module with a more idiomatic interface but with fewer features at this time.If you want the QuantLib Python bindings, you can get them from the QuantLib download page (look in the "other languages" folder inside any of the listed versions); installation instructions are at http://quantlib.org/install.shtml.