{ "cells": [ { "cell_type": "markdown", "id": "b13c5457", "metadata": {}, "source": [ "### Deal with multiple Asset Types" ] }, { "cell_type": "code", "execution_count": 2, "id": "00cd7f10", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> https://absbox.org/api/dev\n",
       "
\n" ], "text/plain": [ "\u001b[1;35mConnecting engine server -> \u001b[0m\u001b[1;4;35mhttps://absbox.org/api/dev\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Connected, local lib:0.26.4, server:0.27.8\n",
       "
\n" ], "text/plain": [ "✅\u001b[1;32mConnected, local li\u001b[0m\u001b[1;32mb:0\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m26.4\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.27\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m8\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": "code", "execution_count": 9, "id": "33f85732", "metadata": {}, "outputs": [], "source": [ "from absbox.examples import mixedAsset_test01" ] }, { "cell_type": "markdown", "id": "bbd2cc2c", "metadata": {}, "source": [ "#### import a mix-asset-type deal\n", "\n", "Lets import test case , which has two pools ,`PoolA` , `PoolB`, which holds `Morgage` and `Loan` respectively" ] }, { "cell_type": "code", "execution_count": 12, "id": "063843e0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'PoolA': {'assets': [['Mortgage',\n", " {'originBalance': 2200,\n", " 'originRate': ['fix', 0.045],\n", " 'originTerm': 30,\n", " 'freq': 'Monthly',\n", " 'type': 'Level',\n", " 'originDate': '2021-02-01'},\n", " {'currentBalance': 2200,\n", " 'currentRate': 0.08,\n", " 'remainTerm': 30,\n", " 'status': 'current'}]]},\n", " 'PoolB': {'assets': [['Loan',\n", " {'originBalance': 80000,\n", " 'originRate': ['floater',\n", " 0.045,\n", " {'index': 'SOFR3M', 'spread': 0.01, 'reset': 'QuarterEnd'}],\n", " 'originTerm': 60,\n", " 'freq': 'Monthly',\n", " 'type': 'i_p',\n", " 'originDate': '2021-02-01'},\n", " {'currentBalance': 65000,\n", " 'currentRate': 0.06,\n", " 'remainTerm': 60,\n", " 'status': 'Current'}]]}}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mixedAsset_test01.pool" ] }, { "cell_type": "markdown", "id": "ae5b5f30", "metadata": {}, "source": [ "#### Set assumption by Pool Name" ] }, { "cell_type": "code", "execution_count": 13, "id": "c3ef450a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Fee serviceFee is not paid off\n",
       "Fee serviceFee2 is not paid off\n",
       "Account acc02 has cash to be distributed\n",
       "
\n" ], "text/plain": [ "Warning Message from server:\n", "\u001b[1;33mBond B is not paid off\u001b[0m\n", "\u001b[1;33mFee serviceFee is not paid off\u001b[0m\n", "\u001b[1;33mFee serviceFee2 is not paid off\u001b[0m\n", "\u001b[1;33mAccount acc02 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "r = localAPI.run(mixedAsset_test01\n", " ,poolAssump = (\"ByName\"\n", " ,{\"PoolA\":\n", " ((\"Mortgage\",{\"CDR\":0.02} ,None, None, None)\n", " ,None\n", " ,None)\n", " ,\"PoolB\":\n", " ((\"Loan\",{\"CDR\":0.01} ,None, None, None)\n", " ,None\n", " ,None)}\n", " )\n", " ,runAssump = [(\"interest\",(\"LIBOR6M\",0.04)\n", " ,(\"SOFR3M\",0.04))\n", " ,(\"inspect\",(\"MonthEnd\",(\"poolBalance\",\"PoolB\"))\n", " ,(\"MonthEnd\",(\"poolBalance\",\"PoolA\"))\n", " )]\n", " ,read=True)" ] }, { "cell_type": "markdown", "id": "b878982f", "metadata": {}, "source": [ "#### Get result via pool name" ] }, { "cell_type": "code", "execution_count": 16, "id": "0fd3e750", "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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-07-151847.71135.1025.9906.5906.590.08NoneNone135.10006.5906.59
2021-07-311847.710.000.0000.0000.000.08NoneNone135.10006.5906.59
2021-08-311776.5068.0512.2903.1603.160.08NoneNone203.15009.7509.75
2021-09-301705.0868.3811.8203.0403.040.08NoneNone271.530012.79012.79
2021-10-311633.5368.7311.3402.8202.820.08NoneNone340.260015.61015.61
\n", "
" ], "text/plain": [ " Balance Principal Interest Prepayment Default Recovery Loss \\\n", "Date \n", "2021-07-15 1847.71 135.10 25.99 0 6.59 0 6.59 \n", "2021-07-31 1847.71 0.00 0.00 0 0.00 0 0.00 \n", "2021-08-31 1776.50 68.05 12.29 0 3.16 0 3.16 \n", "2021-09-30 1705.08 68.38 11.82 0 3.04 0 3.04 \n", "2021-10-31 1633.53 68.73 11.34 0 2.82 0 2.82 \n", "\n", " WAC BorrowerNum PrepayPenalty CumPrincipal CumPrepay \\\n", "Date \n", "2021-07-15 0.08 None None 135.10 0 \n", "2021-07-31 0.08 None None 135.10 0 \n", "2021-08-31 0.08 None None 203.15 0 \n", "2021-09-30 0.08 None None 271.53 0 \n", "2021-10-31 0.08 None None 340.26 0 \n", "\n", " CumDelinq CumDefault CumRecovery CumLoss \n", "Date \n", "2021-07-15 0 6.59 0 6.59 \n", "2021-07-31 0 6.59 0 6.59 \n", "2021-08-31 0 9.75 0 9.75 \n", "2021-09-30 0 12.79 0 12.79 \n", "2021-10-31 0 15.61 0 15.61 " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['pool']['flow']['PoolA'].head()" ] }, { "cell_type": "code", "execution_count": 17, "id": "0adfc9e4", "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalancePrincipalInterestPrepaymentDefaultRecoveryLossWACCumPrincipalCumPrepayCumDelinqCumDefaultCumRecoveryCumLoss
Date
2021-07-1564732.110.0541.130108.810108.810.050.000108.810108.81
2021-07-3164732.110.00.0000.0000.000.050.000108.810108.81
2021-08-3164676.880.0274.65055.23055.230.050.000164.040164.04
2021-09-3064621.700.0274.42055.18055.180.050.000219.220219.22
2021-10-3164568.350.0265.34053.35053.350.050.000272.570272.57
\n", "
" ], "text/plain": [ " Balance Principal Interest Prepayment Default Recovery \\\n", "Date \n", "2021-07-15 64732.11 0.0 541.13 0 108.81 0 \n", "2021-07-31 64732.11 0.0 0.00 0 0.00 0 \n", "2021-08-31 64676.88 0.0 274.65 0 55.23 0 \n", "2021-09-30 64621.70 0.0 274.42 0 55.18 0 \n", "2021-10-31 64568.35 0.0 265.34 0 53.35 0 \n", "\n", " Loss WAC CumPrincipal CumPrepay CumDelinq CumDefault \\\n", "Date \n", "2021-07-15 108.81 0.05 0.0 0 0 108.81 \n", "2021-07-31 0.00 0.05 0.0 0 0 108.81 \n", "2021-08-31 55.23 0.05 0.0 0 0 164.04 \n", "2021-09-30 55.18 0.05 0.0 0 0 219.22 \n", "2021-10-31 53.35 0.05 0.0 0 0 272.57 \n", "\n", " CumRecovery CumLoss \n", "Date \n", "2021-07-15 0 108.81 \n", "2021-07-31 0 108.81 \n", "2021-08-31 0 164.04 \n", "2021-09-30 0 219.22 \n", "2021-10-31 0 272.57 " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['pool']['flow']['PoolB'].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.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }