Skip to content

Commit ec45bf7

Browse files
committed
expose "earlier/later" in lease end type assumption
1 parent 343dcf4 commit ec45bf7

4 files changed

Lines changed: 45 additions & 15 deletions

File tree

absbox/local/component.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,9 +1817,13 @@ def mkAssumpLeaseRent(x):
18171817
def mkAssumpLeaseEndType(x):
18181818
match x:
18191819
case {"byDate":d} | ("byDate", d):
1820-
return mkTag("CutByDate", vDate(d))
1820+
return mkTag(("CutByDate", vDate(d)))
18211821
case {"stopByExtNum":n} | ("byExtTimes",n):
1822-
return mkTag("StopByExtTimes", vInt(n))
1822+
return mkTag(("StopByExtTimes", vInt(n)))
1823+
case ("earlierOf", d, n):
1824+
return mkTag(("EarlierOf", [vDate(d), vInt(n)]))
1825+
case ("laterOf", d, n):
1826+
return mkTag(("LaterOf", [vDate(d), vInt(n)]))
18231827
case _:
18241828
raise RuntimeError(f"failed to match {x}:mkAssumpLeaseEndType")
18251829

@@ -1857,19 +1861,8 @@ def mkDefaultedAssumption(x):
18571861

18581862

18591863
def mkDelinqAssumption(x):
1860-
#return "DummyDelinqAssump"
1861-
#return mkTag("DummyDelinqAssump")
18621864
return []
18631865

1864-
def mkEndType(x):
1865-
match x:
1866-
case ("byDate", d):
1867-
return mkTag(("CutByDate",vDate(d)))
1868-
case ("byExtTimes",n):
1869-
return mkTag(("StopByExtTimes", vNum(n)))
1870-
case _:
1871-
raise RuntimeError(f"failed to match {x} : mkEndType")
1872-
18731866
def mkPerfAssumption(x):
18741867
"Make assumption on performing assets"
18751868
def mkExtraStress(y):
@@ -1903,7 +1896,7 @@ def mkExtraStress(y):
19031896
return mkTag(("LeaseAssump",[earlyReturnNone(mkAssumpLeaseDefaultType,md)
19041897
,mkAssumpLeaseGap(gap)
19051898
,mkAssumpLeaseRent(rent)
1906-
,mkEndType(endType)
1899+
,mkAssumpLeaseEndType(endType)
19071900
]))
19081901
case ("Loan",md,mp,mr,mes):
19091902
d = earlyReturnNone(mkAssumpDefault,md)

absbox/tests/regression/assets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@
3030
,"currentRate": 0.075
3131
,"remainTerm": 12
3232
,"status": "Current"}]
33+
34+
l1 = ["Lease"
35+
,{"rental":("byDay", 12.0, ["DayOfMonth",15])
36+
,"originTerm": 12
37+
,"originDate": "2022-01-05"}
38+
,{"status":"Current" ,"remainTerm":6 ,"currentBalance":150}]

absbox/tests/regression/test_main.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,32 @@ def test_trigger_chgBondRate(setup_api):
287287
}
288288
})
289289
r = setup_api.run(withTrigger , read=True ,runAssump = [("interest",("SOFR1Y",0.04))])
290-
assert r['bonds']['A1'].rate.to_list() == [0.07, 0.12, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]
290+
assert r['bonds']['A1'].rate.to_list() == [0.07, 0.12, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]
291+
292+
@pytest.mark.pool
293+
def test_pool_lease_end(setup_api):
294+
""" Lease end date """
295+
myPool = {'assets':[l1],'cutoffDate':"2022-01-01"}
296+
r = setup_api.runPool(myPool
297+
,poolAssump=("Pool",("Lease", None, ('days', 20) , ('byAnnualRate', 0.0), ("byExtTimes", 2))
298+
,None
299+
,None
300+
)
301+
,read=True)
302+
assert r['PoolConsol'][0].index[-1] == '2024-12-15'
303+
304+
r = setup_api.runPool(myPool
305+
,poolAssump=("Pool",("Lease", None, ('days', 20) , ('byAnnualRate', 0.0), ("earlierOf", "2023-11-15", 2))
306+
,None
307+
,None
308+
)
309+
,read=True)
310+
assert r['PoolConsol'][0].index[-1] == '2023-12-15'
311+
312+
r = setup_api.runPool(myPool
313+
,poolAssump=("Pool",("Lease", None, ('days', 20) , ('byAnnualRate', 0.0), ("laterOf", "2023-11-15", 3))
314+
,None
315+
,None
316+
)
317+
,read=True)
318+
assert r['PoolConsol'][0].index[-1] == '2025-12-15'

docs/source/analytics.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ Describle the end type of lease projection,either by a ``Date`` or a ``Extend Ti
507507

508508
* ``("byDate", "2026-09-20")`` : the date when lease projection ends
509509
* ``("byExtTimes", 1)`` : how many times lease will roll over for 1 time
510+
.. versionadded:: 0.45.9
511+
* ``("earlierOf", "2026-09-20", 3)`` : the lease projection ends at the earlier of the date or extend time
512+
* ``("laterOf", "2026-09-20", 3)`` : the lease projection ends at the later of the date or extend time
510513

511514
Summary
512515
""""""""""""""""

0 commit comments

Comments
 (0)