Safe Haskell | None |
---|---|
Language | Haskell2010 |
Liability
Synopsis
- data Bond
- = Bond {
- bndName :: String
- bndType :: BondType
- bndOriginInfo :: OriginalInfo
- bndInterestInfo :: InterestInfo
- bndStepUp :: Maybe StepUp
- bndBalance :: Balance
- bndRate :: IRate
- bndDuePrin :: Balance
- bndDueInt :: Balance
- bndDueIntOverInt :: Balance
- bndDueIntDate :: Maybe Date
- bndLastIntPay :: Maybe Date
- bndLastPrinPay :: Maybe Date
- bndStmt :: Maybe Statement
- | MultiIntBond {
- bndName :: String
- bndType :: BondType
- bndOriginInfo :: OriginalInfo
- bndInterestInfos :: [InterestInfo]
- bndStepUps :: Maybe [StepUp]
- bndBalance :: Balance
- bndRates :: [IRate]
- bndDuePrin :: Balance
- bndDueInts :: [Balance]
- bndDueIntOverInts :: [Balance]
- bndDueIntDate :: Maybe Date
- bndLastIntPays :: Maybe [Date]
- bndLastPrinPay :: Maybe Date
- bndStmt :: Maybe Statement
- | BondGroup (Map String Bond) (Maybe BondType)
- = Bond {
- data BondType
- data OriginalInfo = OriginalInfo {}
- payInt :: Date -> Amount -> Bond -> Bond
- payPrin :: Date -> Amount -> Bond -> Bond
- consolStmt :: Bond -> Bond
- isPaidOff :: Liable lb => lb -> Bool
- getCurBalance :: Liable lb => lb -> Balance
- priceBond :: Date -> Ts -> Bond -> PriceResult
- pv :: Ts -> Date -> Date -> Amount -> Amount
- data InterestInfo
- type RateReset = DatePattern
- getDueInt :: Liable lb => lb -> Balance
- weightAverageBalance :: Date -> Date -> Bond -> Balance
- calcZspread :: (Rational, Date) -> Bond -> Ts -> Either String Spread
- payYield :: Date -> Amount -> Bond -> Bond
- getTotalDueInt :: Liable lb => lb -> Balance
- buildRateResetDates :: Bond -> StartDate -> EndDate -> [Date]
- isAdjustble :: InterestInfo -> Bool
- data StepUp
- isStepUp :: Bond -> Bool
- getDayCountFromInfo :: InterestInfo -> Maybe DayCount
- calcWalBond :: Date -> Bond -> Rational
- patchBondFactor :: Bond -> Bond
- fundWith :: Date -> Amount -> Bond -> Bond
- writeOff :: Date -> Amount -> Bond -> Either String Bond
- data InterestOverInterestType
- getCurBalance :: Liable lb => lb -> Balance
- setBondOrigDate :: Date -> Bond -> Bond
- bndOriginInfoLens :: Traversal' Bond OriginalInfo
- bndIntLens :: Traversal' Bond InterestInfo
- getBeginRate :: InterestInfo -> IRate
- _Bond :: Prism' Bond (String, BondType, OriginalInfo, InterestInfo, Maybe StepUp, Balance, IRate, Balance, Balance, Balance, Maybe Date, Maybe Date, Maybe Date, Maybe Statement)
- _BondGroup :: Prism' Bond (Map String Bond, Maybe BondType)
- totalFundedBalance :: Bond -> Balance
- getIndexFromInfo :: InterestInfo -> Maybe [Index]
- buildStepUpDates :: Bond -> StartDate -> EndDate -> [Date]
- accrueInt :: Date -> Bond -> Bond
- stepUpInterestInfo :: StepUp -> InterestInfo -> InterestInfo
- payIntByIndex :: Date -> Int -> Amount -> Bond -> Bond
- _MultiIntBond :: Prism' Bond (String, BondType, OriginalInfo, [InterestInfo], Maybe [StepUp], Balance, [IRate], Balance, [Balance], [Balance], Maybe Date, Maybe [Date], Maybe Date, Maybe Statement)
- getDueIntAt :: Liable lb => lb -> Int -> Balance
- getDueIntOverIntAt :: Liable lb => lb -> Int -> Balance
- getDueIntOverInt :: Liable lb => lb -> Balance
- getTotalDueIntAt :: Liable lb => lb -> Int -> Balance
- getCurRate :: Liable lb => lb -> IRate
- bondCashflow :: Bond -> ([Date], [Amount])
- getOutstandingAmount :: Liable lb => lb -> Balance
- valueBond :: BondPricingMethod -> Date -> [(Date, Balance)] -> Balance
- getTxnRate :: Txn -> IRate
- getAccrueBegDate :: Liable lb => lb -> Date
- getTxnInt :: Txn -> Amount
- adjInterestInfoByRate :: Rate -> InterestInfo -> InterestInfo
- adjInterestInfoBySpread :: Spread -> InterestInfo -> InterestInfo
- interestInfoTraversal :: Traversal' Bond InterestInfo
- getOriginBalance :: Liable lb => lb -> Balance
- curRatesTraversal :: Traversal' Bond IRate
- backoutAccruedInt :: Date -> Date -> [Txn] -> Amount
- extractIrrResult :: PriceResult -> Maybe IRR
- adjustBalance :: Balance -> Bond -> Bond
Documentation
Constructors
Bond | |
Fields
| |
MultiIntBond | |
Fields
| |
BondGroup (Map String Bond) (Maybe BondType) | bond group |
Instances
Constructors
Sequential | Pass through type tranche |
PAC PlannedAmorSchedule | bond with schedule amortization |
AmtByPeriod (PerCurve Balance) | principal due by period |
PacAnchor PlannedAmorSchedule [BondName] | pay till schdule balance if bonds from bond names has oustanding balance, if other bonds are paid off ,then pay oustanding balance |
Lockout Date | No principal due till date |
IO | |
Z | Z tranche |
Equity | Equity type tranche |
data OriginalInfo Source #
Constructors
OriginalInfo | |
Fields
|
Instances
FromJSON OriginalInfo Source # | |||||
Defined in Liability | |||||
ToJSON OriginalInfo Source # | |||||
Defined in Liability Methods toJSON :: OriginalInfo -> Value # toEncoding :: OriginalInfo -> Encoding # toJSONList :: [OriginalInfo] -> Value # toEncodingList :: [OriginalInfo] -> Encoding # omitField :: OriginalInfo -> Bool # | |||||
Generic OriginalInfo Source # | |||||
Defined in Liability Associated Types
| |||||
Read OriginalInfo Source # | |||||
Defined in Liability Methods readsPrec :: Int -> ReadS OriginalInfo # readList :: ReadS [OriginalInfo] # | |||||
Show OriginalInfo Source # | |||||
Defined in Liability Methods showsPrec :: Int -> OriginalInfo -> ShowS # show :: OriginalInfo -> String # showList :: [OriginalInfo] -> ShowS # | |||||
Eq OriginalInfo Source # | |||||
Defined in Liability | |||||
Ord OriginalInfo Source # | |||||
Defined in Liability Methods compare :: OriginalInfo -> OriginalInfo -> Ordering # (<) :: OriginalInfo -> OriginalInfo -> Bool # (<=) :: OriginalInfo -> OriginalInfo -> Bool # (>) :: OriginalInfo -> OriginalInfo -> Bool # (>=) :: OriginalInfo -> OriginalInfo -> Bool # max :: OriginalInfo -> OriginalInfo -> OriginalInfo # min :: OriginalInfo -> OriginalInfo -> OriginalInfo # | |||||
type Rep OriginalInfo Source # | |||||
Defined in Liability type Rep OriginalInfo = D1 ('MetaData "OriginalInfo" "Liability" "Hastructure-0.50.4-C46IQoFqEMALLVrlvHB4m" 'False) (C1 ('MetaCons "OriginalInfo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "originBalance") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Balance) :*: S1 ('MetaSel ('Just "originDate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Date)) :*: (S1 ('MetaSel ('Just "originRate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rate) :*: S1 ('MetaSel ('Just "maturityDate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Date))))) |
consolStmt :: Bond -> Bond Source #
getCurBalance :: Liable lb => lb -> Balance Source #
pv :: Ts -> Date -> Date -> Amount -> Amount Source #
calculate present value in the future using constant rate
data InterestInfo Source #
scale a spread to interest rate info
Constructors
Floater IRate Index Spread RateReset DayCount (Maybe Floor) (Maybe Cap) | |
Fix IRate DayCount | fixed rate |
RefBal DealStats InterestInfo | accure interest based on balance(described by a formula) |
RefRate IRate DealStats Float RateReset | interest rate depends to a formula |
CapRate InterestInfo IRate | cap rate |
FloorRate InterestInfo IRate | floor rate |
WithIoI InterestInfo InterestOverInterestType | Interest Over Interest(normal on left,IoI on right) |
Instances
FromJSON InterestInfo Source # | |||||
Defined in Liability | |||||
ToJSON InterestInfo Source # | |||||
Defined in Liability Methods toJSON :: InterestInfo -> Value # toEncoding :: InterestInfo -> Encoding # toJSONList :: [InterestInfo] -> Value # toEncodingList :: [InterestInfo] -> Encoding # omitField :: InterestInfo -> Bool # | |||||
Generic InterestInfo Source # | |||||
Defined in Liability Associated Types
| |||||
Read InterestInfo Source # | |||||
Defined in Liability Methods readsPrec :: Int -> ReadS InterestInfo # readList :: ReadS [InterestInfo] # | |||||
Show InterestInfo Source # | |||||
Defined in Liability Methods showsPrec :: Int -> InterestInfo -> ShowS # show :: InterestInfo -> String # showList :: [InterestInfo] -> ShowS # | |||||
Eq InterestInfo Source # | |||||
Defined in Liability | |||||
Ord InterestInfo Source # | |||||
Defined in Liability Methods compare :: InterestInfo -> InterestInfo -> Ordering # (<) :: InterestInfo -> InterestInfo -> Bool # (<=) :: InterestInfo -> InterestInfo -> Bool # (>) :: InterestInfo -> InterestInfo -> Bool # (>=) :: InterestInfo -> InterestInfo -> Bool # max :: InterestInfo -> InterestInfo -> InterestInfo # min :: InterestInfo -> InterestInfo -> InterestInfo # | |||||
type Rep InterestInfo Source # | |||||
Defined in Liability type Rep InterestInfo = D1 ('MetaData "InterestInfo" "Liability" "Hastructure-0.50.4-C46IQoFqEMALLVrlvHB4m" 'False) ((C1 ('MetaCons "Floater" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IRate) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Index) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Spread))) :*: ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RateReset) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DayCount)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Floor)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Cap))))) :+: (C1 ('MetaCons "Fix" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IRate) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DayCount)) :+: C1 ('MetaCons "RefBal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DealStats) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InterestInfo)))) :+: ((C1 ('MetaCons "RefRate" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IRate) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DealStats)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Float) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RateReset))) :+: C1 ('MetaCons "CapRate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InterestInfo) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IRate))) :+: (C1 ('MetaCons "FloorRate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InterestInfo) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IRate)) :+: C1 ('MetaCons "WithIoI" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InterestInfo) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InterestOverInterestType))))) |
type RateReset = DatePattern Source #
calcZspread :: (Rational, Date) -> Bond -> Ts -> Either String Spread Source #
get total funded balance (from transaction) of a bond
payYield :: Date -> Amount -> Bond -> Bond Source #
pay principal to single bond principal with limit of principal due
getTotalDueInt :: Liable lb => lb -> Balance Source #
isAdjustble :: InterestInfo -> Bool Source #
test if a bond may changes its interest rate
Constructors
PassDateSpread Date Spread | add a spread on a date and effective afterwards |
PassDateLadderSpread Date Spread RateReset | add a spread on the date pattern |
Instances
FromJSON StepUp Source # | |||||
ToJSON StepUp Source # | |||||
Generic StepUp Source # | |||||
Defined in Liability Associated Types
| |||||
Read StepUp Source # | |||||
Show StepUp Source # | |||||
Eq StepUp Source # | |||||
Ord StepUp Source # | |||||
type Rep StepUp Source # | |||||
Defined in Liability type Rep StepUp = D1 ('MetaData "StepUp" "Liability" "Hastructure-0.50.4-C46IQoFqEMALLVrlvHB4m" 'False) (C1 ('MetaCons "PassDateSpread" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Date) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Spread)) :+: C1 ('MetaCons "PassDateLadderSpread" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Date) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Spread) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RateReset)))) |
patchBondFactor :: Bond -> Bond Source #
data InterestOverInterestType Source #
the way how interest due amount is calculated
Constructors
OverCurrRateBy Rational | inflat ioi rate by pct over current rate |
OverFixSpread Spread | inflat ioi rate by fix spread |
Instances
FromJSON InterestOverInterestType Source # | |||||
Defined in Liability Methods parseJSON :: Value -> Parser InterestOverInterestType # parseJSONList :: Value -> Parser [InterestOverInterestType] # | |||||
ToJSON InterestOverInterestType Source # | |||||
Defined in Liability Methods toJSON :: InterestOverInterestType -> Value # toEncoding :: InterestOverInterestType -> Encoding # toJSONList :: [InterestOverInterestType] -> Value # | |||||
Generic InterestOverInterestType Source # | |||||
Defined in Liability Associated Types
Methods from :: InterestOverInterestType -> Rep InterestOverInterestType x # to :: Rep InterestOverInterestType x -> InterestOverInterestType # | |||||
Read InterestOverInterestType Source # | |||||
Defined in Liability | |||||
Show InterestOverInterestType Source # | |||||
Defined in Liability Methods showsPrec :: Int -> InterestOverInterestType -> ShowS # show :: InterestOverInterestType -> String # showList :: [InterestOverInterestType] -> ShowS # | |||||
Eq InterestOverInterestType Source # | |||||
Defined in Liability Methods (==) :: InterestOverInterestType -> InterestOverInterestType -> Bool # (/=) :: InterestOverInterestType -> InterestOverInterestType -> Bool # | |||||
Ord InterestOverInterestType Source # | |||||
Defined in Liability Methods compare :: InterestOverInterestType -> InterestOverInterestType -> Ordering # (<) :: InterestOverInterestType -> InterestOverInterestType -> Bool # (<=) :: InterestOverInterestType -> InterestOverInterestType -> Bool # (>) :: InterestOverInterestType -> InterestOverInterestType -> Bool # (>=) :: InterestOverInterestType -> InterestOverInterestType -> Bool # max :: InterestOverInterestType -> InterestOverInterestType -> InterestOverInterestType # min :: InterestOverInterestType -> InterestOverInterestType -> InterestOverInterestType # | |||||
type Rep InterestOverInterestType Source # | |||||
Defined in Liability type Rep InterestOverInterestType = D1 ('MetaData "InterestOverInterestType" "Liability" "Hastructure-0.50.4-C46IQoFqEMALLVrlvHB4m" 'False) (C1 ('MetaCons "OverCurrRateBy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)) :+: C1 ('MetaCons "OverFixSpread" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Spread))) |
getCurBalance :: Liable lb => lb -> Balance Source #
getBeginRate :: InterestInfo -> IRate Source #
_Bond :: Prism' Bond (String, BondType, OriginalInfo, InterestInfo, Maybe StepUp, Balance, IRate, Balance, Balance, Balance, Maybe Date, Maybe Date, Maybe Date, Maybe Statement) Source #
totalFundedBalance :: Bond -> Balance Source #
getIndexFromInfo :: InterestInfo -> Maybe [Index] Source #
stepUpInterestInfo :: StepUp -> InterestInfo -> InterestInfo Source #
get reset dates from interest info
payIntByIndex :: Date -> Int -> Amount -> Bond -> Bond Source #
pay interest to single bond regardless any interest due
_MultiIntBond :: Prism' Bond (String, BondType, OriginalInfo, [InterestInfo], Maybe [StepUp], Balance, [IRate], Balance, [Balance], [Balance], Maybe Date, Maybe [Date], Maybe Date, Maybe Statement) Source #
getDueIntOverInt :: Liable lb => lb -> Balance Source #
getCurRate :: Liable lb => lb -> IRate Source #
bondCashflow :: Bond -> ([Date], [Amount]) Source #
remove empty transaction frgetBondByName :: Ast.Assetom a bond
getOutstandingAmount :: Liable lb => lb -> Balance Source #
getTxnRate :: Txn -> IRate Source #
getAccrueBegDate :: Liable lb => lb -> Date Source #
adjInterestInfoByRate :: Rate -> InterestInfo -> InterestInfo Source #
add a spread to interest rate info
getOriginBalance :: Liable lb => lb -> Balance Source #
extractIrrResult :: PriceResult -> Maybe IRR Source #