From 25850b8c82b3c8af8bcbd0e0d3daa41dcfe55ee1 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 7 Mar 2025 11:27:19 -0500 Subject: [PATCH 1/9] extend clean_price method --- quantlib/instruments/_bond.pxd | 6 ++++++ quantlib/instruments/bond.pyx | 23 ++++++++++++++++++----- quantlib/mlab/fixed_income.py | 2 +- test/test_bonds.py | 8 ++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/quantlib/instruments/_bond.pxd b/quantlib/instruments/_bond.pxd index bbcbbd67f..2547ae0eb 100644 --- a/quantlib/instruments/_bond.pxd +++ b/quantlib/instruments/_bond.pxd @@ -43,6 +43,12 @@ cdef extern from 'ql/instruments/bond.hpp' namespace 'QuantLib' nogil: Real dirtyPrice() except + Real settlementValue() except + + Rate cleanPrice(Rate y, + DayCounter& dc, + Compounding comp, + Frequency freq, + Date settlementDate) + Rate bond_yield 'yield'( DayCounter& dc, Compounding comp, diff --git a/quantlib/instruments/bond.pyx b/quantlib/instruments/bond.pyx index ce581d5cc..4e678c6d5 100644 --- a/quantlib/instruments/bond.pyx +++ b/quantlib/instruments/bond.pyx @@ -1,4 +1,4 @@ -from quantlib.types cimport Real, Size +from quantlib.types cimport Rate, Real, Size from . cimport _bond cimport quantlib.time._date as _date @@ -75,10 +75,23 @@ cdef class Bond(Instrument): """ Returns the bond settlement date after the given date.""" return date_from_qldate(self.as_ptr().settlementDate(from_date._thisptr)) - @property - def clean_price(self): - """ Bond clean price. """ - return self.as_ptr().cleanPrice() + def clean_price(self, *args): + cdef: + Rate y + DayCounter dc + Compounding comp + Frequency freq + Date settlement_date = Date() + if len(args) == 0: + return self.as_ptr().cleanPrice() + else: + if len(args) == 4: + y, dc, comp, freq = args + else: + y, dc, comp, freq, settlement_date = args + return self.as_ptr().cleanPrice( + y, deref(dc._thisptr), comp, freq, settlement_date._thisptr + ) @property def dirty_price(self): diff --git a/quantlib/mlab/fixed_income.py b/quantlib/mlab/fixed_income.py index 3a1191d5a..31f0660ed 100644 --- a/quantlib/mlab/fixed_income.py +++ b/quantlib/mlab/fixed_income.py @@ -153,7 +153,7 @@ def _bndprice(bond_yield, coupon_rate, pricing_date, maturity_date, bond.set_pricing_engine(engine) - price = bond.clean_price + price = bond.clean_price() ac = bond.accrued_amount(pydate_to_qldate(settlement_date)) return (price, ac) diff --git a/test/test_bonds.py b/test/test_bonds.py index 08625bf70..46786adf1 100644 --- a/test/test_bonds.py +++ b/test/test_bonds.py @@ -104,7 +104,7 @@ def test_pricing_bond(self): self.assertTrue(settings.evaluation_date, bond.valuation_date) # the following assertion fails but must be verified - self.assertAlmostEqual(101.1, bond.clean_price, 1) + self.assertAlmostEqual(101.1, bond.clean_price(), 1) self.assertAlmostEqual(101.1, bond.net_present_value, 1) self.assertAlmostEqual(101.1, bond.dirty_price) self.assertAlmostEqual(0.009851, bond.accrued_amount()) @@ -117,7 +117,7 @@ def test_pricing_bond(self): print('Coupon rate: {:.4%}'.format(coupon_rate)) print('Yield: {:.4%}'.format(bond_yield)) print('Net present value: {:.4f}'.format(bond.net_present_value)) - print('Clean price: {:.4f}'.format(bond.clean_price)) + print('Clean price: {:.4f}'.format(bond.clean_price())) print('Dirty price: {:.4f}'.format(bond.dirty_price)) print('Accrued coupon: {:.6f}'.format(bond.accrued_amount())) print('Accrued coupon: {:.6f}'.format( @@ -192,7 +192,7 @@ def test_excel_example_with_fixed_rate_bond(self): self.assertAlmostEqual( 0.6849, bond.accrued_amount(bond.settlement_date()), 4 ) - self.assertAlmostEqual(102.1154, bond.clean_price, 4) + self.assertAlmostEqual(102.1154, bond.clean_price(), 4) def test_excel_example_with_zero_coupon_bond(self): @@ -228,7 +228,7 @@ def test_excel_example_with_zero_coupon_bond(self): calendar.advance(todays_date, 3, Days), bond.settlement_date() ) self.assertEqual(0., bond.accrued_amount(bond.settlement_date())) - self.assertAlmostEqual(57.6915, bond.clean_price, 4) + self.assertAlmostEqual(57.6915, bond.clean_price(), 4) def test_excel_example_with_floating_rate_bond(self): todays_date = Date(25, August, 2011) From ed45a3d8a3a8f21d475820bcdb758ff485e7161a Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Mon, 27 Feb 2023 15:48:25 -0500 Subject: [PATCH 2/9] fix exception message --- quantlib/termstructures/vol_term_structure.pxd | 1 + quantlib/termstructures/vol_term_structure.pyx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/quantlib/termstructures/vol_term_structure.pxd b/quantlib/termstructures/vol_term_structure.pxd index e8a706ce6..26deb4bdd 100644 --- a/quantlib/termstructures/vol_term_structure.pxd +++ b/quantlib/termstructures/vol_term_structure.pxd @@ -5,6 +5,7 @@ from . cimport _vol_term_structure as _vts cdef class VolatilityTermStructure: cdef shared_ptr[_vts.VolatilityTermStructure] _thisptr cdef _vts.VolatilityTermStructure* as_ptr(self) nogil + @staticmethod cdef Handle[_vts.VolatilityTermStructure] handle(object vol) diff --git a/quantlib/termstructures/vol_term_structure.pyx b/quantlib/termstructures/vol_term_structure.pyx index fca07d717..b2af8504c 100644 --- a/quantlib/termstructures/vol_term_structure.pyx +++ b/quantlib/termstructures/vol_term_structure.pyx @@ -17,7 +17,7 @@ cdef class VolatilityTermStructure: elif isinstance(vol, HandleVolatilityTermStructure): return (vol).handle else: - raise TypeError("vol needs to be either a SwaptionVolatilityStructure or a HandleSwaptionVolatilityStructure") + raise TypeError("vol needs to be either a VolatilityTermStructure or a HandleVolatilityTermStructure") def time_from_reference(self, Date date not None): return self.as_ptr().timeFromReference(date._thisptr) From 5efd38facfcb9afcf70e99b4f02a647f9eec4458 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 8 Mar 2023 16:39:20 -0500 Subject: [PATCH 3/9] reuse Interpolation --- quantlib/math/interpolation.pxd | 19 +++++++++++++++---- .../equityfx/black_variance_surface.pxd | 4 ---- .../equityfx/black_variance_surface.pyx | 13 +++++++------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/quantlib/math/interpolation.pxd b/quantlib/math/interpolation.pxd index 59a4dc05f..4d02b2b31 100644 --- a/quantlib/math/interpolation.pxd +++ b/quantlib/math/interpolation.pxd @@ -1,18 +1,29 @@ cimport cython from . cimport _interpolations as _intpl +cdef class Interpolation: + pass + @cython.final -cdef class Linear: +cdef class Linear(Interpolation): cdef _intpl.Linear _thisptr @cython.final -cdef class LogLinear: +cdef class LogLinear(Interpolation): cdef _intpl.LogLinear _thisptr @cython.final -cdef class BackwardFlat: +cdef class BackwardFlat(Interpolation): cdef _intpl.BackwardFlat _thisptr @cython.final -cdef class Cubic: +cdef class Cubic(Interpolation): cdef _intpl.Cubic _thisptr + +@cython.final +cdef class Bicubic(Interpolation): + cdef _intpl.Bicubic _thisptr + +@cython.final +cdef class Bilinear(Interpolation): + cdef _intpl.Bilinear _thisptr diff --git a/quantlib/termstructures/volatility/equityfx/black_variance_surface.pxd b/quantlib/termstructures/volatility/equityfx/black_variance_surface.pxd index c191dc4d6..0dbcb3616 100644 --- a/quantlib/termstructures/volatility/equityfx/black_variance_surface.pxd +++ b/quantlib/termstructures/volatility/equityfx/black_variance_surface.pxd @@ -5,9 +5,5 @@ cdef extern from 'ql/termstructures/volatility/equityfx/blackvariancesurface.hpp ConstantExtrapolation InterpolatorDefaultExtrapolation -cpdef enum Interpolator: - Bilinear - Bicubic - cdef class BlackVarianceSurface(BlackVarianceTermStructure): pass diff --git a/quantlib/termstructures/volatility/equityfx/black_variance_surface.pyx b/quantlib/termstructures/volatility/equityfx/black_variance_surface.pyx index 109b10aaf..621960715 100644 --- a/quantlib/termstructures/volatility/equityfx/black_variance_surface.pyx +++ b/quantlib/termstructures/volatility/equityfx/black_variance_surface.pyx @@ -6,7 +6,8 @@ from libcpp.vector cimport vector from quantlib.handle cimport shared_ptr from quantlib.math.matrix cimport Matrix -cimport quantlib.math._interpolations as intpl +from quantlib.math.interpolation cimport Interpolation, Bilinear, Bicubic + from quantlib.time.date cimport Date, date_from_qldate from quantlib.time._date cimport Date as _Date from quantlib.time.calendar cimport Calendar @@ -89,10 +90,10 @@ cdef class BlackVarianceSurface(BlackVarianceTermStructure): return get_bvs(self).maxStrike() # Modifiers - def set_interpolation(self, Interpolator i): - if i == Bilinear: - get_bvs(self).setInterpolation[intpl.Bilinear]() # Calls the default constructor - elif i == Bicubic: - get_bvs(self).setInterpolation[intpl.Bicubic]() + def set_interpolation(self, Interpolation i): + if isinstance(i, Bicubic): + get_bvs(self).setInterpolation((i)._thisptr) # Calls the default constructor + elif isinstance(i, Bilinear): + get_bvs(self).setInterpolation((i)._thisptr) else: raise ValueError("Interpolator must be Bilinear or Bicubic") From f1d9a2b75e2e8e3efe2c87b6cd44e47704ce5a75 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 5 Mar 2025 22:02:33 -0500 Subject: [PATCH 4/9] InterestRate: make it more useful --- quantlib/_interest_rate.pxd | 13 ++++++++++--- quantlib/interest_rate.pyx | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/quantlib/_interest_rate.pxd b/quantlib/_interest_rate.pxd index aff1c187e..44f466a3d 100644 --- a/quantlib/_interest_rate.pxd +++ b/quantlib/_interest_rate.pxd @@ -6,10 +6,9 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. """ - -include 'types.pxi' - +from quantlib.types cimport DiscountFactor, Rate, Real, Time from libcpp.string cimport string +from quantlib.time._date cimport Date from quantlib.time._daycounter cimport DayCounter from quantlib.time._period cimport Frequency from quantlib.compounding cimport Compounding @@ -29,6 +28,10 @@ cdef extern from 'ql/interestrate.hpp' namespace 'QuantLib' nogil: Frequency frequency() DiscountFactor discountFactor(Time t) + DiscountFactor discountFactor(const Date& d1, + const Date &d2, + const Date& refStart, + const Date& refEnd) InterestRate impliedRate(Real compound, const DayCounter& resultDC, Compounding comp, @@ -39,6 +42,10 @@ cdef extern from 'ql/interestrate.hpp' namespace 'QuantLib' nogil: Frequency freq, Time t) Real compoundFactor(Time t) + Real compoundFactor(const Date& d1, + const Date &d2, + const Date& refStart, + const Date& refEnd) cdef extern from "" namespace "std": cdef cppclass stringstream: diff --git a/quantlib/interest_rate.pyx b/quantlib/interest_rate.pyx index faf128101..bf95779ef 100644 --- a/quantlib/interest_rate.pyx +++ b/quantlib/interest_rate.pyx @@ -4,13 +4,10 @@ # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the license for more details. - -include 'types.pxi' - +from quantlib.types cimport Rate, Real, Time from cython.operator cimport dereference as deref -from quantlib.handle cimport shared_ptr - +from quantlib.time.date cimport Date from quantlib.time.daycounter cimport DayCounter cimport quantlib.time._daycounter as _daycounter from quantlib.compounding cimport Compounding @@ -25,12 +22,11 @@ cdef class InterestRate: """ - def __init__(self, double rate, DayCounter dc not None, Compounding compounding, - int frequency): + def __init__(self, Rate rate, DayCounter dc not None, Compounding compounding, + Frequency frequency): self._thisptr = _ir.InterestRate( - rate, deref(dc._thisptr), compounding, - <_ir.Frequency>frequency + rate, deref(dc._thisptr), compounding, frequency ) @@ -68,8 +64,11 @@ cdef class InterestRate: ss << self._thisptr return ss.str().decode() - def compound_factor(self, Time t): - return self._thisptr.compoundFactor(t) + def compound_factor(self, Date d1, Date d2, Date ref_start=Date(), Date ref_end=Date()): + return self._thisptr.compoundFactor(d1._thisptr, d2._thisptr, ref_start._thisptr, ref_end._thisptr) + + def discount_factor(self, Date d1, Date d2, Date ref_start=Date(), Date ref_end=Date()): + return self._thisptr.discountFactor(d1._thisptr, d2._thisptr, ref_start._thisptr, ref_end._thisptr) def implied_rate(self, Real compound, DayCounter result_dc not None, From 2218355fa84900c0f6d3e19ce2524fa5db68febe Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 17 Jul 2026 11:39:45 -0400 Subject: [PATCH 5/9] fix test --- test/test_hullwhite_model.py | 5 +---- test/test_inflation.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/test_hullwhite_model.py b/test/test_hullwhite_model.py index 8374b510d..d271930d2 100644 --- a/test/test_hullwhite_model.py +++ b/test/test_hullwhite_model.py @@ -1,6 +1,3 @@ -from __future__ import division -from __future__ import print_function - import unittest from quantlib.models.shortrate.onefactormodels.hullwhite import HullWhite @@ -59,7 +56,7 @@ def test_hull_white_calibration(self): ) ) - model = HullWhite(yield_ts, a=0.05, sigma=.005) + model = HullWhite(yield_ts, a=0.1, sigma=.01) data = [[1, 5, 0.1148 ], [2, 4, 0.1108 ], diff --git a/test/test_inflation.py b/test/test_inflation.py index 1fd82ac19..c2eb741d2 100644 --- a/test/test_inflation.py +++ b/test/test_inflation.py @@ -140,7 +140,7 @@ def test_clean_price(self): cpi_bond.set_pricing_engine(engine) set_coupon_pricer(cpi_bond.cashflows, CPICouponPricer(self.yts)) storedPrice = 383.054224764 - calculated = cpi_bond.clean_price + calculated = cpi_bond.clean_price() self.assertAlmostEqual(storedPrice, calculated) if __name__ == '__main__': From 4efef47bc094ece9b537c2ab2b9f5473369d3341 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 23 Apr 2025 15:01:09 -0400 Subject: [PATCH 6/9] allow to relink HandleDefaultProbabilityTermStructure --- quantlib/termstructures/default_term_structure.pyx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/quantlib/termstructures/default_term_structure.pyx b/quantlib/termstructures/default_term_structure.pyx index f94c2f0e1..e3ff4fc11 100644 --- a/quantlib/termstructures/default_term_structure.pyx +++ b/quantlib/termstructures/default_term_structure.pyx @@ -47,3 +47,17 @@ cdef class HandleDefaultProbabilityTermStructure: self.handle = RelinkableHandle[_dts.DefaultProbabilityTermStructure]( static_pointer_cast[_dts.DefaultProbabilityTermStructure](ts._thisptr), register_as_observer) + + @property + def current_link(self): + cdef DefaultProbabilityTermStructure instance = DefaultProbabilityTermStructure.__new__(DefaultProbabilityTermStructure) + if self.handle.empty(): + raise ValueError("empty handle") + instance._thisptr = self.handle.currentLink() + return instance + + def link_to(self, DefaultProbabilityTermStructure ts, bool register_as_observer=True): + self.handle.linkTo( + static_pointer_cast[_dts.DefaultProbabilityTermStructure](ts._thisptr), + register_as_observer + ) From f08f3a25d4f9e0b3f452359d79d1d79affeff54d Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Tue, 6 May 2025 15:37:30 -0400 Subject: [PATCH 7/9] nogil --- quantlib/time/_period.pxd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quantlib/time/_period.pxd b/quantlib/time/_period.pxd index 2f54565eb..74a89a888 100644 --- a/quantlib/time/_period.pxd +++ b/quantlib/time/_period.pxd @@ -4,7 +4,7 @@ from libcpp.string cimport string from .frequency cimport Frequency -cdef extern from 'ql/time/timeunit.hpp' namespace "QuantLib": +cdef extern from 'ql/time/timeunit.hpp' namespace "QuantLib" nogil: cdef enum TimeUnit: Days Weeks @@ -16,7 +16,7 @@ cdef extern from 'ql/time/timeunit.hpp' namespace "QuantLib": Milliseconds Microseconds -cdef extern from 'ql/time/period.hpp' namespace "QuantLib": +cdef extern from 'ql/time/period.hpp' namespace "QuantLib" nogil: cdef cppclass Period: @@ -52,20 +52,20 @@ cdef extern from 'ql/time/period.hpp' namespace "QuantLib": Real weeks(const Period& p) except + Real days(const Period& p) except + -cdef extern from 'ql/utilities/dataparsers.hpp' namespace "QuantLib::PeriodParser": +cdef extern from 'ql/utilities/dataparsers.hpp' namespace "QuantLib::PeriodParser" nogil: Period parse(string& str) except + -cdef extern from "ql/time/period.hpp" namespace "QuantLib::detail": +cdef extern from "ql/time/period.hpp" namespace "QuantLib::detail" nogil: cdef cppclass long_period_holder: pass cdef cppclass short_period_holder: pass -cdef extern from "ql/time/period.hpp" namespace "QuantLib::io": +cdef extern from "ql/time/period.hpp" namespace "QuantLib::io" nogil: cdef short_period_holder short_period(const Period&) cdef long_period_holder long_period(const Period&) -cdef extern from "" namespace "std": +cdef extern from "" namespace "std" nogil: cdef cppclass stringstream: stringstream& operator<<(long_period_holder) stringstream& operator<<(short_period_holder) From 5f4444026fb1e8b8f9e76dcade9bc32b222705b7 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Thu, 8 May 2025 16:52:53 -0400 Subject: [PATCH 8/9] add functions to bondfunctions --- .../pricingengines/bond/_bondfunctions.pxd | 11 ++++++++ .../pricingengines/bond/bondfunctions.pyx | 28 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/quantlib/pricingengines/bond/_bondfunctions.pxd b/quantlib/pricingengines/bond/_bondfunctions.pxd index b58f921b3..0c41398c8 100644 --- a/quantlib/pricingengines/bond/_bondfunctions.pxd +++ b/quantlib/pricingengines/bond/_bondfunctions.pxd @@ -15,6 +15,17 @@ cdef extern from 'ql/pricingengines/bond/bondfunctions.hpp' namespace 'QuantLib: cdef Date startDate(Bond bond) cdef Leg.const_reverse_iterator previousCashFlow(const Bond& bond, Date refDate) # = Date() + cdef Leg.const_iterator nextCashFlow(const Bond& bond, + Date refDate) # = Date() + + cdef Date previousCashFlowDate(const Bond& bond, + Date refDate) + cdef Date nextCashFlowDate(const Bond& bond, + Date refDate) + cdef Real previousCashFlowAmount(const Bond& bond, + Date refDate) + cdef Real nextCashFlowAmount(const Bond& bond, + Date refDate) cdef Time duration(Bond bond, Rate yld, DayCounter dayCounter, diff --git a/quantlib/pricingengines/bond/bondfunctions.pyx b/quantlib/pricingengines/bond/bondfunctions.pyx index d68710260..0fb0cd73c 100644 --- a/quantlib/pricingengines/bond/bondfunctions.pyx +++ b/quantlib/pricingengines/bond/bondfunctions.pyx @@ -20,13 +20,37 @@ def start_date(Bond bond): return date_from_qldate(_bf.startDate(deref(bond.as_ptr()))) def previous_cash_flow(Bond bond, Date ref_date=Date()): - cdef Leg.const_reverse_iterator it = _bf.previousCashFlow(deref(bond.as_ptr()), ref_date._thisptr) + cdef Leg.const_reverse_iterator it = _bf.previousCashFlow(deref(bond.as_ptr()), ref_date._thisptr) cdef CashFlow cf = CashFlow.__new__(CashFlow) - while it != bond.as_ptr().cashflows().const_rbegin(): + while it != bond.as_ptr().cashflows().const_rend(): cf._thisptr = deref(it) yield cf preinc(it) +def next_cash_flow(Bond bond, Date ref_date=Date()): + cdef Leg.const_iterator it = _bf.nextCashFlow(deref(bond.as_ptr()), ref_date._thisptr) + cdef CashFlow cf = CashFlow.__new__(CashFlow) + while it != bond.as_ptr().cashflows().const_end(): + cf._thisptr = deref(it) + yield cf + preinc(it) + + +def previous_cash_flow_date(Bond bond, Date ref_date=Date()): + cdef Date d = Date.__new__(Date) + d._thisptr = _bf.previousCashFlowDate(deref(bond.as_ptr()), ref_date._thisptr) + return d + +def next_cash_flow_date(Bond bond, Date ref_date=Date()): + cdef Date d = Date.__new__(Date) + d._thisptr = _bf.nextCashFlowDate(deref(bond.as_ptr()), ref_date._thisptr) + return d + +def previous_cash_flow_amount(Bond bond, Date ref_date=Date()): + return _bf.previousCashFlowAmount(deref(bond.as_ptr()), ref_date._thisptr) + +def next_cash_flow_amount(Bond bond, Date ref_date=Date()): + return _bf.nextCashFlowAmount(deref(bond.as_ptr()), ref_date._thisptr) def duration(Bond bond not None, Rate yld, From c8eb00f240426d348be855c0d81380a5319d7694 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Tue, 20 May 2025 13:03:33 -0400 Subject: [PATCH 9/9] bufgix --- .../yields/piecewise_zerospreaded_termstructure.pyx | 4 ++-- .../termstructures/yields/zero_spreaded_term_structure.pyx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/quantlib/termstructures/yields/piecewise_zerospreaded_termstructure.pyx b/quantlib/termstructures/yields/piecewise_zerospreaded_termstructure.pyx index 1fb29ea7e..3bc459056 100644 --- a/quantlib/termstructures/yields/piecewise_zerospreaded_termstructure.pyx +++ b/quantlib/termstructures/yields/piecewise_zerospreaded_termstructure.pyx @@ -1,6 +1,6 @@ from cython.operator cimport dereference as deref from libcpp.vector cimport vector -from quantlib.compounding cimport Compounding, Continuous +from quantlib.compounding cimport Compounding from quantlib.handle cimport Handle from quantlib.time.daycounter cimport DayCounter from quantlib.time.frequency cimport Frequency, NoFrequency @@ -13,7 +13,7 @@ from . cimport _piecewise_zerospreaded_termstructure as _pzt cdef class PiecewiseZeroSpreadedTermStructure(YieldTermStructure): def __init__(self, HandleYieldTermStructure h not None, list spreads, list dates, - Compounding comp=Continuous, Frequency freq=NoFrequency, + Compounding comp=Compounding.Continuous, Frequency freq=NoFrequency, DayCounter dc not None=DayCounter()): cdef vector[Handle[_qt.Quote]] spreads_vec cdef vector[QlDate] dates_vec diff --git a/quantlib/termstructures/yields/zero_spreaded_term_structure.pyx b/quantlib/termstructures/yields/zero_spreaded_term_structure.pyx index 956c568c2..0bcd4aa98 100644 --- a/quantlib/termstructures/yields/zero_spreaded_term_structure.pyx +++ b/quantlib/termstructures/yields/zero_spreaded_term_structure.pyx @@ -1,5 +1,5 @@ from cython.operator cimport dereference as deref -from quantlib.compounding cimport Compounding, Continuous +from quantlib.compounding cimport Compounding from quantlib.termstructures.yield_term_structure cimport HandleYieldTermStructure from quantlib.time.daycounter cimport DayCounter from quantlib.time.frequency cimport Frequency, NoFrequency @@ -8,7 +8,7 @@ from . cimport _zero_spreaded_term_structure as _zsts cdef class ZeroSpreadedTermStructure(YieldTermStructure): def __init__(self, HandleYieldTermStructure h not None, Quote spread, - Compounding comp=Continuous, Frequency freq=NoFrequency, + Compounding comp=Compounding.Continuous, Frequency freq=NoFrequency, DayCounter dc not None=DayCounter()): self._thisptr.reset(