Loic Rougier
Loic Rougier

Reputation: 41

Quantlib-python No constructor defined

I am trying to instanciate the class Forward as below

import  QuantLib as ql

calculation_date = ql.Date().todaysDate()

ql.Settings.instance().evaluationDate = calculation_date

day_count = ql.Thirty360()

yield_ts_handle = ql.YieldTermStructureHandle(
    ql.FlatForward(calculation_date, -30e-4, day_count)
)
dividend_ts_handle = ql.YieldTermStructureHandle(
    ql.FlatForward(calculation_date, 25e-4, day_count)
)

fwd = ql.Forward(
    ql.Date(16,5,2022),
    ql.UnitedStates(),
    ql.Following,
    yield_ts_handle,
    dividend_ts_handle,
    False,
    230,
    0
)

Python console gives me this

fwd = ql.Forward()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\Loic\AppData\Local\Programs\Python\Python38-32\lib\site-packages\QuantLib\QuantLib.py", line 20974, in __init__
    raise AttributeError("No constructor defined")
AttributeError: No constructor defined

Is this class transposed from C++ to python?

Upvotes: 3

Views: 1188

Answers (1)

David Duarte
David Duarte

Reputation: 664

The Forward class you are using is an abstract class used to create the FixedRateBondForward and ForwardRateAgreement (FRA) classes.

You should use one of these two.

Upvotes: 2

Related Questions