Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Sep 21, 2023
1 parent ababb98 commit 0a0342a
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 47 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Assumptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/Deal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
148 changes: 106 additions & 42 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -4131,6 +4144,12 @@
"DC_30_360_US"
]
},
"AssetDelinqPerfAssumption": {
"type": "string",
"enum": [
"DummyDelinqAssump"
]
},
"Pool_Loan": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -11483,7 +11547,7 @@
}
},
"info": {
"version": "0.20.2",
"version": "0.21.1",
"title": "Hastructure API",
"license": {
"name": "BSD 3"
Expand Down

0 comments on commit 0a0342a

Please sign in to comment.