From 8b9d0bac9b6852164ad01929f9f59bda793bfd7b Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 3 Mar 2023 11:13:09 -0500 Subject: [PATCH] rename to DateGeneration --- quantlib/instruments/_bonds.pxd | 4 ++-- quantlib/instruments/_credit_default_swap.pxd | 4 ++-- quantlib/instruments/_make_cds.pxd | 4 ++-- quantlib/instruments/_make_cms.pxd | 6 +++--- quantlib/instruments/_make_ois.pxd | 4 ++-- quantlib/instruments/_make_vanilla_swap.pxd | 8 ++++---- quantlib/instruments/credit_default_swap.pyx | 6 +++--- quantlib/instruments/make_cds.pyx | 4 ++-- quantlib/instruments/make_ois.pyx | 4 ++-- quantlib/instruments/make_vanilla_swap.pyx | 4 ++-- quantlib/market/market.py | 8 ++++---- quantlib/mlab/fixed_income.py | 6 +++--- quantlib/termstructures/credit/_credit_helpers.pxd | 12 ++++++------ .../credit/default_probability_helpers.pyx | 12 ++++++------ quantlib/time/_schedule.pxd | 8 ++++---- quantlib/time/api.py | 2 +- quantlib/time/dategeneration.pxd | 2 +- quantlib/time/schedule.pyx | 12 ++++++------ test/test_bermudan_swaption.py | 6 +++--- test/test_bond_helpers.py | 4 ++-- test/test_bondfunctions.py | 4 ++-- test/test_bonds.py | 8 ++++---- test/test_cds.py | 9 ++++----- test/test_credit_termstructures.py | 4 ++-- test/test_cython_bug.pyx | 4 ++-- test/test_inflation.py | 4 ++-- test/test_schedule.py | 12 ++++++------ test/test_sensitivity_analysis.py | 4 ++-- test/test_settings.py | 6 +++--- test/test_swap.py | 6 +++--- 30 files changed, 90 insertions(+), 91 deletions(-) diff --git a/quantlib/instruments/_bonds.pxd b/quantlib/instruments/_bonds.pxd index 88914bb58..b85af6823 100644 --- a/quantlib/instruments/_bonds.pxd +++ b/quantlib/instruments/_bonds.pxd @@ -13,7 +13,7 @@ from quantlib.time._schedule cimport Schedule from quantlib._cashflow cimport Leg from quantlib.indexes._ibor_index cimport IborIndex from quantlib.indexes._inflation_index cimport ZeroInflationIndex -from quantlib.time._schedule cimport Rule +from quantlib.time._schedule cimport DateGeneration from quantlib._compounding cimport Compounding cdef extern from 'ql/instruments/bond.hpp' namespace 'QuantLib': @@ -110,7 +110,7 @@ cdef extern from 'ql/instruments/bonds/floatingratebond.hpp' namespace 'QuantLib Real redemption, Date& issueDate, Date& stubDate, - Rule rule) except + + DateGeneration rule) except + cdef extern from 'ql/cashflows/cpicoupon.hpp' namespace 'QuantLib::CPI': cdef enum InterpolationType: diff --git a/quantlib/instruments/_credit_default_swap.pxd b/quantlib/instruments/_credit_default_swap.pxd index a6c28ceff..375efea8d 100644 --- a/quantlib/instruments/_credit_default_swap.pxd +++ b/quantlib/instruments/_credit_default_swap.pxd @@ -8,7 +8,7 @@ from quantlib._cashflow cimport CashFlow, Leg from quantlib.time._calendar cimport BusinessDayConvention from quantlib.time._date cimport Date, Period from quantlib.time._daycounter cimport DayCounter -from quantlib.time._schedule cimport Schedule, Rule +from quantlib.time._schedule cimport Schedule, DateGeneration cdef extern from 'ql/default.hpp' namespace 'QuantLib::Protection': enum Side: @@ -95,4 +95,4 @@ cdef extern from 'ql/instruments/creditdefaultswap.hpp' namespace 'QuantLib': Real accuracy, # = 1.0e-8 PricingModel model # = Midpoint ) except + - Date cdsMaturity(const Date& tradeDate, const Period& tenor, Rule rule) except +ValueError + Date cdsMaturity(const Date& tradeDate, const Period& tenor, DateGeneration rule) except +ValueError diff --git a/quantlib/instruments/_make_cds.pxd b/quantlib/instruments/_make_cds.pxd index d09924062..0de185c6d 100644 --- a/quantlib/instruments/_make_cds.pxd +++ b/quantlib/instruments/_make_cds.pxd @@ -6,7 +6,7 @@ from quantlib.time._calendar cimport Calendar from quantlib.time._daycounter cimport DayCounter from quantlib.time._date cimport Date from quantlib.time._period cimport Period -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from ._credit_default_swap cimport Side, CreditDefaultSwap cdef extern from 'ql/instruments/makecds.hpp' namespace 'QuantLib': @@ -28,7 +28,7 @@ cdef extern from 'ql/instruments/makecds.hpp' namespace 'QuantLib': MakeCreditDefaultSwap& withCouponTenor(Period) MakeCreditDefaultSwap& withDayCounter(DayCounter&) MakeCreditDefaultSwap& withLastPeriodDayCounter(DayCounter&) - MakeCreditDefaultSwap& withDateGenerationRule(Rule rule) + MakeCreditDefaultSwap& withDateGenerationRule(DateGeneration rule) MakeCreditDefaultSwap& withCashSettlementDays(Natural cashSettlementDays) MakeCreditDefaultSwap& withPricingEngine(const shared_ptr[PricingEngine]&) diff --git a/quantlib/instruments/_make_cms.pxd b/quantlib/instruments/_make_cms.pxd index 0d43bdc95..88b3cef07 100644 --- a/quantlib/instruments/_make_cms.pxd +++ b/quantlib/instruments/_make_cms.pxd @@ -10,7 +10,7 @@ from quantlib.time._calendar cimport Calendar from quantlib.time._daycounter cimport DayCounter from quantlib.time._date cimport Date from quantlib.time._period cimport Period -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.handle cimport Handle from quantlib.termstructures._yield_term_structure cimport YieldTermStructure @@ -34,7 +34,7 @@ cdef extern from 'ql/instruments/makecms.hpp' namespace 'QuantLib': MakeCms& withCmsLegCalendar(const Calendar& cal) MakeCms& withCmsLegConvention(BusinessDayConvention bdc) MakeCms& withCmsLegTerminationDateConvention(BusinessDayConvention) - MakeCms& withCmsLegRule(Rule r) + MakeCms& withCmsLegRule(DateGeneration r) MakeCms& withCmsLegEndOfMonth(bool flag = True) MakeCms& withCmsLegFirstDate(const Date& d) MakeCms& withCmsLegNextToLastDate(const Date& d) @@ -45,7 +45,7 @@ cdef extern from 'ql/instruments/makecms.hpp' namespace 'QuantLib': MakeCms& withFloatingLegConvention(BusinessDayConvention bdc) MakeCms& withFloatingLegTerminationDateConvention( BusinessDayConvention bdc) - MakeCms& withFloatingLegRule(Rule r) + MakeCms& withFloatingLegRule(DateGeneration r) MakeCms& withFloatingLegEndOfMonth(bool flag = True) MakeCms& withFloatingLegFirstDate(const Date& d) MakeCms& withFloatingLegNextToLastDate(const Date& d) diff --git a/quantlib/instruments/_make_ois.pxd b/quantlib/instruments/_make_ois.pxd index e35f73f0e..d1ebc5bf7 100644 --- a/quantlib/instruments/_make_ois.pxd +++ b/quantlib/instruments/_make_ois.pxd @@ -2,7 +2,7 @@ from quantlib.types cimport Natural, Real, Rate, Spread from quantlib.handle cimport shared_ptr, Handle from libcpp cimport bool from quantlib.time.businessdayconvention cimport BusinessDayConvention -from quantlib.time._schedule cimport Rule +from quantlib.time._schedule cimport DateGeneration from quantlib.time._date cimport Date from quantlib.time._period cimport Period, Frequency from quantlib.time._daycounter cimport DayCounter @@ -30,7 +30,7 @@ cdef extern from 'ql/instruments/makeois.hpp' namespace 'QuantLib': MakeOIS& withSettlementDays(Natural settlementDays) MakeOIS& withEffectiveDate(const Date&) MakeOIS& withTerminationDate(const Date&) - MakeOIS& withRule(Rule r) + MakeOIS& withRule(DateGeneration r) MakeOIS& withPaymentFrequency(Frequency f) MakeOIS& withPaymentAdjustment(BusinessDayConvention convention) diff --git a/quantlib/instruments/_make_vanilla_swap.pxd b/quantlib/instruments/_make_vanilla_swap.pxd index 9e83b3f43..cb109c287 100644 --- a/quantlib/instruments/_make_vanilla_swap.pxd +++ b/quantlib/instruments/_make_vanilla_swap.pxd @@ -6,7 +6,7 @@ from quantlib.time._date cimport Date from quantlib.time._period cimport Period from quantlib.time._calendar cimport Calendar from quantlib.time.businessdayconvention cimport BusinessDayConvention -from quantlib.time._schedule cimport Rule +from quantlib.time._schedule cimport DateGeneration from quantlib.time._daycounter cimport DayCounter from quantlib.indexes._ibor_index cimport IborIndex from quantlib.instruments._vanillaswap cimport VanillaSwap @@ -30,14 +30,14 @@ cdef extern from 'ql/instruments/makevanillaswap.hpp' namespace 'QuantLib': MakeVanillaSwap& withSettlementDays(Natural settlementDays) MakeVanillaSwap& withEffectiveDate(const Date&) MakeVanillaSwap& withTerminationDate(const Date&) - MakeVanillaSwap& withRule(Rule r) + MakeVanillaSwap& withRule(DateGeneration r) MakeVanillaSwap& withFixedLegTenor(const Period& t) MakeVanillaSwap& withFixedLegCalendar(const Calendar& cal) MakeVanillaSwap& withFixedLegConvention(BusinessDayConvention bdc) MakeVanillaSwap& withFixedLegTerminationDateConvention( BusinessDayConvention bdc) - MakeVanillaSwap& withFixedLegRule(Rule r) + MakeVanillaSwap& withFixedLegRule(DateGeneration r) MakeVanillaSwap& withFixedLegEndOfMonth(bool flag) # = true) MakeVanillaSwap& withFixedLegFirstDate(const Date& d) MakeVanillaSwap& withFixedLegNextToLastDate(const Date& d) @@ -48,7 +48,7 @@ cdef extern from 'ql/instruments/makevanillaswap.hpp' namespace 'QuantLib': MakeVanillaSwap& withFloatingLegConvention(BusinessDayConvention bdc) MakeVanillaSwap& withFloatingLegTerminationDateConvention( BusinessDayConvention bdc) - MakeVanillaSwap& withFloatingLegRule(Rule r) + MakeVanillaSwap& withFloatingLegRule(DateGeneration r) MakeVanillaSwap& withFloatingLegEndOfMonth(bool flag)# = true) MakeVanillaSwap& withFloatingLegFirstDate(const Date& d) MakeVanillaSwap& withFloatingLegNextToLastDate(const Date& d) diff --git a/quantlib/instruments/credit_default_swap.pyx b/quantlib/instruments/credit_default_swap.pyx index 797e4147c..fe35b14f3 100644 --- a/quantlib/instruments/credit_default_swap.pyx +++ b/quantlib/instruments/credit_default_swap.pyx @@ -17,7 +17,7 @@ cimport quantlib.instruments._credit_default_swap as _cds cimport quantlib._instrument as _instrument cimport quantlib.pricingengines._pricing_engine as _pe cimport quantlib.time._calendar as _calendar -cimport quantlib.time._schedule as _schedule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.termstructures.yield_term_structure cimport YieldTermStructure from quantlib.pricingengines.engine cimport PricingEngine @@ -328,14 +328,14 @@ cdef class CreditDefaultSwap(Instrument): <_cds.PricingModel>model) -def cds_maturity(Date trade_date, Period tenor, _schedule.Rule rule): +def cds_maturity(Date trade_date, Period tenor, DateGeneration rule): """Computes a CDS maturity date. Parameters ---------- trade_date : Date tenor : Period - rule : Rule + rule : DateGeneration Returns ------- diff --git a/quantlib/instruments/make_cds.pyx b/quantlib/instruments/make_cds.pyx index 3db6f8742..c4f870f3a 100644 --- a/quantlib/instruments/make_cds.pyx +++ b/quantlib/instruments/make_cds.pyx @@ -5,7 +5,7 @@ from quantlib.handle cimport static_pointer_cast, shared_ptr from quantlib.time.date cimport Date, Period from quantlib.time.daycounter cimport DayCounter from quantlib.time._date cimport Date as QlDate, Period as QlPeriod -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.pricingengines.engine cimport PricingEngine from . cimport _credit_default_swap as _cds from .. cimport _instrument as _in @@ -51,7 +51,7 @@ cdef class MakeCreditDefaultSwap: self._thisptr.withLastPeriodDayCounter(deref(dc._thisptr)) return self - def with_date_generation_rule(self, Rule rule): + def with_date_generation_rule(self, DateGeneration rule): self._thisptr.withDateGenerationRule(rule) return self diff --git a/quantlib/instruments/make_ois.pyx b/quantlib/instruments/make_ois.pyx index 6d84109e2..afc7102f5 100644 --- a/quantlib/instruments/make_ois.pyx +++ b/quantlib/instruments/make_ois.pyx @@ -9,7 +9,7 @@ from quantlib.time._period cimport Days, Frequency from quantlib.time.businessdayconvention cimport BusinessDayConvention from quantlib.time.calendar cimport Calendar from quantlib.time.daycounter cimport DayCounter -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.termstructures.yield_term_structure cimport YieldTermStructure from quantlib.pricingengines.engine cimport PricingEngine cimport quantlib.indexes._ibor_index as _ii @@ -65,7 +65,7 @@ cdef class MakeOIS: self._thisptr.withTerminationDate(deref(d._thisptr)) return self - def with_rule(self, Rule r): + def with_rule(self, DateGeneration r): self._thisptr.withRule(r) return self diff --git a/quantlib/instruments/make_vanilla_swap.pyx b/quantlib/instruments/make_vanilla_swap.pyx index c78761182..0e401b1d0 100644 --- a/quantlib/instruments/make_vanilla_swap.pyx +++ b/quantlib/instruments/make_vanilla_swap.pyx @@ -8,7 +8,7 @@ from quantlib.time.date cimport Period, Date from quantlib.time.businessdayconvention cimport BusinessDayConvention from quantlib.time.daycounter cimport DayCounter from quantlib.time._period cimport Days -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.termstructures.yield_term_structure cimport YieldTermStructure from quantlib.pricingengines.engine cimport PricingEngine cimport quantlib.indexes._ibor_index as _ii @@ -62,7 +62,7 @@ cdef class MakeVanillaSwap: self._thisptr.withTerminationDate(deref(termination_date._thisptr)) return self - def with_rule(self, Rule rule): + def with_rule(self, DateGeneration rule): self._thisptr.withRule(rule) return self diff --git a/quantlib/market/market.py b/quantlib/market/market.py index fd46727bb..f66b423c2 100644 --- a/quantlib/market/market.py +++ b/quantlib/market/market.py @@ -13,7 +13,7 @@ from quantlib.time.api import ( Date, Period, Years, Days, JointCalendar, UnitedStates, UnitedKingdom, pydate_from_qldate, qldate_from_pydate, DayCounter, - BusinessDayConvention, Rule, Following, calendar_from_name, + BusinessDayConvention, DateGeneration, Following, calendar_from_name, Schedule, Frequency ) @@ -121,7 +121,7 @@ def make_eurobond_helper( index.fixing_calendar, index.business_day_convention, index.business_day_convention, - Rule.Backward, # Date generation rule + DateGeneration.Backward, # Date generation rule index.end_of_month, ) @@ -374,13 +374,13 @@ def create_fixed_float_swap(self, settlement_date, length, fixed_rate, fixed_schedule = Schedule.from_rule(settlement_date, maturity, fixed_frequency, calendar, fixed_convention, fixed_convention, - Rule.Forward, False) + DateGeneration.Forward, False) float_schedule = Schedule.from_rule(settlement_date, maturity, floating_frequency, calendar, floating_convention, floating_convention, - Rule.Forward, False) + DateGeneration.Forward, False) swap = VanillaSwap(swap_type, nominal, fixed_schedule, fixed_rate, fixed_daycount, float_schedule, index, diff --git a/quantlib/mlab/fixed_income.py b/quantlib/mlab/fixed_income.py index 833b5d93c..75caad258 100644 --- a/quantlib/mlab/fixed_income.py +++ b/quantlib/mlab/fixed_income.py @@ -24,7 +24,7 @@ Date, Days, Period, Years, str_to_frequency) from quantlib.time.schedule import Schedule -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration from quantlib.settings import Settings from quantlib.termstructures.yields.api import ( FlatForward, YieldTermStructure @@ -119,7 +119,7 @@ def _bndprice(bond_yield, coupon_rate, pricing_date, maturity_date, calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward ) issue_date = effective_date @@ -229,7 +229,7 @@ def _cfamounts(coupon_rate, pricing_date, maturity_date, calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward ) issue_date = effective_date diff --git a/quantlib/termstructures/credit/_credit_helpers.pxd b/quantlib/termstructures/credit/_credit_helpers.pxd index 74727802d..8fb6791c3 100644 --- a/quantlib/termstructures/credit/_credit_helpers.pxd +++ b/quantlib/termstructures/credit/_credit_helpers.pxd @@ -18,7 +18,7 @@ from quantlib.time._date cimport Date from quantlib.time._daycounter cimport DayCounter from quantlib.time._period cimport Period, Frequency from quantlib.termstructures.yields._flat_forward cimport YieldTermStructure -from quantlib.time._schedule cimport Rule +from quantlib.time._schedule cimport DateGeneration from quantlib.termstructures._default_term_structure cimport DefaultProbabilityTermStructure from quantlib.termstructures._helpers cimport BootstrapHelper, \ @@ -38,7 +38,7 @@ cdef extern from 'ql/termstructures/credit/defaultprobabilityhelpers.hpp' namesp Calendar& calendar, Frequency frequency, BusinessDayConvention paymentConvention, - Rule rule, + DateGeneration rule, DayCounter& dayCounter, Real recoveryRate, Handle[YieldTermStructure]& discountCurve, @@ -57,7 +57,7 @@ cdef extern from 'ql/termstructures/credit/defaultprobabilityhelpers.hpp' namesp const Calendar& calendar, Frequency frequency, BusinessDayConvention paymentConvention, - Rule rule, + DateGeneration rule, const DayCounter& dayCounter, Real recoveryRate, const Handle[YieldTermStructure]& discountCurve, @@ -74,7 +74,7 @@ cdef extern from 'ql/termstructures/credit/defaultprobabilityhelpers.hpp' namesp const Calendar& calendar, Frequency frequency, BusinessDayConvention paymentConvention, - Rule rule, + DateGeneration rule, const DayCounter& dayCounter, Real recoveryRate, const Handle[YieldTermStructure]& discountCurve, @@ -93,7 +93,7 @@ cdef extern from 'ql/termstructures/credit/defaultprobabilityhelpers.hpp' namesp const Calendar& calendar, Frequency frequency, BusinessDayConvention paymentConvention, - Rule rule, + DateGeneration rule, const DayCounter& dayCounter, Real recoveryRate, const Handle[YieldTermStructure]& discountCurve, @@ -112,7 +112,7 @@ cdef extern from 'ql/termstructures/credit/defaultprobabilityhelpers.hpp' namesp const Calendar& calendar, Frequency frequency, BusinessDayConvention paymentConvention, - Rule rule, + DateGeneration rule, const DayCounter& dayCounter, Real recoveryRate, const Handle[YieldTermStructure]& discountCurve, diff --git a/quantlib/termstructures/credit/default_probability_helpers.pyx b/quantlib/termstructures/credit/default_probability_helpers.pyx index 4d7a152a9..e58e6beeb 100644 --- a/quantlib/termstructures/credit/default_probability_helpers.pyx +++ b/quantlib/termstructures/credit/default_probability_helpers.pyx @@ -16,7 +16,7 @@ from quantlib.handle cimport shared_ptr, static_pointer_cast cimport quantlib.termstructures.credit._credit_helpers as _ci cimport quantlib.termstructures._yield_term_structure as _yts from quantlib.time._period cimport Frequency -from quantlib.time._schedule cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.time._calendar cimport BusinessDayConvention @@ -112,7 +112,7 @@ cdef class SpreadCdsHelper(CdsHelper): def __init__(self, running_spread, Period tenor, Integer settlement_days, Calendar calendar not None, int frequency, - int paymentConvention, Rule date_generation_rule, + int paymentConvention, DateGeneration date_generation_rule, DayCounter daycounter, Real recovery_rate, YieldTermStructure discount_curve=YieldTermStructure(), bool settles_accrual=True, @@ -145,7 +145,7 @@ cdef class SpreadCdsHelper(CdsHelper): (running_spread).handle(), deref(tenor._thisptr), settlement_days, deref(calendar._thisptr), frequency, - paymentConvention, date_generation_rule, + paymentConvention, date_generation_rule, deref(daycounter._thisptr), recovery_rate, discount_curve._thisptr, settles_accrual, pays_at_default_time, @@ -162,7 +162,7 @@ cdef class UpfrontCdsHelper(CdsHelper): def __init__(self, upfront, Rate running_spread, Period tenor not None, Integer settlement_days, Calendar calendar not None, int frequency, - int paymentConvention, Rule date_generation_rule, + int paymentConvention, DateGeneration rule, DayCounter daycounter not None, Real recovery_rate, YieldTermStructure discount_curve=YieldTermStructure(), Natural upfront_settlement_days=3, @@ -179,7 +179,7 @@ cdef class UpfrontCdsHelper(CdsHelper): new _ci.UpfrontCdsHelper( upfront, running_spread, deref(tenor._thisptr.get()), settlement_days, deref(calendar._thisptr), frequency, - paymentConvention, date_generation_rule, + paymentConvention, rule, deref(daycounter._thisptr), recovery_rate, discount_curve._thisptr, upfront_settlement_days, settles_accrual, pays_at_default_time, @@ -193,7 +193,7 @@ cdef class UpfrontCdsHelper(CdsHelper): new _ci.UpfrontCdsHelper( (upfront).handle(), running_spread, deref(tenor._thisptr), settlement_days, deref(calendar._thisptr), frequency, - paymentConvention, date_generation_rule, + paymentConvention, rule, deref(daycounter._thisptr), recovery_rate, discount_curve._thisptr, upfront_settlement_days, settles_accrual, pays_at_default_time, diff --git a/quantlib/time/_schedule.pxd b/quantlib/time/_schedule.pxd index 9be7c5b53..5a022bb4b 100644 --- a/quantlib/time/_schedule.pxd +++ b/quantlib/time/_schedule.pxd @@ -6,7 +6,7 @@ from ._period cimport Period from ._date cimport Date from ._calendar cimport Calendar, BusinessDayConvention from quantlib.handle cimport optional -from .dategeneration cimport Rule +from .dategeneration cimport DateGeneration cdef extern from 'ql/time/schedule.hpp' namespace 'QuantLib': cdef cppclass Schedule: @@ -18,7 +18,7 @@ cdef extern from 'ql/time/schedule.hpp' namespace 'QuantLib': Calendar& calendar, BusinessDayConvention convention, BusinessDayConvention terminationDateConvention, - Rule rule, + DateGeneration rule, bool endOfMonth, Date& firstDate, Date& nextToLastDate @@ -28,7 +28,7 @@ cdef extern from 'ql/time/schedule.hpp' namespace 'QuantLib': BusinessDayConvention convention, optional[BusinessDayConvention] terminationDateConvention, optional[Period] tenor, - optional[Rule] rule, + optional[DateGeneration] rule, optional[bool] endOfMonth, vector[bool]& isRegular ) except + @@ -42,4 +42,4 @@ cdef extern from 'ql/time/schedule.hpp' namespace 'QuantLib': vector[Date].const_iterator begin() vector[Date].const_iterator end() - Date previousTwentieth(const Date& d, Rule rule) + Date previousTwentieth(const Date& d, DateGeneration rule) diff --git a/quantlib/time/api.py b/quantlib/time/api.py index 15988674f..33546399d 100644 --- a/quantlib/time/api.py +++ b/quantlib/time/api.py @@ -45,4 +45,4 @@ ) from .schedule import Schedule -from .dategeneration import Rule +from .dategeneration import DateGeneration diff --git a/quantlib/time/dategeneration.pxd b/quantlib/time/dategeneration.pxd index 99d3e47b2..62eabb09c 100644 --- a/quantlib/time/dategeneration.pxd +++ b/quantlib/time/dategeneration.pxd @@ -1,5 +1,5 @@ cdef extern from 'ql/time/dategenerationrule.hpp' namespace 'QuantLib::DateGeneration': - cpdef enum class Rule: + cpdef enum class DateGeneration "QuantLib::DateGeneration::Rule": Backward # Backward from termination date to effective date. Forward # Forward from effective date to termination date. Zero # No intermediate dates between effective date diff --git a/quantlib/time/schedule.pyx b/quantlib/time/schedule.pyx index 601e53266..1c48e3db0 100644 --- a/quantlib/time/schedule.pyx +++ b/quantlib/time/schedule.pyx @@ -10,7 +10,7 @@ import numpy as np cimport numpy as np np.import_array() from .businessdayconvention cimport Following, BusinessDayConvention -from .dategeneration cimport Rule +from .dategeneration cimport DateGeneration from .calendar cimport Calendar from .date cimport date_from_qldate, Date, Period @@ -24,7 +24,7 @@ cdef class Schedule: Period tenor not None, Calendar calendar not None, BusinessDayConvention business_day_convention=Following, BusinessDayConvention termination_date_convention=Following, - Rule date_generation_rule=Rule.Forward, bool end_of_month=False, + DateGeneration date_generation_rule=DateGeneration.Forward, bool end_of_month=False, from_classmethod=False ): @@ -50,7 +50,7 @@ cdef class Schedule: BusinessDayConvention business_day_convention=Following, BusinessDayConvention termination_date_convention=Following, Period tenor=None, - Rule date_generation_rule=Rule.Forward, bool end_of_month=False, + DateGeneration date_generation_rule=DateGeneration.Forward, bool end_of_month=False, vector[bool] is_regular=[]): # convert lists to vectors cdef vector[_date.Date] _dates = vector[_date.Date]() @@ -68,7 +68,7 @@ cdef class Schedule: business_day_convention, opt_termination_convention, opt_tenor, - optional[_schedule.Rule](<_schedule.Rule>date_generation_rule), + optional[DateGeneration](date_generation_rule), optional[bool](end_of_month), is_regular ) @@ -81,7 +81,7 @@ cdef class Schedule: Period tenor not None, Calendar calendar not None, BusinessDayConvention business_day_convention=Following, BusinessDayConvention termination_date_convention=Following, - Rule date_generation_rule=Rule.Forward, bool end_of_month=False, + DateGeneration date_generation_rule=DateGeneration.Forward, bool end_of_month=False, Date first_date=Date(), Date next_to_lastdate=Date()): cdef Schedule instance = cls.__new__(cls) @@ -164,6 +164,6 @@ cdef class Schedule: else: raise TypeError('index needs to be an integer or a slice') -def previous_twentieth(Date d not None, Rule rule): +def previous_twentieth(Date d not None, DateGeneration rule): cdef _date.Date date = _schedule.previousTwentieth(deref(d._thisptr), rule) return date_from_qldate(date) diff --git a/test/test_bermudan_swaption.py b/test/test_bermudan_swaption.py index 9b6c68b7d..9f8d44564 100644 --- a/test/test_bermudan_swaption.py +++ b/test/test_bermudan_swaption.py @@ -4,7 +4,7 @@ from quantlib.instruments.swap import SwapType from quantlib.time.api import ( Date, today, Unadjusted, ModifiedFollowing, Annual, Semiannual, - Thirty360, Days, Years, Rule, Schedule, Actual365Fixed, Period) + Thirty360, Days, Years, DateGeneration, Schedule, Actual365Fixed, Period) from quantlib.time.daycounters.thirty360 import Convention from quantlib.indexes.api import Euribor6M from quantlib.termstructures.yields.api import YieldTermStructure @@ -37,9 +37,9 @@ def make_swap(self, fixed_rate): start = self.calendar.advance(self.settlement, self.start_years, Years) maturity = self.calendar.advance(start, self.length, Years) fixed_schedule = Schedule.from_rule(start, maturity, Period(self.fixed_frequency), self.calendar, - self.fixed_convention, self.fixed_convention, Rule.Forward, False) + self.fixed_convention, self.fixed_convention, DateGeneration.Forward, False) float_schedule = Schedule.from_rule(start, maturity, Period(self.floating_frequency), self.calendar, - self.floating_convention, self.floating_convention, Rule.Forward, False) + self.floating_convention, self.floating_convention, DateGeneration.Forward, False) swap = VanillaSwap(self.swap_type, self.nominal, fixed_schedule, fixed_rate, self.fixed_day_count, float_schedule, self.index, 0.0, self.index.day_counter) swap.set_pricing_engine(DiscountingSwapEngine(self.term_structure)) return swap diff --git a/test/test_bond_helpers.py b/test/test_bond_helpers.py index e7375e3de..3f0f99635 100644 --- a/test/test_bond_helpers.py +++ b/test/test_bond_helpers.py @@ -4,7 +4,7 @@ from quantlib.termstructures.yields.bond_helpers import ( FixedRateBondHelper) from quantlib.time.api import ( - Annual, Rule, Date, DayCounter, ModifiedFollowing, Following, Period, Schedule, TARGET) + Annual, DateGeneration, Date, DayCounter, ModifiedFollowing, Following, Period, Schedule, TARGET) class TestFixedRateBondHelper(unittest.TestCase): @@ -20,7 +20,7 @@ def test_create_fixed_rate_bond_helper(self): TARGET(), ModifiedFollowing, ModifiedFollowing, - Rule.Backward, + DateGeneration.Backward, False ) diff --git a/test/test_bondfunctions.py b/test/test_bondfunctions.py index 08d24253e..ba25cb7a5 100644 --- a/test/test_bondfunctions.py +++ b/test/test_bondfunctions.py @@ -21,7 +21,7 @@ Annual, UnitedStates, Months, Actual365Fixed) from quantlib.time.daycounters.actual_actual import Bond, ISMA from quantlib.time.schedule import Schedule -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration from quantlib.settings import Settings from quantlib.indexes.ibor.libor import Libor @@ -88,7 +88,7 @@ def test_display(self): UnitedStates(market=GovernmentBond), Unadjusted, Unadjusted, - Rule.Backward, + DateGeneration.Backward, False); diff --git a/test/test_bonds.py b/test/test_bonds.py index d63428c0d..22b77dd7b 100644 --- a/test/test_bonds.py +++ b/test/test_bonds.py @@ -17,7 +17,7 @@ from quantlib.time.daycounters.simple import Actual365Fixed, Actual360 from quantlib.time.daycounters.actual_actual import ActualActual, Bond, ISMA from quantlib.time.schedule import Schedule -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration from quantlib.settings import Settings from quantlib.termstructures.yields.api import ( FlatForward, YieldTermStructure @@ -80,7 +80,7 @@ def test_pricing_bond(self): UnitedStates(market=GOVERNMENTBOND), Unadjusted, Unadjusted, - Rule.Backward, + DateGeneration.Backward, False); @@ -152,7 +152,7 @@ def test_excel_example_with_fixed_rate_bond(self): calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward ) issue_date = effective_date @@ -254,7 +254,7 @@ def test_excel_example_with_floating_rate_bond(self): calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward )#3 flat_discounting_term_structure = YieldTermStructure() diff --git a/test/test_cds.py b/test/test_cds.py index a80252801..f7e486020 100644 --- a/test/test_cds.py +++ b/test/test_cds.py @@ -9,8 +9,7 @@ from quantlib.instruments.credit_default_swap import cds_maturity from quantlib.instruments.make_cds import MakeCreditDefaultSwap from quantlib.time.api import ( TARGET, today, Years, Schedule, - Following, Quarterly, Rule, Actual360, Period ) -from quantlib.time.dategeneration import Rule + Following, Quarterly, DateGeneration, Actual360, Period ) import math @@ -29,7 +28,7 @@ def setUp(self): maturity = calendar.advance(issue_date, 10, Years) self.convention = Following self.schedule = Schedule.from_rule(issue_date, maturity, Period("3M"), calendar, - self.convention, self.convention, Rule.TwentiethIMM) + self.convention, self.convention, DateGeneration.TwentiethIMM) recovery_rate = 0.4 self.engine = MidPointCdsEngine(probability_curve, recovery_rate, discount_curve, True) @@ -83,9 +82,9 @@ def test_fair_upfront(self): def test_makecds(self): cds = (MakeCreditDefaultSwap(Period(5, Years), 0.01). - with_date_generation_rule(Rule.CDS2015)()) + with_date_generation_rule(DateGeneration.CDS2015)()) self.assertEqual(cds.cash_settlement_days, 3) - self.assertEqual(cds.protection_end_date, cds_maturity(Settings().evaluation_date, Period(5, Years), Rule.CDS2015)) + self.assertEqual(cds.protection_end_date, cds_maturity(Settings().evaluation_date, Period(5, Years), DateGeneration.CDS2015)) if __name__ == "__main__": unittest.main() diff --git a/test/test_credit_termstructures.py b/test/test_credit_termstructures.py index 85e0af5d6..64f253435 100644 --- a/test/test_credit_termstructures.py +++ b/test/test_credit_termstructures.py @@ -10,7 +10,7 @@ InterpolatedHazardRateCurve, ProbabilityTrait, Interpolator) from quantlib.instruments.api import PricingModel from quantlib.time.api import TARGET, Date, Actual365Fixed, Years, \ - Following, Quarterly, Rule, May, Period, Days + Following, Quarterly, DateGeneration, May, Period, Days import math def create_helper(): @@ -31,7 +31,7 @@ def create_helper(): helper = SpreadCdsHelper( quoted_spreads, tenor, 0, calendar, Quarterly, - Following, Rule.TwentiethIMM, Actual365Fixed(), recovery_rate, ts_curve, + Following, DateGeneration.TwentiethIMM, Actual365Fixed(), recovery_rate, ts_curve, model=PricingModel.Midpoint ) diff --git a/test/test_cython_bug.pyx b/test/test_cython_bug.pyx index 859744323..3bf8119d5 100644 --- a/test/test_cython_bug.pyx +++ b/test/test_cython_bug.pyx @@ -14,7 +14,7 @@ from quantlib.time.businessdayconvention cimport ( ) from quantlib.time.calendars._target cimport TARGET from quantlib.time._schedule cimport Schedule -from quantlib.time.dategeneration cimport Rule +from quantlib.time.dategeneration cimport DateGeneration from quantlib.time.date cimport date_from_qldate, Date from quantlib.time.daycounters._actual_actual cimport ISMA, ActualActual @@ -66,7 +66,7 @@ cdef FixedRateBond* get_bond_for_evaluation_date(QlDate& in_date): calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward, + DateGeneration.Backward, False, QlDate(), QlDate() diff --git a/test/test_inflation.py b/test/test_inflation.py index d68a49853..67b51d3e9 100644 --- a/test/test_inflation.py +++ b/test/test_inflation.py @@ -13,7 +13,7 @@ from quantlib.time.date import Monthly, Months, Period, Date from quantlib.time.api import ( UnitedKingdom, ModifiedFollowing, ActualActual, Schedule, Actual365Fixed, Unadjusted ) -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration from quantlib.instruments.bonds import CPIBond, InterpolationType from quantlib.pricingengines.bond import DiscountingBondEngine from quantlib.settings import Settings @@ -129,7 +129,7 @@ def test_clean_price(self): Period(6, Months), fixed_calendar, Unadjusted, - Rule.Backward) + DateGeneration.Backward) cpi_bond = CPIBond(settlement_days, notional, growth_only, baseCPI, contractObservationLag, fixed_index, diff --git a/test/test_schedule.py b/test/test_schedule.py index d11d76a32..b0c1de6f4 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -5,7 +5,7 @@ from quantlib.time.businessdayconvention import Following, Preceding from quantlib.time.calendars.united_kingdom import UnitedKingdom from quantlib.time.schedule import Schedule -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration class ScheduleTestCase(unittest.TestCase): @@ -17,7 +17,7 @@ def test_create_schedule(self): calendar = UnitedKingdom() convention = Following termination_convention = Following - rule = Rule.Forward + rule = DateGeneration.Forward schedule = Schedule( from_date, to_date, tenor, calendar, convention, termination_convention, rule @@ -43,7 +43,7 @@ def setUp(self): self.calendar = UnitedKingdom() self.convention = Following self.termination_convention = Preceding - self.rule = Rule.Twentieth + self.rule = DateGeneration.Twentieth self.schedule = Schedule.from_rule( self.from_date, self.to_date, self.tenor, self.calendar, @@ -90,7 +90,7 @@ def test_previous_next_reference_date(self): calendar = UnitedKingdom() convention = Following termination_convention = Following - rule = Rule.Forward + rule = DateGeneration.Forward fwd_schedule = Schedule.from_rule(from_date, to_date, tenor, calendar, convention, termination_convention, rule) @@ -98,7 +98,7 @@ def test_previous_next_reference_date(self): expected_date = Date(5, Sep, 2011) self.assertEqual(expected_date, fwd_schedule.next_date(from_date)) - rule = Rule.Backward + rule = DateGeneration.Backward bwd_schedule = Schedule.from_rule(from_date, to_date, tenor, calendar, convention, termination_convention, rule) @@ -114,7 +114,7 @@ def test_schedule_from_dates(self): calendar = UnitedKingdom() convention = Following termination_convention = Following - rule = Rule.Forward + rule = DateGeneration.Forward schedule = Schedule.from_dates(dates, calendar, convention, termination_convention, tenor, rule) diff --git a/test/test_sensitivity_analysis.py b/test/test_sensitivity_analysis.py index 788e9ba65..6e4b4b711 100644 --- a/test/test_sensitivity_analysis.py +++ b/test/test_sensitivity_analysis.py @@ -15,7 +15,7 @@ Actual365Fixed) from quantlib.time.daycounters.actual_actual import Bond from quantlib.time.schedule import Schedule -from quantlib.time.dategeneration import Rule +from quantlib.time.dategeneration import DateGeneration from quantlib.settings import Settings from quantlib.indexes.ibor.usdlibor import USDLibor from quantlib.termstructures.yields.rate_helpers import ( @@ -111,7 +111,7 @@ def test_bucketanalysis_bond(self): UnitedStates(market=GovernmentBond), Unadjusted, Unadjusted, - Rule.Backward, + DateGeneration.Backward, False) bond = FixedRateBond( diff --git a/test/test_settings.py b/test/test_settings.py index 2ee6d2760..e679e2c0f 100644 --- a/test/test_settings.py +++ b/test/test_settings.py @@ -2,7 +2,7 @@ from quantlib.instruments.bonds import FixedRateBond from quantlib.time.api import ( Date, Days, August, Period, Jul, Annual, today, Years, TARGET, - Unadjusted, Schedule, ModifiedFollowing, Rule, ActualActual, ISMA, + Unadjusted, Schedule, ModifiedFollowing, DateGeneration, ActualActual, ISMA, Following ) @@ -75,7 +75,7 @@ def test_bond_schedule_today(self): calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward ) issue_date = effective_date @@ -124,7 +124,7 @@ def test_bond_schedule_anotherday(self): calendar, ModifiedFollowing, ModifiedFollowing, - Rule.Backward + DateGeneration.Backward ) issue_date = effective_date diff --git a/test/test_swap.py b/test/test_swap.py index 814219e3c..cacc44290 100644 --- a/test/test_swap.py +++ b/test/test_swap.py @@ -13,7 +13,7 @@ from quantlib.time.api import ( Unadjusted, ModifiedFollowing, Date, Days, Semiannual, January, Period, Annual, Years, Months, Actual365Fixed, Thirty360, TARGET, Actual360, - Schedule, Rule + Schedule, DateGeneration ) from quantlib.util.converter import pydate_to_qldate from quantlib.quotes import SimpleQuote @@ -63,13 +63,13 @@ def test_swap_QL(self): fixedSchedule = Schedule(settlement_date, maturity, Period(fixedFrequency), calendar, fixedConvention, fixedConvention, - Rule.Forward, False) + DateGeneration.Forward, False) floatSchedule = Schedule(settlement_date, maturity, Period(floatingFrequency), calendar, floatingConvention, floatingConvention, - Rule.Forward, False) + DateGeneration.Forward, False) engine = DiscountingSwapEngine(termStructure, False, settlement_date, settlement_date)