Skip to content

Commit a13ce3b

Browse files
authored
0.41.x (#245)
* fix : order of pay sequence when remain amt is 0 * add cmt * Fix on step up & floater bond * add asset-assumption mismatch error * refactor on PDL * expose query LedgerBalanceBy * fix ledger query by direction always return positive * remove legacy DealQuery * Add utils * patch dates to Errors * expose changeStatus action * Ensure result of <limit> is above zero * update validation on liqSupport
1 parent a0eb234 commit a13ce3b

37 files changed

+1876
-1541
lines changed

.github/workflows/docker-image-dev-by-tag.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ jobs:
2727

2828
- name: Extract metadata (tags, labels) for Docker
2929
id: meta
30-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
30+
uses: docker/metadata-action@v5
3131
with:
3232
images: yellowbean/hastructure
3333
tags: |
34-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
34+
type=match,pattern=(a\d+.\d+.\d+),group=1
35+
flavor: |
36+
latest=false
3537
3638
- name: 'Cleanup build folder'
3739
run: |

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135

136136
- name: Extract metadata (tags, labels) for Docker
137137
id: meta
138-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
138+
uses: docker/metadata-action@v5
139139
with:
140140
images: yellowbean/hastructure
141141

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@
33
<!-- towncrier release notes start -->
44

55

6+
## 0.40.9
7+
### 2024-12-11
8+
* ENHANCE: Ensure <limit> always return positive ,otherwise engine will throw error
9+
* NEW: add new action `changeStatus` in waterfall, with optional `Pre` as condition to trigger the status change
10+
11+
12+
## 0.40.6
13+
### 2024-12-06
14+
* NEW: new formula `ledgerBalanceBy`, which return either `Credit` or `Debit` balance of a ledger
15+
* FIX: step-up coupon bond which has a floater index will increase forever
16+
* ENHANCE: refactor on `PDL` book type.
17+
18+
619
## 0.40.1
720
### 2024-11-05
821
* NEW: break changes on API ,now the engine is able to throw out error message instead of just hanging.
922

1023

1124
## 0.31.0
12-
1325
### 2024-11-05
1426
* NEW: new Call options assumption ,which specifies `dates` to be tested
15-
* NEW:
16-
* ENHANCE: transform financial report to a Tree from a Table
27+
* ENHANCE: transform financial report to a `Tree` from a `Table`
1728

1829
## 0.30.5
1930
### 2024-11-02

Hastructure.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.36.0.
3+
-- This file has been generated from package.yaml by hpack version 0.37.0.
44
--
55
-- see: https://github.com/sol/hpack
66

77
name: Hastructure
8-
version: 0.26.5
8+
version: 0.40.11
99
description: Please see the README on GitHub at <https://github.com/yellowbean/Hastructure#readme>
1010
category: StructuredFinance;Securitisation;Cashflow
1111
homepage: https://github.com/yellowbean/Hastructure#readme
@@ -18,7 +18,7 @@ license-file: LICENSE
1818
build-type: Simple
1919
extra-source-files:
2020
README.md
21-
ChangeLog.md
21+
CHANGELOG.md
2222

2323
source-repository head
2424
type: git

app/Main.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ import qualified DateUtil as DU
9292

9393
import Data.Scientific (fromRationalRepetend,formatScientific, Scientific,FPFormat(Fixed))
9494
import Control.Lens
95-
import Debug.Trace
9695
import qualified Types as W
9796
import Cashflow (patchCumulative)
9897

9998

99+
import Debug.Trace
100100
debug = flip Debug.Trace.trace
101101

102102

@@ -115,7 +115,7 @@ $(deriveJSON defaultOptions ''Version)
115115
instance ToSchema Version
116116

117117
version1 :: Version
118-
version1 = Version "0.40.1"
118+
version1 = Version "0.40.11"
119119

120120

121121

@@ -304,7 +304,7 @@ wrapRun (PDeal d) mAssump mNonPerfAssump
304304
(_d,_pflow,_rs,_p) <- D.runDeal d D.DealPoolFlowPricing mAssump mNonPerfAssump
305305
return (PDeal _d,_pflow,_rs,_p)
306306

307-
wrapRun x _ _ = error $ "RunDeal Failed ,due to unsupport deal type "++ show x
307+
wrapRun x _ _ = Left $ "RunDeal Failed ,due to unsupport deal type "++ show x
308308

309309

310310
data PoolTypeWrap = LPool (DB.PoolType AB.Loan)
@@ -337,7 +337,7 @@ wrapRunPoolType (FPool pt) assump mRates = D.runPoolType pt assump $ Just (AP.No
337337
wrapRunPoolType (VPool pt) assump mRates = D.runPoolType pt assump $ Just (AP.NonPerfAssumption{AP.interest = mRates})
338338
wrapRunPoolType (PPool pt) assump mRates = D.runPoolType pt assump $ Just (AP.NonPerfAssumption{AP.interest = mRates})
339339
wrapRunPoolType (UPool pt) assump mRates = D.runPoolType pt assump $ Just (AP.NonPerfAssumption{AP.interest = mRates})
340-
wrapRunPoolType x _ _ = error $ "RunPool Failed ,due to unsupport pool type "++ show x
340+
wrapRunPoolType x _ _ = Left $ "RunPool Failed ,due to unsupport pool type "++ show x
341341

342342

343343
data RunAssetReq = RunAssetReq Date [AB.AssetUnion] (Maybe AP.ApplyAssumptionType) (Maybe [RateAssumption]) (Maybe PricingMethod)

package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Hastructure
2-
version: 0.26.5
2+
version: 0.40.11
33
github: "yellowbean/Hastructure"
44
license: BSD3
55
author: "Xiaoyu"
@@ -8,7 +8,7 @@ copyright: "2024 Xiaoyu, Zhang"
88

99
extra-source-files:
1010
- README.md
11-
- ChangeLog.md
11+
- CHANGELOG.md
1212

1313
# Metadata used when publishing your package
1414
# synopsis: Short description of your package

src/Accounts.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ depositInt ed a@(Account bal _ (Just intType) _ stmt)
9898
newStmt = appendStmt stmt newTxn
9999

100100
-- | move cash from account A to account B
101-
transfer :: Account -> Amount -> Date -> Account -> (Account, Account)
102-
transfer sourceAcc@(Account sBal san _ _ sStmt)
103-
amount
101+
transfer :: (Account,Account) -> Date -> Amount -> (Account, Account)
102+
transfer (sourceAcc@(Account sBal san _ _ sStmt), targetAcc@(Account tBal tan _ _ tStmt))
104103
d
105-
targetAcc@(Account tBal tan _ _ tStmt)
104+
amount
106105
= (sourceAcc {accBalance = newSBal, accStmt = sourceNewStmt}
107106
,targetAcc {accBalance = newTBal, accStmt = targetNewStmt})
108107
where
@@ -121,7 +120,9 @@ deposit amount d source acc@(Account bal _ _ _ maybeStmt) =
121120

122121
-- | draw cash from account with a comment
123122
draw :: Amount -> Date -> TxnComment -> Account -> Account
124-
draw amount = deposit (- amount)
123+
draw amount d txn acc@Account{ accBalance = bal ,accName = an}
124+
| bal >= amount = deposit (- amount) d txn acc
125+
| otherwise = error $ "Date:"++ show d ++" Failed to draw "++ show amount ++" from account" ++ an
125126

126127
-- | draw cash from account with a comment,return shortfall and acccount
127128
tryDraw :: Amount -> Date -> TxnComment -> Account -> ((Amount,Amount),Account)

src/AssetClass/AssetCashflow.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ applyHaircut (Just A.ExtraStress{A.poolHairCut = Just haircuts}) (CF.CashFlowFra
8484
patchPrepayPenaltyFlow :: (Int,Maybe PrepayPenaltyType) -> CF.CashFlowFrame -> CF.CashFlowFrame
8585
patchPrepayPenaltyFlow (ot,mPpyPen) mflow@(CF.CashFlowFrame st trs)
8686
= let
87-
(startDate,endDate) = CF.getDateRangeCashFlowFrame mflow
87+
--(startDate,endDate) = CF.getDateRangeCashFlowFrame mflow
8888
prepaymentFlow = CF.mflowPrepayment <$> trs
8989
flowSize = CF.sizeCashFlowFrame mflow
9090
in

src/AssetClass/Installment.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ instance Asset Installment where
175175
projCashflow inst@(Installment _ cb rt (Defaulted Nothing)) asOfDay assumps _
176176
= Right $ (CF.CashFlowFrame (cb, asOfDay, Nothing) $ [CF.LoanFlow asOfDay cb 0 0 0 0 0 0 (getOriginRate inst) Nothing],Map.empty)
177177

178+
projCashflow a b c d = Left $ "Failed to match when proj mortgage with assumption >>" ++ show a ++ show b ++ show c ++ show d
179+
178180
splitWith (Installment (LoanOriginalInfo ob or ot p sd _type _obligor) cb rt st) rs
179181
= [ Installment (LoanOriginalInfo (mulBR ob ratio) or ot p sd _type _obligor) (mulBR cb ratio) rt st | ratio <- rs ]
180182

src/AssetClass/Lease.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ instance Asset Lease where
239239
begBal = CF.buildBegBal allTxns
240240

241241

242+
projCashflow a b c d = Left $ "Failed to match when proj lease with assumption >>" ++ show a ++ show b ++ show c ++ show d
243+
242244
getCurrentBal l = case l of
243245
StepUpLease _ _ bal _ _ -> bal
244246
RegularLease _ bal _ _-> bal

0 commit comments

Comments
 (0)