from absbox import Generic

test01 = Generic(
    "TEST01"
    ,{"cutoff":"2021-03-01","closing":"2021-06-15","firstPay":"2021-07-26"
     ,"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":20
          ,"status":"current"}]]}
    ,(("acc01",{"balance":0}),)
    ,(("A1",{"balance":1000
             ,"rate":0.07
             ,"originBalance":1000
             ,"originRate":0.07
             ,"startDate":"2020-01-03"
             ,"rateType":{"Fixed":0.08}
             ,"bondType":{"Sequential":None}})
      ,("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"]]
         ,["payPrin","acc01",["A1"]]
         ,["payPrin","acc01",["B"]]
         ,["payIntResidual","acc01","B"]
     ]}
    ,[["CollectedInterest","acc01"]
      ,["CollectedPrincipal","acc01"]
      ,["CollectedPrepayment","acc01"]
      ,["CollectedRecoveries","acc01"]]
    ,None
    ,None
    ,None
    ,None
    ,("PreClosing","Amortizing")
    )
from absbox import API,EnginePath

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

Test Calls

Legacy, but works

r = localAPI.run(test01
               ,runAssump = [("call", {"or":[{"afterDate":"2023-06-01"} # clean up any of them met
                                             ,{"poolFactor":0.3}]}
                             )]
               ,read=True)

r['result']['status']
/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(
Warning Message from server:Bond B is not paid off
Account acc01 has cash to be distributed
Outstanding pool cashflow hasn't been collected yetfromList [(PoolConsol,5)]
Date From To Comment
0 2021-06-15 PreClosing Amortizing By Deal Close
1 2023-04-20 Amortizing Called Call by triggers before waterfall distribution
2 2023-04-20 DealEnd Clean Up

New callWhen

callWhen has two options:

  • OnDates which the condition list will be tested on the dates described by a DatePattern

  • if which the condition list will be tested on the waterfall payment dates.

Call On Dates

r = localAPI.run(test01
               ,runAssump = [("callWhen", ("onDates", "MonthEnd", ["all", [("poolFactor",),"<",0.5]
                                                                        , ["date",">","2022-01-01"]
                                                                  ])
                             )]
               ,read=True)
r['result']['status']
/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(
Date From To Comment
0 2021-06-15 PreClosing Amortizing By Deal Close
1 2023-09-30 DealEnd No Pool Cashflow/All Account is zero/Not revol...

Call by Condition

r = localAPI.run(test01
               ,runAssump = [("callWhen", ("if", ["all", [("poolFactor",),"<",0.2]
                                                         , ["date",">","2022-01-01"]
                                                  ])
                             )]
               ,read=True)
r['result']['status']
/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(
Warning Message from server:Bond B is not paid off
Account acc01 has cash to be distributed
Outstanding pool cashflow hasn't been collected yetfromList [(PoolConsol,3)]
Date From To Comment
0 2021-06-15 PreClosing Amortizing By Deal Close
1 2023-06-20 Amortizing Called Call by triggers before waterfall distribution
2 2023-06-20 DealEnd Clean Up

Combine of both

r = localAPI.run(test01
               ,runAssump = [("callWhen", ("if", ["all", [("poolFactor",),"<",0.2]
                                                         , ["date",">","2022-01-01"]
                                                  ])
                                         , ("if", ["all", [("poolFactor",),"<",0.3]
                                                         , ["date",">","2022-01-01"]
                                                  ])                              
                             )]
               ,read=True)
r['result']['status']
/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(
Warning Message from server:Bond B is not paid off
Account acc01 has cash to be distributed
Outstanding pool cashflow hasn't been collected yetfromList [(PoolConsol,5)]
Date From To Comment
0 2021-06-15 PreClosing Amortizing By Deal Close
1 2023-04-20 Amortizing Called Call by triggers before waterfall distribution
2 2023-04-20 DealEnd Clean Up
r = localAPI.run(test01
               ,runAssump = [("callWhen", ("if", ["all", [("poolFactor",),"<",0.2]
                                                         , ["date",">","2022-01-01"]
                                                  ])
                                         ,("onDates", "MonthEnd", ["all", [("poolFactor",),"<",0.5]
                                                                        , ["date",">","2022-01-01"]
                                                                  ])                             
                             )]
               ,read=True)
r['result']['status']
/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(
Warning Message from server:Bond B is not paid off
Account acc01 has cash to be distributed
Outstanding pool cashflow hasn't been collected yetfromList [(PoolConsol,3)]
Date From To Comment
0 2021-06-15 PreClosing Amortizing By Deal Close
1 2023-06-20 Amortizing Called Call by triggers before waterfall distribution
2 2023-06-20 DealEnd Clean Up