From 9ebd9887cd65e7f1bf13fbd7250fd61d44da30d3 Mon Sep 17 00:00:00 2001 From: yellowbean Date: Thu, 12 Dec 2024 10:18:41 +0800 Subject: [PATCH] remove debug --- CHANGELOG.md | 7 ++++++- Hastructure.cabal | 2 +- src/Deal.hs | 23 ++++++----------------- src/Deal/DealAction.hs | 6 ++---- src/Deal/DealQuery.hs | 6 +++--- swagger.json | 2 +- 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f98c788..783a649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,17 @@ +## 0.40.9 +### 2024-12-11 +* ENHANCE: Ensure always return positive ,otherwise engine will throw error +* NEW: add new action `changeStatus` in waterfall, with optional `Pre` as condition to trigger the status change + + ## 0.40.6 ### 2024-12-06 * NEW: new formula `ledgerBalanceBy`, which return either `Credit` or `Debit` balance of a ledger * FIX: step-up coupon bond which has a floater index will increase forever * ENHANCE: refactor on `PDL` book type. -* ENHANCE: ## 0.40.1 diff --git a/Hastructure.cabal b/Hastructure.cabal index b6cc86b..ed9e26a 100644 --- a/Hastructure.cabal +++ b/Hastructure.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: Hastructure -version: 0.40.9 +version: 0.40.9 description: Please see the README on GitHub at category: StructuredFinance;Securitisation;Cashflow homepage: https://github.com/yellowbean/Hastructure#readme diff --git a/src/Deal.hs b/src/Deal.hs index d738cd4..cf16d14 100644 --- a/src/Deal.hs +++ b/src/Deal.hs @@ -398,7 +398,7 @@ run t@TestDeal{accounts=accMap,fees=feeMap,triggers=mTrgMap,bonds=bndMap,status= return (prepareDeal finalDeal,newLogs++[EndRun (Just (getDate ad)) "No Pool Cashflow/All Account is zero/Not revolving"]) -- `debug` ("End of pool collection with logs with length "++ show (length log)) | otherwise - = case ad `debug` ("Action"++show ad++">>\n")of + = case ad of PoolCollection d _ -> if any (> 0) remainCollectionNum then let @@ -860,7 +860,7 @@ appendCollectedCF d t@TestDeal { pool = pt } poolInflowMap 0 -> 0 _ -> CF.mflowBalance $ last txnCollected txnToAppend = CF.patchCumulative currentStats [] txnCollected - accUpdated = Map.adjust (over P.poolFutureTxn (++ txnToAppend)) k acc `debug` ("date"++show d ++ "appending txn"++ show txnToAppend) + accUpdated = Map.adjust (over P.poolFutureTxn (++ txnToAppend)) k acc in Map.adjust (over P.poolIssuanceStat (Map.insert RuntimeCurrentPoolBalance balInCollected)) @@ -885,16 +885,8 @@ removePoolCf t@TestDeal{pool=pt} = ResecDeal uds -> ResecDeal uds _ -> error "not implement" in - t {pool=newPt} + t {pool = newPt} --- ^ TODO: need to set cashflow to different pool other than SoloPool --- setFutureCF :: Ast.Asset a => TestDeal a -> CF.CashFlowFrame -> TestDeal a --- setFutureCF t@TestDeal{pool = (SoloPool p )} cf --- = let --- newPool = p {P.futureCf = Just cf} --- newPoolType = SoloPool newPool --- in --- t {pool = newPoolType } populateDealDates :: DateDesp -> DealStatus -> (Date,Date,Date,[ActionOnDate],[ActionOnDate],Date) populateDealDates (WarehousingDates begDate rampingPoolDp rampingBondDp statedDate) @@ -950,12 +942,9 @@ runPool (P.Pool [] (Just (CF.CashFlowFrame _ txn)) _ asof _ (Just dp)) (Just (AP -- use interest rate assumption runPool (P.Pool as _ _ asof _ _) Nothing mRates -- = Right $ map (\x -> (Ast.calcCashflow x asof mRates,Map.empty)) as - = let - cfs::(Either String [CF.CashFlowFrame]) = sequenceA $ map (\x -> Ast.calcCashflow x asof mRates) as - in - do - cf <- cfs - return [ (x, Map.empty) | x <- cf ] + = do + cf <- sequenceA $ map (\x -> Ast.calcCashflow x asof mRates) as + return [ (x, Map.empty) | x <- cf ] -- asset cashflow with credit stress ---- By pool level diff --git a/src/Deal/DealAction.hs b/src/Deal/DealAction.hs index e56fb96..33de862 100644 --- a/src/Deal/DealAction.hs +++ b/src/Deal/DealAction.hs @@ -680,8 +680,8 @@ performActionWrap d -- REMOVE future cf newPfInRc = foldr (Map.adjust (set CF.cashflowTxn [])) pcf (Map.keys poolMapToLiq) -- Update current balance to zero - in - Right (t {accounts = accMapAfterLiq , pool = newPt} , rc {runPoolFlow = newPfInRc}, logs ) + in + Right (t {accounts = accMapAfterLiq , pool = newPt} , rc {runPoolFlow = newPfInRc}, logs) performActionWrap d (t, rc, logs) (W.WatchVal ms dss) @@ -718,13 +718,11 @@ performActionWrap d (t, rc, logs) (W.ChangeStatus mPre newSt) return (t, rc, logs) -- ^ go down to performAction - performActionWrap d (t, rc, logs) a = do dealAfterExe <- performAction d t a return (dealAfterExe, rc, logs) - performAction :: Ast.Asset a => Date -> TestDeal a -> W.Action -> Either String (TestDeal a) performAction d t@TestDeal{accounts=accMap, ledgers = Just ledgerM} (W.TransferAndBook mLimit an1 an2 (dr, lName) mComment) diff --git a/src/Deal/DealQuery.hs b/src/Deal/DealQuery.hs index d115dc5..77ae2a7 100644 --- a/src/Deal/DealQuery.hs +++ b/src/Deal/DealQuery.hs @@ -427,19 +427,19 @@ queryCompound t@TestDeal{accounts=accMap, bonds=bndMap, ledgers=ledgersM, fees=f Nothing else Just (x!!lookupIndx)) - pCollectedTxns `debug` ("date"++show d++"Pool collection: "++ show pCollectedTxns) + pCollectedTxns -- `debug` ("date"++show d++"Pool collection: "++ show pCollectedTxns) in do curPoolBalM <- sequenceA $ Map.mapWithKey (\k v -> queryCompound t d (FutureCurrentPoolBalance (Just [k]))) - pStat `debug` ("date"++show d++"Pool stats collection: "++ show pStat) + pStat -- `debug` ("date"++show d++"Pool stats collection: "++ show pStat) let poolStat = Map.mapWithKey (\k v -> case v of Just _v -> sum $ CF.lookupSource _v <$> ps Nothing -> sum $ CF.lookupSourceM (fromRational (curPoolBalM Map.! k)) Nothing <$> ps) - pStat `debug` ("date"++show d++"query pool current pool stat 2" ++ show pStat ) + pStat -- `debug` ("date"++show d++"query pool current pool stat 2" ++ show pStat ) return $ sum $ Map.elems $ toRational <$> poolStat -- `debug` ("query pool current stats"++ show poolStat) FuturePoolScheduleCfPv asOfDay pm mPns -> diff --git a/swagger.json b/swagger.json index cfbf6b3..bce8d1d 100644 --- a/swagger.json +++ b/swagger.json @@ -19275,7 +19275,7 @@ "name": "BSD 3" }, "title": "Hastructure API", - "version": "0.40.5" + "version": "0.40.9" }, "openapi": "3.0.0", "paths": {