Bond Pricing

from absbox import API,EnginePath
localAPI = API(EnginePath.DEV,lang='english',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

Setup Pricing Assumtpion

syntax

{
 "date":<Pricing Date>
 ,"curve":<Pricing Curve>
}
  • <pricing date> : the day all bond cashflow will discount back to

  • <pricing curve> : the rate to be used to PV calculation. if cashflow falls in the middle , it will use the rates proprotionally

from absbox.examples import test01

r = localAPI.run(test01
               ,poolAssump = ("Pool",("Mortgage",{"CDR":0.01},None,None,None)
                                       ,None
                                       ,None)
               ,runAssump = [("pricing"
                              ,{"date":"2021-09-20"
                                ,"curve":[["2021-01-01",0.025]
                                         ,["2024-08-01",0.025]]})]
               ,read=True
               ,showWarning=False)
/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[2], line 3
      1 from absbox.examples import test01
----> 3 r = localAPI.run(test01
      4                ,poolAssump = ("Pool",("Mortgage",{"CDR":0.01},None,None,None)
      5                                        ,None
      6                                        ,None)
      7                ,runAssump = [("pricing"
      8                               ,{"date":"2021-09-20"
      9                                 ,"curve":[["2021-01-01",0.025]
     10                                          ,["2024-08-01",0.025]]})]
     11                ,read=True
     12                ,showWarning=False)

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-09-20

Access bond pricing

if localAPI.server_info['_version']>'0.27.17':
    print(r['pricing']['summary'])
if localAPI.server_info['_version']>'0.27.17':
    print(r['pricing']['breakdown']['A1'])
if localAPI.server_info['_version']<='0.27.17':
    print(r['pricing'])
    pricing     face   WAL  duration  convexity  accure interest
A1   201.66   20.166  0.11      0.11       0.12                0
B   1291.18  129.118  0.54      0.52       1.09                0