Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
stochastic-thread opened this issue Feb 16, 2015 · 6 comments · Fixed by #77
Closed

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

stochastic-thread opened this issue Feb 16, 2015 · 6 comments · Fixed by #77
Labels

Comments

@stochastic-thread
Copy link

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.

@dpinte
Copy link
Member

dpinte commented Feb 16, 2015

@arthurcolle thanks for reporting the issue. There is an easy fix for this bug. We should expose the empty constructor from the Euribor class ( see ql/indexes/_euribor.pxd). I'll see if I can find a minute to fix it. If you want to give it a try, let me know.

@dpinte dpinte added the bug label Feb 16, 2015
@stochastic-thread
Copy link
Author

Yes I am free to try at your leisure! I just ran a 'git pull origin master' and the master branch was already up to date so just let me know and I'll try again whenever. Thanks for the prompt response

@dpinte
Copy link
Member

dpinte commented Feb 21, 2015

There is some work on the fix/bug_76 branch but it revealed some other issue with swap.py example (wrong usage of relinkable handles). I'll try to fix that as soon as possible.

@dpinte
Copy link
Member

dpinte commented Mar 26, 2015

@arthurcolle if you want to give a shot at #77 that would be great.

@stochastic-thread
Copy link
Author

Traceback (most recent call last):
  File "swap.py", line 101, in <module>
    for n, unit in swaps.keys() ]
  File "swap.py", line 101, in <listcomp>
    for n, unit in swaps.keys() ]
  File "quantlib/indexes/euribor.pyx", line 41, in quantlib.indexes.euribor.Euribor6M.__init__ (quantlib/indexes/euribor.cpp:2721)
TypeError: __init__() takes exactly 1 positional argument (0 given)

Here is output when I run it.

I totally rebuilt this repo from scratch btw, in its own venv, so lmk if you think I'm doing something wrong.
The above output is when I ran "python swap.py" at the command-line but here is the output in iPython as well, which my be a distinct issue, but just reporting for your info:

ImportError                               Traceback (most recent call last)
<ipython-input-2-677456946651> in <module>()
      4 """
      5 from __future__ import print_function
----> 6 from quantlib.indexes.euribor import Euribor6M
      7 from quantlib.pricingengines.swap import DiscountingSwapEngine
      8 from quantlib.settings import Settings

ImportError: No module named 'quantlib.indexes.euribor'

@dpinte
Copy link
Member

dpinte commented Mar 27, 2015

Something happened in your compilation step. Are you sure you're on the fix/example_swap branch? The fact that you don't have the quantlib.indexes.euribor module shows that it was not cythonized and compiled properly.

What platform do you use? This is the output of the swap.py example for me with the fix in place:

DP-MBP:pyql dpinte (fix/example_swap) $ python examples/swap.py
==================================================================
5-year market swap-rate = 4.43 %
==================================================================
        5-years swap paying 4.00 %
term structure | net present value | fair spread | fair fixed rate
------------------------------------------------------------------
 depo-fut-swap |          19067.30 |   -0.4192 % |        4.4300 %
 depo-FRA-swap |          19055.41 |   -0.4193 % |        4.4300 %
------------------------------------------------------------------
        5-years, 1-year forward swap paying 4.00 %
------------------------------------------------------------------
 depo-fut-swap |          42129.89 |   -0.9710 % |        4.9976 %
 depo-FRA-swap |          37151.83 |   -0.8564 % |        4.8793 %
==================================================================
5-year market swap-rate = 4.60 %
==================================================================
        5-years swap paying 4.00 %
term structure | net present value | fair spread | fair fixed rate
------------------------------------------------------------------
 depo-fut-swap |          26541.00 |   -0.5846 % |        4.6000 %
 depo-FRA-swap |          26524.45 |   -0.5848 % |        4.6000 %
------------------------------------------------------------------
        5-years, 1-year forward swap paying 4.00 %
------------------------------------------------------------------
 depo-fut-swap |          48499.75 |   -1.1217 % |        5.1529 %
 depo-FRA-swap |          42835.30 |   -0.9907 % |        5.0176 %

@dpinte dpinte closed this as completed in #77 Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants