Skip to content

Commit

Permalink
expose refince by rate
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Sep 13, 2024
1 parent 4266be9 commit 3ad498a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/AssetClass/AssetBase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ data Revolver = Heloc OriginalInfo LineOfCredit Balance IRate RemainTerms (Maybe
| DUMMY5
deriving (Show,Generic,Eq,Ord)



-- FixedAsset
data Capacity = FixedCapacity Balance
| CapacityByTerm [(Int,Balance)]
Expand Down
22 changes: 5 additions & 17 deletions src/Deal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -626,28 +626,16 @@ run t@TestDeal{accounts=accMap,fees=feeMap,triggers=mTrgMap,bonds=bndMap,status=
((shortfall,drawAmt),newAcc) = A.tryDraw dueIntToPay d (PayInt [bName]) (accMap Map.! accName)

newBnd = set L.bndIntLens iInfo $ L.payInt d drawAmt nBnd

newAccMap = Map.insert accName newAcc accMap
-- reset interest info
newBndMap = Map.insert bName newBnd bndMap
newRate = L.getBeginRate iInfo
newBndMap = Map.insert bName (newBnd {L.bndRate = newRate, L.bndDueIntDate = Just d
,L.bndLastIntPay = Just d}) bndMap
in
run t{bonds = newBndMap, accounts = newAccMap} poolFlowMap (Just ads) rates calls rAssump log

-- RefiBond d accName bnd ->
-- let
-- bName = L.bndName bnd
-- origBnd = bndMap Map.! bName
--
-- nBnd = calcDueInt t d Nothing Nothing origBnd

-- totalDueAmt = L.getOutstandingAmount nBnd
-- totalAmountIssued = L.getCurBalance bnd
--
-- deltaAmt = totalAmountIssued - totalDueAmt


-- newBndMap = Map.insert bName bnd bndMap
-- in
-- run t{bonds = newBndMap} poolFlowMap (Just ads) rates calls rAssump log
RefiBond d accName bnd -> undefined

_ -> error $ "Failed to match action on Date"++ show ad
where
Expand Down
15 changes: 13 additions & 2 deletions src/Liability.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Liability
,buildRateResetDates,isAdjustble,StepUp(..),isStepUp,getDayCountFromInfo
,calcWalBond,patchBondFactor,fundWith,writeOff,InterestOverInterestType(..)
,getCurBalance,setBondOrigDate
,bndOriginInfoLens,bndIntLens)
,bndOriginInfoLens,bndIntLens,getBeginRate)
where

import Language.Haskell.TH
Expand Down Expand Up @@ -106,7 +106,18 @@ data InterestInfo = Floater IRate Index Spread RateReset DayCount (Maybe Floor)
| FloorRate InterestInfo IRate -- ^ floor rate
| WithIoI InterestInfo InterestOverInterestType -- ^ Interest Over Interest(normal on left,IoI on right)
deriving (Show, Eq, Generic, Ord, Read)


getBeginRate :: InterestInfo -> IRate
getBeginRate (Floater a _ _ _ _ _ _ ) = a
getBeginRate (Fix a _ ) = a
getBeginRate (RefRate a _ _ _ ) = a
getBeginRate (CapRate a _ ) = getBeginRate a
getBeginRate (FloorRate a _ ) = getBeginRate a
getBeginRate (WithIoI a _) = getBeginRate a
getBeginRate InterestByYield {} = 0.0



data StepUp = PassDateSpread Date Spread -- ^ add a spread on a date and effective afterwards
| PassDateLadderSpread Date Spread RateReset -- ^ add a spread on the date pattern
deriving (Show, Eq, Generic, Ord, Read)
Expand Down

0 comments on commit 3ad498a

Please sign in to comment.