Skip to content

Commit bf7a7aa

Browse files
committed
add test case: bond group pay by names
1 parent efd5481 commit bf7a7aa

2 files changed

Lines changed: 103 additions & 2 deletions

File tree

absbox/tests/regression/deals.py

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@
409409
"Amortizing",
410410
)
411411

412-
from absbox import Generic
413412

414413
pac02 = Generic(
415414
"PAC 02",
@@ -690,4 +689,99 @@
690689
None,
691690
None,
692691
"Amortizing",
692+
)
693+
694+
695+
bondGrp = Generic(
696+
"Bond Group",
697+
{
698+
"lastCollect": "2021-03-01",
699+
"lastPay": "2021-04-15",
700+
"nextPay": "2021-07-26",
701+
"nextCollect": "2021-04-28",
702+
"payFreq": ["DayOfMonth", 20],
703+
"poolFreq": "MonthEnd",
704+
"stated": "2030-01-01",
705+
},
706+
{
707+
"assets": [
708+
[
709+
"Mortgage",
710+
{
711+
"originBalance": 2200,
712+
"originRate": ["fix", 0.045],
713+
"originTerm": 30,
714+
"freq": "Monthly",
715+
"type": "Level",
716+
"originDate": "2021-02-01",
717+
},
718+
{
719+
"currentBalance": 2200,
720+
"currentRate": 0.08,
721+
"remainTerm": 30,
722+
"status": "current",
723+
},
724+
]
725+
]
726+
},
727+
(("acc01", {"balance": 0}),),
728+
(
729+
(
730+
"A",
731+
(
732+
"bondGroup",
733+
{
734+
"A1": {
735+
"balance": 1000,
736+
"rate": 0.07,
737+
"originBalance": 1000,
738+
"originRate": 0.07,
739+
"startDate": "2020-01-03",
740+
"rateType": ("fix", 0.08),
741+
"bondType": "Seq",
742+
"lastAccrueDate": "2021-04-15",
743+
},
744+
"A2": {
745+
"balance": 800,
746+
"rate": 0.07,
747+
"originBalance": 800,
748+
"originRate": 0.07,
749+
"startDate": "2020-01-03",
750+
"rateType": ("fix", 0.08),
751+
"bondType": "Seq",
752+
"lastAccrueDate": "2021-04-15",
753+
},
754+
},
755+
),
756+
),
757+
(
758+
"B",
759+
{
760+
"balance": 1000,
761+
"rate": 0.0,
762+
"originBalance": 1000,
763+
"originRate": 0.07,
764+
"startDate": "2020-01-03",
765+
"rateType": ("fix", 0.08),
766+
"lastAccrueDate": "2021-04-15",
767+
"bondType": "Equity",
768+
},
769+
),
770+
),
771+
tuple(),
772+
{
773+
"default": [
774+
["accrueAndPayIntByGroup", "acc01", "A", ("byName", "A2","A1")],
775+
["payPrinByGroup", "acc01", "A", ("byName", "A2","A1")],
776+
["accrueAndPayInt","acc01",["B"]],
777+
["payPrin","acc01",["B"]],
778+
["payIntResidual", "acc01", "B"],
779+
],
780+
},
781+
[["CollectedCash", "acc01"]],
782+
None,
783+
None,
784+
None,
785+
None,
786+
"Amortizing",
693787
)

absbox/tests/regression/test_main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,11 @@ def test_pac_03(setup_api):
264264
def test_pac_04(setup_api):
265265
r = setup_api.run(pac04 , read=True , runAssump = [])
266266
groupBals = readBondsCf(r['bonds']).xs('balance',axis=1,level=2)[[("A","A1"),("A","A2")]].sum(axis=1).loc["2021-07-26":"2021-12-20"].to_list()
267-
assert groupBals == [1050.0, 980.0, 915.0, 880.0, 850.0, 773.73], "Got"+str(groupBals)
267+
assert groupBals == [1050.0, 980.0, 915.0, 880.0, 850.0, 773.73], "Got"+str(groupBals)
268+
269+
@pytest.mark.bond
270+
def test_bondGrp(setup_api):
271+
r = setup_api.run(bondGrp , read=True , runAssump = [])
272+
grpFlow = readBondsCf(r['bonds'])['A'].xs('balance',axis=1,level=1)
273+
assert grpFlow.A1.to_list()[:8] == [100.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 993.93]
274+
assert grpFlow.A2.to_list()[:8] == [510.6, 436.68, 364.06, 290.75, 217.26, 143.1, 68.74, 0.0,]

0 commit comments

Comments
 (0)