Skip to content

Commit 968f144

Browse files
authored
BUG: Adjuster.reverse correction for Variant (#222) (#1143)
1 parent b1b5535 commit 968f144

File tree

4 files changed

+599
-25
lines changed

4 files changed

+599
-25
lines changed

python/rateslib/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ def __exit__(self, *args) -> None: # type: ignore[no-untyped-def]
117117
FloatPeriod,
118118
FXCallPeriod,
119119
FXPutPeriod,
120+
ZeroFixedPeriod,
121+
ZeroFloatPeriod,
120122
)
121123
from rateslib.scheduling import (
122124
Adjuster,
@@ -221,6 +223,8 @@ def __exit__(self, *args) -> None: # type: ignore[no-untyped-def]
221223
# periods.py,
222224
"FixedPeriod",
223225
"FloatPeriod",
226+
"ZeroFixedPeriod",
227+
"ZeroFloatPeriod",
224228
"Cashflow",
225229
"FXCallPeriod",
226230
"FXPutPeriod",

python/tests/scheduling/test_calendars.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Convention,
1212
Frequency,
1313
RollDay,
14+
UnionCal,
1415
add_tenor,
1516
dcf,
1617
get_calendar,
@@ -688,3 +689,13 @@ def test_wlg_changes():
688689
assert not cal.is_bus_day(dt(2022, 9, 26))
689690
assert not cal.is_bus_day(dt(2025, 1, 20))
690691
assert not cal.is_bus_day(dt(2025, 1, 27))
692+
693+
694+
def test_busdayslag_reverse():
695+
# test that reverse operates over settleable days also
696+
a = Adjuster.BusDaysLagSettle(2)
697+
cal = Cal([dt(2026, 1, 1)], [5, 6])
698+
union = UnionCal([Cal([], [])], [cal])
699+
assert a.adjust(dt(2025, 12, 30), union) == dt(2026, 1, 2)
700+
assert a.adjust(dt(2025, 12, 31), union) == dt(2026, 1, 2)
701+
assert a.reverse(dt(2026, 1, 2), union) == [dt(2025, 12, 31), dt(2025, 12, 30)]

0 commit comments

Comments
 (0)