Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions unit_tests/legacy/test_FinIborSingleCurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

########################################################################################

Expand Down Expand Up @@ -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))