Skip to content

Commit cbf3fe7

Browse files
committed
init for loan level cashflow
1 parent dca5b8b commit cbf3fe7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+195131
-69303
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Created by venv; see https://docs.python.org/3/library/venv.html
2+
lib/
3+
etc/
4+
share
5+
lib64
6+
pyvenv.cfg
7+
.ipynb_checkpoints/
8+
absbox/__pycache__/
9+
absbox/examples/__pycache__/
10+
absbox/local/__pycache__/
11+
absbox/tests/__pycache__/
12+
absbox/tests/benchmark/china/__pycache__/
13+
absbox/tests/benchmark/us/__pycache__/
14+
absbox/tests/regression/__pycache__/
15+
absbox/tests/regression/*.ipynb
16+
absbox.egg-info/
17+
bin/
18+
*.ipynb
19+

absbox/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def build_run_deal_req(self, run_type, deal, perfAssump=None, nonPerfAssump=[],
247247
_deal = deal.json if hasattr(deal, "json") else deal
248248
_perfAssump = earlyReturnNone(mkAssumpType, perfAssump)
249249
_nonPerfAssump = mkNonPerfAssumps({}, nonPerfAssump)
250-
dealRunInput= (_deal, _perfAssump, _nonPerfAssump)
250+
dealRunInput= (_deal, _perfAssump, _nonPerfAssump, [])
251251
r = mkTag((RunReqType.RootFinder.value, [dealRunInput, mkTweak(tweak), mkStop(stop)]))
252252
case ("FirstLoss", bn) | ("FL", bn):
253253
_deal = deal.json if hasattr(deal, "json") else deal
@@ -429,14 +429,14 @@ def read_single(self, breakdown, pool_resp) -> tuple:
429429
:rtype: tuple
430430
"""
431431

432-
((pool_flow, pool_bals), pool_breakdown_flow) = pool_resp
432+
(pool_flow, pool_breakdown_flow) = pool_resp
433433
result = _read_cf(pool_flow['contents'][1], self.lang)
434434
if not breakdown:
435-
return {"flow":result, "stat":pool_bals}
435+
return {"flow":result}
436436
else:
437437
assert pool_breakdown_flow is not None, "Breakdown flow is None"
438438
assert len(pool_breakdown_flow)>0, "Breakdown flow is empty"
439-
return {"flow":result, "stat":pool_bals
439+
return {"flow":result
440440
,"breakdown": [ {"flow": _read_cf(_[0]['contents'][1], self.lang), "stat":_[1]}
441441
for _ in pool_breakdown_flow ]
442442
}
@@ -749,13 +749,13 @@ def runAsset(self, date, _assets, poolAssump=None, rateAssump=None
749749

750750
def readResult(x):
751751
try:
752-
((cfs, cfBalance), pr) = x
752+
(cfs, pr) = x
753753
cfs = _read_cf(cfs['contents'][1], self.lang)
754754
pricingResult = _read_asset_pricing(pr, self.lang) if pr else None
755-
return (cfs, cfBalance, pricingResult)
755+
return (cfs, pricingResult)
756756
except Exception as e:
757757
print(f"Failed to read result {x} \n with error {e}")
758-
return (None, None, None)
758+
return (None,None)
759759

760760
url = f"{self.url}/{Endpoints.RunAsset.value}"
761761
_assumptions = mkAssumpType(poolAssump) if poolAssump else None

absbox/local/component.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ def id_by_pool_assets(z):
16751675
return "MDeal"
16761676
case {"assets": [{'tag': 'AdjustRateMortgage'}, *rest]}:
16771677
return "MDeal"
1678-
case {"assets": [], "futureCf": cfs} if cfs['contents'][1][0]['tag'] == 'MortgageFlow':
1678+
case {"assets": [], "futureCf": cfs} if cfs[0]['contents'][1][0]['tag'] == 'MortgageFlow':
16791679
return "MDeal"
16801680
case {"assets": [{'tag': 'Installment'}, *rest]} :
16811681
return "IDeal"
@@ -2029,9 +2029,7 @@ def mkPoolType(assetDate, x, mixedFlag) -> dict:
20292029
for ((bn,pct,sd),dealObj) in x['deals'].items()} ))
20302030
case x if all([ isinstance(_,dict) for _ in x.values() ]):
20312031
return mkTag(("MultiPool"
2032-
,{f"PoolName:{k}":mkPoolComp(vDate(assetDate),v,mixedFlag)
2033-
for (k,v) in x.items()})
2034-
)
2032+
,{f"PoolName:{k}":mkPoolComp(vDate(assetDate),v,mixedFlag) for (k,v) in x.items()}))
20352033
case _ :
20362034
raise RuntimeError("Failed to match pool type ",x)
20372035

@@ -2044,7 +2042,7 @@ def mkPoolComp(asOfDate, x, mixFlag) -> dict:
20442042
, lambda y: updateKs(y, validCutoffFields)
20452043
)
20462044
, "futureCf":[mkCf(getValWithKs(x, ['cashflow', '现金流归集表', '归集表'], [])),None]
2047-
, "futureScheduleCf" : [mkCf([]), None]
2045+
, "futureScheduleCf" : None
20482046
, "extendPeriods":mkDatePattern(getValWithKs(x, ['extendBy'], "MonthEnd"))}
20492047
return r
20502048

absbox/local/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .base import *
99
from .interface import mkTag
1010

11+
1112
def mapNone(x, v):
1213
''' return a default value if x is None, other wise, return x '''
1314
if x is None:

absbox/tests/benchmark/china/out/test01.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@
6969
],
7070
"asOfDate": "2021-03-31",
7171
"issuanceStat": {},
72-
"futureCf": null,
72+
"futureCf": [
73+
{
74+
"tag": "CashFlowFrame",
75+
"contents": [
76+
[
77+
0,
78+
"1900-01-01",
79+
null
80+
],
81+
[]
82+
]
83+
},
84+
null
85+
],
86+
"futureScheduleCf": null,
7387
"extendPeriods": {
7488
"tag": "MonthEnd"
7589
}

absbox/tests/benchmark/china/out/test02.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@
6969
],
7070
"asOfDate": "2021-03-01",
7171
"issuanceStat": {},
72-
"futureCf": null,
72+
"futureCf": [
73+
{
74+
"tag": "CashFlowFrame",
75+
"contents": [
76+
[
77+
0,
78+
"1900-01-01",
79+
null
80+
],
81+
[]
82+
]
83+
},
84+
null
85+
],
86+
"futureScheduleCf": null,
7387
"extendPeriods": {
7488
"tag": "MonthEnd"
7589
}

absbox/tests/benchmark/china/out/test03.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,21 @@
7777
],
7878
"asOfDate": "2021-03-01",
7979
"issuanceStat": {},
80-
"futureCf": null,
80+
"futureCf": [
81+
{
82+
"tag": "CashFlowFrame",
83+
"contents": [
84+
[
85+
0,
86+
"1900-01-01",
87+
null
88+
],
89+
[]
90+
]
91+
},
92+
null
93+
],
94+
"futureScheduleCf": null,
8195
"extendPeriods": {
8296
"tag": "MonthEnd"
8397
}

absbox/tests/benchmark/china/out/test04.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@
6969
],
7070
"asOfDate": "2022-10-02",
7171
"issuanceStat": {},
72-
"futureCf": null,
72+
"futureCf": [
73+
{
74+
"tag": "CashFlowFrame",
75+
"contents": [
76+
[
77+
0,
78+
"1900-01-01",
79+
null
80+
],
81+
[]
82+
]
83+
},
84+
null
85+
],
86+
"futureScheduleCf": null,
7387
"extendPeriods": {
7488
"tag": "MonthEnd"
7589
}

absbox/tests/benchmark/china/out/test05.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,21 @@
100100
],
101101
"asOfDate": "2021-03-01",
102102
"issuanceStat": {},
103-
"futureCf": null,
103+
"futureCf": [
104+
{
105+
"tag": "CashFlowFrame",
106+
"contents": [
107+
[
108+
0,
109+
"1900-01-01",
110+
null
111+
],
112+
[]
113+
]
114+
},
115+
null
116+
],
117+
"futureScheduleCf": null,
104118
"extendPeriods": {
105119
"tag": "MonthEnd"
106120
}

absbox/tests/benchmark/china/out/test06.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,21 @@
7979
"IssuanceBalance": 7573626700,
8080
"HistoryDefaults": 81403764.08
8181
},
82-
"futureCf": null,
82+
"futureCf": [
83+
{
84+
"tag": "CashFlowFrame",
85+
"contents": [
86+
[
87+
0,
88+
"1900-01-01",
89+
null
90+
],
91+
[]
92+
]
93+
},
94+
null
95+
],
96+
"futureScheduleCf": null,
8397
"extendPeriods": {
8498
"tag": "MonthEnd"
8599
}

0 commit comments

Comments
 (0)