aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/tranche_functions.py2
-rw-r--r--python/tests/test_dates.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/python/analytics/tranche_functions.py b/python/analytics/tranche_functions.py
index 3355a887..b72d4bba 100644
--- a/python/analytics/tranche_functions.py
+++ b/python/analytics/tranche_functions.py
@@ -455,6 +455,8 @@ def credit_schedule(tradedate, coupon, yc, enddate=None, tenor=None, rule=CDS201
sched = Schedule.from_rule(
tradedate, enddate, Period("3M"), cal, ModifiedFollowing, Unadjusted, rule
)
+ if sched[1] == start_date: # we need to skip one date
+ sched = sched.after(start_date)
payment_dates = [pydate_from_qldate(cal.adjust(d)) for d in sched if d > start_date]
df = [yc.discount_factor(d) for d in payment_dates]
coupons = [
diff --git a/python/tests/test_dates.py b/python/tests/test_dates.py
index 054a0ee1..1437bba4 100644
--- a/python/tests/test_dates.py
+++ b/python/tests/test_dates.py
@@ -183,6 +183,10 @@ class TestCdsSchedule(unittest.TestCase):
""" tests when IMM date falls on a week-end"""
df = credit_schedule(self.trade_date, 1.0, self.yc, datetime.date(2022, 12, 20))
self.assertEqual(df.index[0], pd.Timestamp("2020-06-22"))
+ df = credit_schedule(
+ datetime.date(2020, 3, 19), 1.0, self.yc, datetime.date(2022, 12, 20)
+ )
+ self.assertEqual(df.index[0], pd.Timestamp("2020-06-22"))
if __name__ == "__main__":