From 0a0342af3943068a9a26dd8d91b0922d9a06ee16 Mon Sep 17 00:00:00 2001 From: Xiaoyu Date: Thu, 21 Sep 2023 15:11:19 +0800 Subject: [PATCH] minor fix --- ChangeLog.md | 5 ++ README.md | 5 +- src/Assumptions.hs | 2 +- src/Deal.hs | 5 +- src/Types.hs | 1 + swagger.json | 148 ++++++++++++++++++++++++++++++++------------- 6 files changed, 119 insertions(+), 47 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c4209cfd..0daede72 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,10 @@ # Changelog for Hastructure +## 0.21.1 +### 2023-9-21 +* BREAK: seperate `performance assumption` +* BREAK: add `delinquency` projection on mortgage as well as schedule mortgage cashflow + ## 0.20.3 ### 2023-9-4 * ENHANCE: now user can include boolean/int/balance/rate type query in `inspect` field diff --git a/README.md b/README.md index e59a3fbf..084834dc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ * Docker Support * Asset class coverage (Mortgage/Student Loan/Auto Loan/Rentals/Corp Loan/Consumer Installment) * Pool Assumptions - * Mortgage (Prepay,Prepay Penalty,Default,Recovery Lag/Rate) + * Mortgage (Prepay, Prepay Penalty, Deliquency, Default,Recovery Lag/Rate) * Installment (Prepay Default Recovery Lag/Rate) * Corp Loan (Prepay Default Recovery Lag/Rate) * Rentals (Gaps between leases,Rental Curve Assumption) @@ -50,10 +50,11 @@ * Running multiple scenarios on single deal * Pricing on single asset * Revoving Buy Analysis -* Formula Support +* Free Formula Support * User is able to using statistics of deal ( Pool Balance,Account balance ,total Bond Balance of , A factor of .. ) to construct formula which used to specify the amount of cash to transfer , pay out to fee or liabilities etc. * Misc * Support user define pay dates & pool collection dates + ### Online Demo The demo only cover very limit features of this engine and subject to UI performance issue due to rapid prototype design of web component diff --git a/src/Assumptions.hs b/src/Assumptions.hs index 2e2ee419..2eebef7c 100644 --- a/src/Assumptions.hs +++ b/src/Assumptions.hs @@ -47,7 +47,7 @@ lookupAssumptionByIdx :: [StratPerfByIdx] -> Int -> AssetPerf lookupAssumptionByIdx sbi i = case find (\(indxs,_) -> Set.member i (Set.fromList indxs) ) sbi of Just (_, aps ) -> aps - Nothing -> error ("Can't find idx"++ (show i)++"in starfication list"++ (show sbi)) + Nothing -> error ("Can't find idx"++ show i ++"in starfication list"++ (show sbi)) data ApplyAssumptionType = PoolLevel AssetPerf diff --git a/src/Deal.hs b/src/Deal.hs index 49778b45..ac428447 100644 --- a/src/Deal.hs +++ b/src/Deal.hs @@ -366,7 +366,7 @@ run t@TestDeal{accounts=accMap,fees=feeMap,triggers=mTrgMap,bonds=bndMap} poolFl RtnRate -> InspectRate d ds $ queryDealRate t (patchDateToStats d ds) RtnBool -> InspectBool d ds $ queryDealBool t (patchDateToStats d ds) RtnInt -> InspectInt d ds $ queryDealInt t (patchDateToStats d ds) d - _ -> InspectBal d ds $ queryDeal t (patchDateToStats d ds) `debug` ("getDealStatType"++show (getDealStatType ds)++ ">>>"++ show ds) + _ -> InspectBal d ds $ queryDeal t (patchDateToStats d ds) -- `debug` ("getDealStatType"++show (getDealStatType ds)++ ">>>"++ show ds) in run t poolFlow (Just ads) rates calls rAssump $ log++[newlog] -- `debug` ("Add log"++show newlog) @@ -556,7 +556,7 @@ calcDealStageDate _ = [] runPool :: P.Asset a => P.Pool a -> Maybe AP.ApplyAssumptionType -> Maybe [RateAssumption] -> [CF.CashFlowFrame] -- schedule cashflow just ignores the interest rate assumption runPool (P.Pool [] (Just cf) asof _ _) Nothing _ = [cf] -runPool (P.Pool [] (Just (CF.CashFlowFrame txn)) asof _ (Just dp)) (Just (AP.PoolLevel assumps)) mRates = [ (P.projCashflow (ACM.ScheduleMortgageFlow asof txn dp) asof assumps mRates) ] -- `debug` ("PROJ in schedule flow") +runPool (P.Pool [] (Just (CF.CashFlowFrame txn)) asof _ (Just dp)) (Just (AP.PoolLevel assumps)) mRates = [ P.projCashflow (ACM.ScheduleMortgageFlow asof txn dp) asof assumps mRates ] -- `debug` ("PROJ in schedule flow") -- contractual cashflow will use interest rate assumption runPool (P.Pool as _ asof _ _) Nothing mRates = map (\x -> P.calcCashflow x asof mRates) as -- `debug` ("RUNPOOL-> calc cashflow") @@ -569,6 +569,7 @@ runPool (P.Pool as Nothing asof _ _) (Just (AP.ByIndex idxAssumps)) mRates = _assumps = map (AP.lookupAssumptionByIdx idxAssumps) [0..(pred numAssets)] -- `debug` ("Num assets"++ show numAssets) in zipWith (\x a -> P.projCashflow x asof a mRates) as _assumps +runPool _a _b _c = error $ "Failed to match" ++ show _a ++ show _b ++ show _c getInits :: P.Asset a => TestDeal a -> Maybe AP.ApplyAssumptionType -> Maybe AP.NonPerfAssumption -> (TestDeal a,[ActionOnDate], CF.CashFlowFrame) diff --git a/src/Types.hs b/src/Types.hs index a6fb524e..0898098a 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -484,6 +484,7 @@ getDealStatType (Avg dss) = getDealStatType (head dss) getDealStatType (Max dss) = getDealStatType (head dss) getDealStatType (Min dss) = getDealStatType (head dss) getDealStatType (Divide ds1 ds2) = getDealStatType ds1 +getDealStatType _ = RtnBalance dealStatType _ = RtnBalance diff --git a/swagger.json b/swagger.json index 87fdcc0e..c3712ade 100644 --- a/swagger.json +++ b/swagger.json @@ -2918,7 +2918,20 @@ "$ref": "#/components/schemas/RevolvingPool" }, { - "$ref": "#/components/schemas/AssetPerfAssumption" + "items": [ + { + "$ref": "#/components/schemas/AssetPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDelinqPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDefaultedPerfAssumption" + } + ], + "maxItems": 3, + "type": "array", + "minItems": 3 } ], "maxItems": 2, @@ -4131,6 +4144,12 @@ "DC_30_360_US" ] }, + "AssetDelinqPerfAssumption": { + "type": "string", + "enum": [ + "DummyDelinqAssump" + ] + }, "Pool_Loan": { "type": "object", "properties": { @@ -7155,6 +7174,63 @@ "collects" ] }, + "AssetDefaultedPerfAssumption": { + "oneOf": [ + { + "type": "object", + "properties": { + "contents": { + "items": [ + { + "format": "double", + "type": "number" + }, + { + "maximum": 9223372036854775807, + "type": "integer", + "minimum": -9223372036854775808 + }, + { + "items": { + "format": "double", + "type": "number" + }, + "type": "array" + } + ], + "maxItems": 3, + "type": "array", + "minItems": 3 + }, + "tag": { + "type": "string", + "enum": [ + "DefaultedRecovery" + ] + } + }, + "required": [ + "tag", + "contents" + ] + }, + { + "type": "object", + "properties": { + "tag": { + "type": "string", + "enum": [ + "DummyDefaultAssump" + ] + } + }, + "required": [ + "tag" + ] + } + ], + "type": "object" + }, "TestDeal_Installment": { "type": "object", "properties": { @@ -9519,44 +9595,6 @@ "tag", "contents" ] - }, - { - "type": "object", - "properties": { - "contents": { - "items": [ - { - "format": "double", - "type": "number" - }, - { - "maximum": 9223372036854775807, - "type": "integer", - "minimum": -9223372036854775808 - }, - { - "items": { - "format": "double", - "type": "number" - }, - "type": "array" - } - ], - "maxItems": 3, - "type": "array", - "minItems": 3 - }, - "tag": { - "type": "string", - "enum": [ - "DefaultedRecovery" - ] - } - }, - "required": [ - "tag", - "contents" - ] } ], "type": "object" @@ -11121,7 +11159,20 @@ "type": "object", "properties": { "contents": { - "$ref": "#/components/schemas/AssetPerfAssumption" + "items": [ + { + "$ref": "#/components/schemas/AssetPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDelinqPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDefaultedPerfAssumption" + } + ], + "maxItems": 3, + "type": "array", + "minItems": 3 }, "tag": { "type": "string", @@ -11150,7 +11201,20 @@ "type": "array" }, { - "$ref": "#/components/schemas/AssetPerfAssumption" + "items": [ + { + "$ref": "#/components/schemas/AssetPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDelinqPerfAssumption" + }, + { + "$ref": "#/components/schemas/AssetDefaultedPerfAssumption" + } + ], + "maxItems": 3, + "type": "array", + "minItems": 3 } ], "maxItems": 2, @@ -11483,7 +11547,7 @@ } }, "info": { - "version": "0.20.2", + "version": "0.21.1", "title": "Hastructure API", "license": { "name": "BSD 3"