diff --git a/quantlib/pricingengines/bond/__init__.py b/quantlib/pricingengines/bond/__init__.py new file mode 100644 index 000000000..66c6a96f9 --- /dev/null +++ b/quantlib/pricingengines/bond/__init__.py @@ -0,0 +1 @@ +from .discountingbondengine import DiscountingBondEngine diff --git a/quantlib/pricingengines/_bondfunctions.pxd b/quantlib/pricingengines/bond/_bondfunctions.pxd similarity index 96% rename from quantlib/pricingengines/_bondfunctions.pxd rename to quantlib/pricingengines/bond/_bondfunctions.pxd index 1bf062a49..5e04934bd 100644 --- a/quantlib/pricingengines/_bondfunctions.pxd +++ b/quantlib/pricingengines/bond/_bondfunctions.pxd @@ -1,4 +1,4 @@ -include '../types.pxi' +from quantlib.types cimport Rate, Real, Spread, Size, Time from quantlib.instruments._bond cimport Bond from quantlib.handle cimport shared_ptr diff --git a/quantlib/pricingengines/_bond.pxd b/quantlib/pricingengines/bond/_discountingbondengine.pxd similarity index 94% rename from quantlib/pricingengines/_bond.pxd rename to quantlib/pricingengines/bond/_discountingbondengine.pxd index fb3fc5796..197a59b5a 100644 --- a/quantlib/pricingengines/_bond.pxd +++ b/quantlib/pricingengines/bond/_discountingbondengine.pxd @@ -13,11 +13,9 @@ from quantlib.handle cimport Handle, optional from quantlib.termstructures._yield_term_structure cimport YieldTermStructure cdef extern from 'ql/pricingengines/bond/discountingbondengine.hpp' namespace \ - 'QuantLib': + 'QuantLib' nogil: cdef cppclass DiscountingBondEngine(PricingEngine): - - DiscountingBondEngine() DiscountingBondEngine(Handle[YieldTermStructure]& discountCurve) DiscountingBondEngine(Handle[YieldTermStructure]& discountCurve, optional[bool] includeSettlementDateFlows) diff --git a/quantlib/pricingengines/bondfunctions.pyx b/quantlib/pricingengines/bond/bondfunctions.pyx similarity index 97% rename from quantlib/pricingengines/bondfunctions.pyx rename to quantlib/pricingengines/bond/bondfunctions.pyx index 314b0fb26..5aa82ba22 100644 --- a/quantlib/pricingengines/bondfunctions.pyx +++ b/quantlib/pricingengines/bond/bondfunctions.pyx @@ -1,9 +1,8 @@ -include '../types.pxi' - +from quantlib.types cimport Rate, Real, Size from quantlib.time._date cimport Day, Month, Year, Date as QLDate from quantlib.time._period cimport Frequency from quantlib.time._daycounter cimport DayCounter as _DayCounter -cimport quantlib.pricingengines._bondfunctions as _bf +from . cimport _bondfunctions as _bf from quantlib.handle cimport shared_ptr, Handle from cython.operator cimport dereference as deref diff --git a/quantlib/pricingengines/bond.pyx b/quantlib/pricingengines/bond/discountingbondengine.pyx similarity index 58% rename from quantlib/pricingengines/bond.pyx rename to quantlib/pricingengines/bond/discountingbondengine.pyx index 317ddad56..b17565d86 100644 --- a/quantlib/pricingengines/bond.pyx +++ b/quantlib/pricingengines/bond/discountingbondengine.pyx @@ -5,15 +5,10 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. """ -from cython.operator cimport dereference as deref +from . cimport _discountingbondengine as _dbe -from quantlib.handle cimport Handle, shared_ptr -from .cimport _pricing_engine as _pe -from . cimport _bond +from ..engine cimport PricingEngine -from .engine cimport PricingEngine - -cimport quantlib.termstructures._yield_term_structure as _yts from quantlib.termstructures.yield_term_structure cimport YieldTermStructure cdef class DiscountingBondEngine(PricingEngine): @@ -22,4 +17,4 @@ cdef class DiscountingBondEngine(PricingEngine): """ """ - self._thisptr.reset(new _bond.DiscountingBondEngine(discount_curve._thisptr)) + self._thisptr.reset(new _dbe.DiscountingBondEngine(discount_curve._thisptr)) diff --git a/test/test_bondfunctions.py b/test/test_bondfunctions.py index 49a3c4eb5..51ea9cfd6 100644 --- a/test/test_bondfunctions.py +++ b/test/test_bondfunctions.py @@ -34,7 +34,7 @@ from quantlib.math.interpolation import LogLinear from quantlib.quotes import SimpleQuote -import quantlib.pricingengines.bondfunctions as bf +import quantlib.pricingengines.bond.bondfunctions as bf class BondFunctionTestCase(unittest.TestCase): diff --git a/test/test_sensitivity_analysis.py b/test/test_sensitivity_analysis.py index 66d5ea73e..84e177f6c 100644 --- a/test/test_sensitivity_analysis.py +++ b/test/test_sensitivity_analysis.py @@ -33,7 +33,7 @@ AnalyticEuropeanEngine ) from quantlib.instruments.payoffs import PlainVanillaPayoff -import quantlib.pricingengines.bondfunctions as bf +import quantlib.pricingengines.bond.bondfunctions as bf from quantlib.experimental.risk.sensitivityanalysis import ( bucket_analysis, parallel_analysis, Centered) from numpy.testing import assert_allclose