Bond Pricing

from absbox import API,EnginePath
localAPI = API(EnginePath.DEV,lang='english',check=False)
Connecting engine server -> https://absbox.org/api/dev
✅Connected, local lib:0.52.7, server:0.52.7

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)
---------------------------------------------------------------------------
AbsboxError                               Traceback (most recent call last)
Cell In[2], line 3
      1 from absbox.examples import test01
      2 
----> 3 r = localAPI.run(test01
      4                ,poolAssump = ("Pool",("Mortgage",{"CDR":0.01},None,None,None)
      5                                        ,None
      6                                        ,None)

File ~/checkouts/readthedocs.org/user_builds/absbox-doc/envs/latest/lib/python3.11/site-packages/absbox/client.py:406, in API.run(self, deal, poolAssump, runAssump, read, showWarning, rtn, debug)
    402     return req
    404 result = self._send_req(req, url)
--> 406 result = self._unwrap_single(result)
    407 self._print_warnings(result, showWarning)
    409 if read:

File ~/checkouts/readthedocs.org/user_builds/absbox-doc/envs/latest/lib/python3.11/site-packages/absbox/client.py:344, in API._unwrap_single(self, result)
    342 if result is None or 'error' in result or 'Left' in result:
    343     leftVal = (result or {}).get("Left", "")
--> 344     raise AbsboxError(f"❌ Failed to get response from run: {leftVal}")
    345 return result['Right']

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