Bond Schedule By Index Example

only works for deal after 0.42.x

from absbox import Generic

test01 = Generic(
    "deal with bond schedule by index"
    ,{"collect":["2021-03-01","2021-06-30"],"pay":["2021-06-15","2021-07-20"]
     ,"payFreq":["DayOfMonth",20],"poolFreq":"MonthEnd","stated":"2030-01-01"}
    ,{'assets':[["Mortgage"
        ,{"originBalance":2200,"originRate":["fix",0.045],"originTerm":30
          ,"freq":"Monthly","type":"Level","originDate":"2021-02-01"}
          ,{"currentBalance":2200
          ,"currentRate":0.08
          ,"remainTerm":30
          ,"status":"current"}]]
     ,'issuanceStat':{"IssuanceBalance":2300}}
    ,(("acc01",{"balance":0}),)
    ,(("A1",{"balance":1000
             ,"rate":0.07
             ,"originBalance":1000
             ,"originRate":0.07
             ,"startDate":"2020-01-03"
             ,"rateType":{"Fixed":0.08}
             ,"bondType":{"BalanceByPeriod":
                   [[0,900]
                   ,[1,850]
                   ,[2,825]
                   ,[3,810]
                   ,[4,805] 
                   ,[5,780]
                   ,[6,0] 
                   ]}
            })
      ,("B",{"balance":1000
             ,"rate":0.0
             ,"originBalance":1000
             ,"originRate":0.07
             ,"startDate":"2020-01-03"
             ,"rateType":{"Fixed":0.00}
             ,"bondType":{"Equity":None}
             }))
    ,(("trusteeFee",{"type":{"fixFee":30},"feeStart":"2021-06-15"}),)
    ,{"amortizing":[
         ["payFee","acc01",['trusteeFee']]
         ,["accrueAndPayInt","acc01",["A1"]]
         ,['inspect',"beforePayPrin",("dealStat","int","BondPaidPeriod")]
         ,["payPrin","acc01",["A1"]]
         ,["payPrin","acc01",["B"]]
         ,["payIntResidual","acc01","B"]
     ]}
    ,[["CollectedInterest","acc01"]
      ,["CollectedPrincipal","acc01"]
      ,["CollectedPrepayment","acc01"]
      ,["CollectedRecoveries","acc01"]]
    ,None
    ,None
    ,None
    ,None
    ,"Amortizing"
    ,None
    ,None
    ,None
    ,{"BondPaidPeriod": 2,"PoolCollectedPeriod":0}
    )
from absbox import API,EnginePath,readInspect
# https://absbox.org/api/dev
localAPI = API(EnginePath.DEV,check=False)
Connecting engine server -> https://absbox.org/api/dev
/home/docs/checkouts/readthedocs.org/user_builds/absbox-doc/envs/stable/lib/python3.11/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
✅Connected, local lib:0.52.3, server:0.52.3
r = localAPI.run(test01,
             poolAssump= None,
             runAssump =[("pricing"
                          ,{"PVDate":"2021-08-22"
                          ,"PVCurve":[["2021-01-01",0.025]
                                     ,["2024-08-01",0.025]]}),
                        ]
                        ,
             read=True)
/home/docs/checkouts/readthedocs.org/user_builds/absbox-doc/envs/stable/lib/python3.11/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
---------------------------------------------------------------------------
AbsboxError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 r = localAPI.run(test01,
      2              poolAssump= None,
      3              runAssump =[("pricing"
      4                           ,{"PVDate":"2021-08-22"
      5                           ,"PVCurve":[["2021-01-01",0.025]
      6                                      ,["2024-08-01",0.025]]}),
      7                         ]
      8                         ,
      9              read=True)

File ~/checkouts/readthedocs.org/user_builds/absbox-doc/envs/stable/lib/python3.11/site-packages/absbox/client.py:362, in API.run(self, deal, poolAssump, runAssump, read, showWarning, rtn, debug)
    360 if result is None or 'error' in result or 'Left' in result:
    361     leftVal = result.get("Left","")
--> 362     raise AbsboxError(f"❌ Failed to get response from run: {leftVal}")
    363 result = result['Right']
    365 if (wMsgs:=self._getWarningMsg(result[RunResp.LogResp.value], showWarning)):

AbsboxError: ❌ Failed to get response from run: pv4: cashflow date 2021-01-01 is before pricing date 2021-08-22
readInspect(r['result'])
beforePayPrin
Date
2021-07-20 2.00
2021-08-20 3.00
2021-09-20 4.00
2021-10-20 5.00
2021-11-20 6.00
2021-12-20 7.00
2022-01-20 8.00
2022-02-20 9.00
2022-03-20 10.00
2022-04-20 11.00
2022-05-20 12.00
2022-06-20 13.00
2022-07-20 14.00
2022-08-20 15.00
2022-09-20 16.00
2022-10-20 17.00
2022-11-20 18.00
2022-12-20 19.00
2023-01-20 20.00
2023-02-20 21.00
2023-03-20 22.00
2023-04-20 23.00
2023-05-20 24.00
2023-06-20 25.00
2023-07-20 26.00
2023-08-20 27.00
2023-09-20 28.00
r['bonds']['A1']
balance interest principal rate cash intDue intOverInt factor memo
date
2021-07-20 810.00 6.71 190.00 0.07 196.71 0 0 0.81000 [<PayInt:A1>, <PayPrin:A1>]
2021-08-20 805.00 4.81 5.00 0.07 9.81 0 0 0.80500 [<PayInt:A1>, <PayPrin:A1>]
2021-09-20 780.00 4.78 25.00 0.07 29.78 0 0 0.78000 [<PayInt:A1>, <PayPrin:A1>]
2021-10-20 703.33 4.48 76.67 0.07 81.15 0 0 0.70333 [<PayInt:A1>, <PayPrin:A1>]
2021-11-20 626.36 4.18 76.97 0.07 81.15 0 0 0.62636 [<PayInt:A1>, <PayPrin:A1>]
2021-12-20 548.81 3.60 77.55 0.07 81.15 0 0 0.54881 [<PayInt:A1>, <PayPrin:A1>]
2022-01-20 470.92 3.26 77.89 0.07 81.15 0 0 0.47092 [<PayInt:A1>, <PayPrin:A1>]
2022-02-20 392.56 2.79 78.36 0.07 81.15 0 0 0.39256 [<PayInt:A1>, <PayPrin:A1>]
2022-03-20 313.51 2.10 79.05 0.07 81.15 0 0 0.31351 [<PayInt:A1>, <PayPrin:A1>]
2022-04-20 234.22 1.86 79.29 0.07 81.15 0 0 0.23422 [<PayInt:A1>, <PayPrin:A1>]
2022-05-20 154.41 1.34 79.81 0.07 81.15 0 0 0.15441 [<PayInt:A1>, <PayPrin:A1>]
2022-06-20 74.17 0.91 80.24 0.07 81.15 0 0 0.07417 [<PayInt:A1>, <PayPrin:A1>]
2022-07-20 0.00 0.42 74.17 0.07 74.59 0 0 0.00000 [<PayInt:A1>, <PayPrin:A1>]