From 44098560e17baa275b0934362cde5bf9c84b5d4b Mon Sep 17 00:00:00 2001 From: gyx09212214-prog <243787584+gyx09212214-prog@users.noreply.github.com> Date: Thu, 11 Jun 2026 16:24:40 +0800 Subject: [PATCH] Add IborSingleCurve time day count regression test --- unit_tests/legacy/test_FinIborSingleCurve.py | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/unit_tests/legacy/test_FinIborSingleCurve.py b/unit_tests/legacy/test_FinIborSingleCurve.py index 6fb6345b3..3593d1954 100644 --- a/unit_tests/legacy/test_FinIborSingleCurve.py +++ b/unit_tests/legacy/test_FinIborSingleCurve.py @@ -13,6 +13,7 @@ from financepy.utils.day_count import DayCountTypes from financepy.utils.date import Date from financepy.utils.calendar import Calendar, CalendarTypes +from financepy.utils.helpers import times_from_dates ######################################################################################## @@ -400,3 +401,40 @@ def test_reprice_inputs_for_all_interp_choices(interp_type): # If no exception, we are good assert True + + +def test_df_uses_ibor_single_curve_time_day_count(): + """Regression test for inherited DiscountCurve.df date conversion.""" + + value_dt = Date(1, 1, 2024) + maturity_dt = Date(1, 1, 2025) + depo = IborDeposit( + value_dt, + maturity_dt, + 0.05, + DayCountTypes.ACT_360, + ) + + curve = IborSingleCurve( + value_dt, + [depo], + [], + [], + InterpTypes.FLAT_FWD_RATES, + time_dc_type=DayCountTypes.ACT_360, + ) + + curve_df = curve.df(maturity_dt) + act_360_time = times_from_dates( + maturity_dt, + value_dt, + DayCountTypes.ACT_360, + ) + act_365f_time = times_from_dates( + maturity_dt, + value_dt, + DayCountTypes.ACT_365F, + ) + + assert curve_df == pytest.approx(curve.df_t(act_360_time)) + assert curve_df != pytest.approx(curve.df_t(act_365f_time))