{ "cells": [ { "cell_type": "markdown", "id": "c3524e44", "metadata": {}, "source": [ "### Refinance by rate example\n", "\n", "It's common that in `CLO` transaction ,the equity holder has the option to reset the bond's interest rate." ] }, { "cell_type": "code", "execution_count": null, "id": "66dbbaed", "metadata": {}, "outputs": [], "source": [ "from absbox import Generic\n", "\n", "test01 = Generic(\n", " \"TEST01\"\n", " ,{\"cutoff\":\"2021-03-01\",\"closing\":\"2021-06-15\",\"firstPay\":\"2021-07-26\"\n", " ,\"payFreq\":[\"DayOfMonth\",20],\"poolFreq\":\"MonthEnd\",\"stated\":\"2030-01-01\"}\n", " ,{'assets':[[\"Mortgage\"\n", " ,{\"originBalance\":2200,\"originRate\":[\"fix\",0.045],\"originTerm\":30\n", " ,\"freq\":\"Monthly\",\"type\":\"Level\",\"originDate\":\"2021-02-01\"}\n", " ,{\"currentBalance\":2200\n", " ,\"currentRate\":0.08\n", " ,\"remainTerm\":20\n", " ,\"status\":\"current\"}]]}\n", " ,((\"acc01\",{\"balance\":0}),)\n", " ,((\"A1\",{\"balance\":1000\n", " ,\"rate\":0.07\n", " ,\"originBalance\":1000\n", " ,\"originRate\":0.07\n", " ,\"startDate\":\"2020-01-03\"\n", " ,\"rateType\":{\"Fixed\":0.08}\n", " ,\"bondType\":{\"Sequential\":None}})\n", " ,(\"B\",{\"balance\":1000\n", " ,\"rate\":0.0\n", " ,\"originBalance\":1000\n", " ,\"originRate\":0.07\n", " ,\"startDate\":\"2020-01-03\"\n", " ,\"rateType\":{\"Fixed\":0.00}\n", " ,\"bondType\":{\"Equity\":None}\n", " }))\n", " ,((\"trusteeFee\",{\"type\":{\"fixFee\":30},\"feeStart\":\"2021-06-15\"}),)\n", " ,{\"amortizing\":[\n", " [\"payFee\",\"acc01\",['trusteeFee']]\n", " ,[\"accrueAndPayInt\",\"acc01\",[\"A1\"]]\n", " ,[\"payPrin\",\"acc01\",[\"A1\"]]\n", " ,[\"payPrin\",\"acc01\",[\"B\"]]\n", " ,[\"payIntResidual\",\"acc01\",\"B\"]\n", " ]}\n", " ,[[\"CollectedInterest\",\"acc01\"]\n", " ,[\"CollectedPrincipal\",\"acc01\"]\n", " ,[\"CollectedPrepayment\",\"acc01\"]\n", " ,[\"CollectedRecoveries\",\"acc01\"]]\n", " ,None\n", " ,None\n", " ,None\n", " ,None\n", " ,(\"PreClosing\",\"Amortizing\")\n", " )" ] }, { "cell_type": "code", "execution_count": 2, "id": "478d148e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> http://localhost:8081\n",
       "
\n" ], "text/plain": [ "\u001b[1;35mConnecting engine server -> \u001b[0m\u001b[1;4;35mhttp://localhost:8081\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Connected, local lib:0.28.7, server:0.29.2\n",
       "
\n" ], "text/plain": [ "✅\u001b[1;32mConnected, local li\u001b[0m\u001b[1;32mb:0\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m28.7\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.29\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m2\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": "06b57835", "metadata": {}, "source": [ "By using `refinance` ,user can set assumption to change the rate type of a bond in future .\n", "\n", "User can setup different scenario to see how different refinancing options affecting equity returns." ] }, { "cell_type": "code", "execution_count": 3, "id": "4fe0e978", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "\n",
       "
\n" ], "text/plain": [ "Warning Message from server:\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "runAssumption = [(\"refinance\"\n", " ,(\"byRate\",\"2022-07-30\",\"acc01\", \"A1\", {\"Fixed\":0.05}))\n", " ]\n", "\n", "\n", "r = localAPI.run(test01\n", " ,runAssump=runAssumption\n", " ,read=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "cf8ef104", "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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-07-261000.000.000.000.070.007.8601.00000[<PayInt:A1>, <PayPrin:A1>]
2021-08-201000.000.000.000.070.0012.6501.00000[<PayInt:A1>, <PayPrin:A1>]
2021-09-201000.000.000.000.070.0018.5901.00000[<PayInt:A1>, <PayPrin:A1>]
2021-10-201000.000.000.000.070.0024.3401.00000[<PayInt:A1>, <PayPrin:A1>]
2021-11-201000.000.000.000.070.0030.2801.00000[<PayInt:A1>, <PayPrin:A1>]
2021-12-201000.000.000.000.070.0036.0301.00000[<PayInt:A1>, <PayPrin:A1>]
2022-01-201000.000.000.000.070.0041.9701.00000[<PayInt:A1>, <PayPrin:A1>]
2022-02-20960.0547.9139.950.0787.860.0000.96005[<PayInt:A1>, <PayPrin:A1>]
2022-03-20847.345.15112.710.07117.860.0000.84734[<PayInt:A1>, <PayPrin:A1>]
2022-04-20734.515.03112.830.07117.860.0000.73451[<PayInt:A1>, <PayPrin:A1>]
2022-05-20620.874.22113.640.07117.860.0000.62087[<PayInt:A1>, <PayPrin:A1>]
2022-06-20506.713.69114.160.07117.850.0000.50671[<PayInt:A1>, <PayPrin:A1>]
2022-07-20391.762.91114.950.07117.860.0000.39176[<PayInt:A1>, <PayPrin:A1>]
2022-07-30391.760.000.000.070.000.7500.39176<PayInt:A1>
2022-08-20275.781.87115.980.05117.850.0000.27578[<PayInt:A1>, <PayPrin:A1>]
2022-09-20159.101.17116.680.05117.850.0000.15910[<PayInt:A1>, <PayPrin:A1>]
2022-10-2041.890.65117.210.05117.860.0000.04189[<PayInt:A1>, <PayPrin:A1>]
2022-11-200.000.1741.890.0542.060.0000.00000[<PayInt:A1>, <PayPrin:A1>]
\n", "
" ], "text/plain": [ " balance interest principal rate cash intDue intOverInt \\\n", "date \n", "2021-07-26 1000.00 0.00 0.00 0.07 0.00 7.86 0 \n", "2021-08-20 1000.00 0.00 0.00 0.07 0.00 12.65 0 \n", "2021-09-20 1000.00 0.00 0.00 0.07 0.00 18.59 0 \n", "2021-10-20 1000.00 0.00 0.00 0.07 0.00 24.34 0 \n", "2021-11-20 1000.00 0.00 0.00 0.07 0.00 30.28 0 \n", "2021-12-20 1000.00 0.00 0.00 0.07 0.00 36.03 0 \n", "2022-01-20 1000.00 0.00 0.00 0.07 0.00 41.97 0 \n", "2022-02-20 960.05 47.91 39.95 0.07 87.86 0.00 0 \n", "2022-03-20 847.34 5.15 112.71 0.07 117.86 0.00 0 \n", "2022-04-20 734.51 5.03 112.83 0.07 117.86 0.00 0 \n", "2022-05-20 620.87 4.22 113.64 0.07 117.86 0.00 0 \n", "2022-06-20 506.71 3.69 114.16 0.07 117.85 0.00 0 \n", "2022-07-20 391.76 2.91 114.95 0.07 117.86 0.00 0 \n", "2022-07-30 391.76 0.00 0.00 0.07 0.00 0.75 0 \n", "2022-08-20 275.78 1.87 115.98 0.05 117.85 0.00 0 \n", "2022-09-20 159.10 1.17 116.68 0.05 117.85 0.00 0 \n", "2022-10-20 41.89 0.65 117.21 0.05 117.86 0.00 0 \n", "2022-11-20 0.00 0.17 41.89 0.05 42.06 0.00 0 \n", "\n", " factor memo \n", "date \n", "2021-07-26 1.00000 [, ] \n", "2021-08-20 1.00000 [, ] \n", "2021-09-20 1.00000 [, ] \n", "2021-10-20 1.00000 [, ] \n", "2021-11-20 1.00000 [, ] \n", "2021-12-20 1.00000 [, ] \n", "2022-01-20 1.00000 [, ] \n", "2022-02-20 0.96005 [, ] \n", "2022-03-20 0.84734 [, ] \n", "2022-04-20 0.73451 [, ] \n", "2022-05-20 0.62087 [, ] \n", "2022-06-20 0.50671 [, ] \n", "2022-07-20 0.39176 [, ] \n", "2022-07-30 0.39176 \n", "2022-08-20 0.27578 [, ] \n", "2022-09-20 0.15910 [, ] \n", "2022-10-20 0.04189 [, ] \n", "2022-11-20 0.00000 [, ] " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['bonds']['A1'].loc[\"2022-06-20\":]" ] }, { "cell_type": "code", "execution_count": 5, "id": "5d2b1161", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7513205479452054" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "10/365*391.76*0.07" ] }, { "cell_type": "code", "execution_count": 6, "id": "94ae0e68", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.8769808219178081" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "21/365*391.76*0.05+0.75" ] } ], "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 }