{ "cells": [ { "cell_type": "markdown", "id": "a5688603", "metadata": {}, "source": [ "### Three ways to run deal " ] }, { "cell_type": "code", "execution_count": 1, "id": "2e646c1c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> https://absbox.org/api/dev\n",
       "
\n" ], "text/plain": [ "Connecting engine server -> \u001b[4;94mhttps://absbox.org/api/dev\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/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\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
✅Connected, local lib:0.46.5, server:0.50.1\n",
       "
\n" ], "text/plain": [ "✅Connected, local li\u001b[1;92mb:0\u001b[0m.\u001b[1;36m46.5\u001b[0m, server:\u001b[1;36m0.50\u001b[0m.\u001b[1;36m1\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath\n", "\n", "localAPI = API(EnginePath.DEV, lang='english', check=False)" ] }, { "cell_type": "markdown", "id": "64b56f59", "metadata": {}, "source": [ "#### Single Run" ] }, { "cell_type": "code", "execution_count": 2, "id": "6db2f452", "metadata": {}, "outputs": [], "source": [ "from absbox import examples" ] }, { "cell_type": "code", "execution_count": 3, "id": "c7dc2e51", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/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\n", " warnings.warn(\n" ] } ], "source": [ "myAssumption = (\"Pool\",(\"Mortgage\",{\"CDR\":0.01},None,None,None)\n", " ,None\n", " ,None)\n", "\n", "\n", "r = localAPI.run(examples.test01\n", " ,poolAssump=myAssumption\n", " ,read=True)" ] }, { "cell_type": "markdown", "id": "751051de", "metadata": {}, "source": [ "the result `r` returned by API function `run()`." ] }, { "cell_type": "markdown", "id": "ea339b21", "metadata": {}, "source": [ "#### Scenario Sensitivity Run" ] }, { "cell_type": "markdown", "id": "1a0b8986", "metadata": {}, "source": [ "User can build a pool performance map and call the API function `runByScenarios`" ] }, { "cell_type": "code", "execution_count": 4, "id": "7f24f33a", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/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\n", " warnings.warn(\n" ] } ], "source": [ "myAssumption = (\"Pool\",(\"Mortgage\",{\"CDR\":0.01},None,None,None)\n", " ,None\n", " ,None)\n", "\n", "myAssumption2 = (\"Pool\",(\"Mortgage\",None,{\"CPR\":0.01},None,None)\n", " ,None\n", " ,None)\n", "\n", "r = localAPI.runByScenarios(examples.test01\n", " ,poolAssump={\"00\":myAssumption\n", " ,\"stressed\":myAssumption2}\n", " ,read=True)" ] }, { "cell_type": "markdown", "id": "a1e0e565", "metadata": {}, "source": [ "The result `r` is a dict whose keys came fromt he pool assumpiton map" ] }, { "cell_type": "code", "execution_count": 5, "id": "ee85d1e1", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalancePrincipalInterestPrepaymentDefaultRecoveryLossWACBorrowerNumPrepayPenaltyCumPrincipalCumPrepayCumDelinqCumDefaultCumRecoveryCumLoss
Date
2021-04-011989.69206.8428.6003.4703.470.08NoneNone206.84003.4703.47
2021-05-011883.73104.3213.2501.6401.640.08NoneNone311.16005.1105.11
2021-06-011777.20104.9312.5401.6001.600.08NoneNone416.09006.7106.71
2021-07-011670.20105.5411.8301.4601.460.08NoneNone521.63008.1708.17
2021-08-011562.63106.1511.1201.4201.420.08NoneNone627.78009.5909.59
\n", "
" ], "text/plain": [ " Balance Principal Interest Prepayment Default Recovery Loss \\\n", "Date \n", "2021-04-01 1989.69 206.84 28.60 0 3.47 0 3.47 \n", "2021-05-01 1883.73 104.32 13.25 0 1.64 0 1.64 \n", "2021-06-01 1777.20 104.93 12.54 0 1.60 0 1.60 \n", "2021-07-01 1670.20 105.54 11.83 0 1.46 0 1.46 \n", "2021-08-01 1562.63 106.15 11.12 0 1.42 0 1.42 \n", "\n", " WAC BorrowerNum PrepayPenalty CumPrincipal CumPrepay \\\n", "Date \n", "2021-04-01 0.08 None None 206.84 0 \n", "2021-05-01 0.08 None None 311.16 0 \n", "2021-06-01 0.08 None None 416.09 0 \n", "2021-07-01 0.08 None None 521.63 0 \n", "2021-08-01 0.08 None None 627.78 0 \n", "\n", " CumDelinq CumDefault CumRecovery CumLoss \n", "Date \n", "2021-04-01 0 3.47 0 3.47 \n", "2021-05-01 0 5.11 0 5.11 \n", "2021-06-01 0 6.71 0 6.71 \n", "2021-07-01 0 8.17 0 8.17 \n", "2021-08-01 0 9.59 0 9.59 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['00']['pool']['flow']['PoolConsol'].head()" ] }, { "cell_type": "code", "execution_count": 6, "id": "a532517d", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalancePrincipalInterestPrepaymentDefaultRecoveryLossWACBorrowerNumPrepayPenaltyCumPrincipalCumPrepayCumDelinqCumDefaultCumRecoveryCumLoss
Date
2021-04-011989.69206.8428.603.470000.08NoneNone206.843.470000
2021-05-011883.73104.3213.251.640000.08NoneNone311.165.110000
2021-06-011777.20104.9312.541.600000.08NoneNone416.096.710000
2021-07-011670.20105.5411.831.460000.08NoneNone521.638.170000
2021-08-011562.63106.1511.121.420000.08NoneNone627.789.590000
\n", "
" ], "text/plain": [ " Balance Principal Interest Prepayment Default Recovery Loss \\\n", "Date \n", "2021-04-01 1989.69 206.84 28.60 3.47 0 0 0 \n", "2021-05-01 1883.73 104.32 13.25 1.64 0 0 0 \n", "2021-06-01 1777.20 104.93 12.54 1.60 0 0 0 \n", "2021-07-01 1670.20 105.54 11.83 1.46 0 0 0 \n", "2021-08-01 1562.63 106.15 11.12 1.42 0 0 0 \n", "\n", " WAC BorrowerNum PrepayPenalty CumPrincipal CumPrepay \\\n", "Date \n", "2021-04-01 0.08 None None 206.84 3.47 \n", "2021-05-01 0.08 None None 311.16 5.11 \n", "2021-06-01 0.08 None None 416.09 6.71 \n", "2021-07-01 0.08 None None 521.63 8.17 \n", "2021-08-01 0.08 None None 627.78 9.59 \n", "\n", " CumDelinq CumDefault CumRecovery CumLoss \n", "Date \n", "2021-04-01 0 0 0 0 \n", "2021-05-01 0 0 0 0 \n", "2021-06-01 0 0 0 0 \n", "2021-07-01 0 0 0 0 \n", "2021-08-01 0 0 0 0 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['stressed']['pool']['flow']['PoolConsol'].head()" ] }, { "cell_type": "markdown", "id": "0541be7b", "metadata": {}, "source": [ "#### Structure Senstivity Run" ] }, { "cell_type": "markdown", "id": "36ca75d9", "metadata": {}, "source": [ "To run mulitple deals with same pool/deal run assumption , user can call `runStructs()` from the API.\n", "\n", "The function will return the result as a map." ] }, { "cell_type": "code", "execution_count": 7, "id": "6cb13e03", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/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\n", " warnings.warn(\n" ] } ], "source": [ "r = localAPI.runStructs({\"A\":examples.test01\n", " ,\"B\":examples.test02}\n", " ,read=True)" ] }, { "cell_type": "code", "execution_count": 8, "id": "d82d915b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
balanceinterestprincipalratecashintDueintOverIntfactormemo
date
2021-06-20543.9015.34456.100.07471.44000.54390[<PayInt:A1>, <PayPrin:A1>]
2021-07-20429.173.12114.730.07117.85000.42917[<PayInt:A1>, <PayPrin:A1>]
2021-08-20313.862.55115.310.07117.86000.31386[<PayInt:A1>, <PayPrin:A1>]
2021-09-20197.871.86115.990.07117.85000.19787[<PayInt:A1>, <PayPrin:A1>]
2021-10-2081.151.13116.720.07117.85000.08115[<PayInt:A1>, <PayPrin:A1>]
\n", "
" ], "text/plain": [ " balance interest principal rate cash intDue intOverInt \\\n", "date \n", "2021-06-20 543.90 15.34 456.10 0.07 471.44 0 0 \n", "2021-07-20 429.17 3.12 114.73 0.07 117.85 0 0 \n", "2021-08-20 313.86 2.55 115.31 0.07 117.86 0 0 \n", "2021-09-20 197.87 1.86 115.99 0.07 117.85 0 0 \n", "2021-10-20 81.15 1.13 116.72 0.07 117.85 0 0 \n", "\n", " factor memo \n", "date \n", "2021-06-20 0.54390 [, ] \n", "2021-07-20 0.42917 [, ] \n", "2021-08-20 0.31386 [, ] \n", "2021-09-20 0.19787 [, ] \n", "2021-10-20 0.08115 [, ] " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['A']['bonds']['A1'].head()" ] }, { "cell_type": "code", "execution_count": 9, "id": "376360fe", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
balanceinterestprincipalratecashintDueintOverIntfactormemo
date
2021-06-20340.8312.27459.170.07471.44000.34083[<PayInt:A1>, <PayPrin:A1>]
2021-07-20224.941.96115.890.07117.85000.22494[<PayInt:A1>, <PayPrin:A1>]
2021-08-20108.411.33116.530.07117.86000.10841[<PayInt:A1>, <PayPrin:A1>]
2021-09-200.000.64108.410.07109.05000.00000[<PayInt:A1>, <PayPrin:A1>]
\n", "
" ], "text/plain": [ " balance interest principal rate cash intDue intOverInt \\\n", "date \n", "2021-06-20 340.83 12.27 459.17 0.07 471.44 0 0 \n", "2021-07-20 224.94 1.96 115.89 0.07 117.85 0 0 \n", "2021-08-20 108.41 1.33 116.53 0.07 117.86 0 0 \n", "2021-09-20 0.00 0.64 108.41 0.07 109.05 0 0 \n", "\n", " factor memo \n", "date \n", "2021-06-20 0.34083 [, ] \n", "2021-07-20 0.22494 [, ] \n", "2021-08-20 0.10841 [, ] \n", "2021-09-20 0.00000 [, ] " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['B']['bonds']['A1'].head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.3" } }, "nbformat": 4, "nbformat_minor": 5 }