{ "cells": [ { "cell_type": "markdown", "id": "2643e18d", "metadata": {}, "source": [ "### Bond Schedule By Index Example\n", "\n", "*only works for deal after 0.42.x*" ] }, { "cell_type": "code", "execution_count": null, "id": "3ce85dc4-6e50-400f-9a0f-9a52fcfdde86", "metadata": {}, "outputs": [], "source": [ "from absbox import Generic\n", "\n", "test01 = Generic(\n", " \"deal with bond schedule by index\"\n", " ,{\"collect\":[\"2021-03-01\",\"2021-06-30\"],\"pay\":[\"2021-06-15\",\"2021-07-20\"]\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\":30\n", " ,\"status\":\"current\"}]]\n", " ,'issuanceStat':{\"IssuanceBalance\":2300}}\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\":{\"BalanceByPeriod\":\n", " [[0,900]\n", " ,[1,850]\n", " ,[2,825]\n", " ,[3,810]\n", " ,[4,805] \n", " ,[5,780]\n", " ,[6,0] \n", " ]}\n", " })\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", " ,['inspect',\"beforePayPrin\",(\"dealStat\",\"int\",\"BondPaidPeriod\")]\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", " ,\"Amortizing\"\n", " ,None\n", " ,None\n", " ,None\n", " ,{\"BondPaidPeriod\": 2,\"PoolCollectedPeriod\":0}\n", " )" ] }, { "cell_type": "code", "execution_count": null, "id": "d8f5ed3f-d8ff-47f4-84e1-a2f88372c05f", "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.41.3\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.41\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m3\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath,readInspect\n", "# https://absbox.org/api/dev\n", "localAPI = API(EnginePath.DEV,check=False)" ] }, { "cell_type": "code", "execution_count": 13, "id": "0c2db0d2-4878-4c77-bf46-9f52c0b2b9d1", "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": [ "r = localAPI.run(test01,\n", " poolAssump= None,\n", " runAssump =[(\"pricing\"\n", " ,{\"PVDate\":\"2021-08-22\"\n", " ,\"PVCurve\":[[\"2021-01-01\",0.025]\n", " ,[\"2024-08-01\",0.025]]}),\n", " ]\n", " ,\n", " read=True)" ] }, { "cell_type": "code", "execution_count": 14, "id": "320abc0a-077f-415d-b024-53ada40bb559", "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", "
beforePayPrin
Date
2021-07-202.00
2021-08-203.00
2021-09-204.00
2021-10-205.00
2021-11-206.00
2021-12-207.00
2022-01-208.00
2022-02-209.00
2022-03-2010.00
2022-04-2011.00
2022-05-2012.00
2022-06-2013.00
2022-07-2014.00
2022-08-2015.00
2022-09-2016.00
2022-10-2017.00
2022-11-2018.00
2022-12-2019.00
2023-01-2020.00
2023-02-2021.00
2023-03-2022.00
2023-04-2023.00
2023-05-2024.00
2023-06-2025.00
2023-07-2026.00
2023-08-2027.00
2023-09-2028.00
\n", "
" ], "text/plain": [ " beforePayPrin\n", "Date \n", "2021-07-20 2.00\n", "2021-08-20 3.00\n", "2021-09-20 4.00\n", "2021-10-20 5.00\n", "2021-11-20 6.00\n", "2021-12-20 7.00\n", "2022-01-20 8.00\n", "2022-02-20 9.00\n", "2022-03-20 10.00\n", "2022-04-20 11.00\n", "2022-05-20 12.00\n", "2022-06-20 13.00\n", "2022-07-20 14.00\n", "2022-08-20 15.00\n", "2022-09-20 16.00\n", "2022-10-20 17.00\n", "2022-11-20 18.00\n", "2022-12-20 19.00\n", "2023-01-20 20.00\n", "2023-02-20 21.00\n", "2023-03-20 22.00\n", "2023-04-20 23.00\n", "2023-05-20 24.00\n", "2023-06-20 25.00\n", "2023-07-20 26.00\n", "2023-08-20 27.00\n", "2023-09-20 28.00" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "readInspect(r['result'])" ] }, { "cell_type": "code", "execution_count": 15, "id": "2825d813-fc14-4bc4-bd28-00a6b05028e2", "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", "
balanceinterestprincipalratecashintDueintOverIntfactormemo
date
2021-07-20810.006.71190.000.07196.71000.81000[<PayInt:A1>, <PayPrin:A1>]
2021-08-20805.004.815.000.079.81000.80500[<PayInt:A1>, <PayPrin:A1>]
2021-09-20780.004.7825.000.0729.78000.78000[<PayInt:A1>, <PayPrin:A1>]
2021-10-20703.334.4876.670.0781.15000.70333[<PayInt:A1>, <PayPrin:A1>]
2021-11-20626.364.1876.970.0781.15000.62636[<PayInt:A1>, <PayPrin:A1>]
2021-12-20548.813.6077.550.0781.15000.54881[<PayInt:A1>, <PayPrin:A1>]
2022-01-20470.923.2677.890.0781.15000.47092[<PayInt:A1>, <PayPrin:A1>]
2022-02-20392.562.7978.360.0781.15000.39256[<PayInt:A1>, <PayPrin:A1>]
2022-03-20313.512.1079.050.0781.15000.31351[<PayInt:A1>, <PayPrin:A1>]
2022-04-20234.221.8679.290.0781.15000.23422[<PayInt:A1>, <PayPrin:A1>]
2022-05-20154.411.3479.810.0781.15000.15441[<PayInt:A1>, <PayPrin:A1>]
2022-06-2074.170.9180.240.0781.15000.07417[<PayInt:A1>, <PayPrin:A1>]
2022-07-200.000.4274.170.0774.59000.00000[<PayInt:A1>, <PayPrin:A1>]
\n", "
" ], "text/plain": [ " balance interest principal rate cash intDue intOverInt \\\n", "date \n", "2021-07-20 810.00 6.71 190.00 0.07 196.71 0 0 \n", "2021-08-20 805.00 4.81 5.00 0.07 9.81 0 0 \n", "2021-09-20 780.00 4.78 25.00 0.07 29.78 0 0 \n", "2021-10-20 703.33 4.48 76.67 0.07 81.15 0 0 \n", "2021-11-20 626.36 4.18 76.97 0.07 81.15 0 0 \n", "2021-12-20 548.81 3.60 77.55 0.07 81.15 0 0 \n", "2022-01-20 470.92 3.26 77.89 0.07 81.15 0 0 \n", "2022-02-20 392.56 2.79 78.36 0.07 81.15 0 0 \n", "2022-03-20 313.51 2.10 79.05 0.07 81.15 0 0 \n", "2022-04-20 234.22 1.86 79.29 0.07 81.15 0 0 \n", "2022-05-20 154.41 1.34 79.81 0.07 81.15 0 0 \n", "2022-06-20 74.17 0.91 80.24 0.07 81.15 0 0 \n", "2022-07-20 0.00 0.42 74.17 0.07 74.59 0 0 \n", "\n", " factor memo \n", "date \n", "2021-07-20 0.81000 [, ] \n", "2021-08-20 0.80500 [, ] \n", "2021-09-20 0.78000 [, ] \n", "2021-10-20 0.70333 [, ] \n", "2021-11-20 0.62636 [, ] \n", "2021-12-20 0.54881 [, ] \n", "2022-01-20 0.47092 [, ] \n", "2022-02-20 0.39256 [, ] \n", "2022-03-20 0.31351 [, ] \n", "2022-04-20 0.23422 [, ] \n", "2022-05-20 0.15441 [, ] \n", "2022-06-20 0.07417 [, ] \n", "2022-07-20 0.00000 [, ] " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r['bonds']['A1']" ] }, { "cell_type": "code", "execution_count": null, "id": "78fc5bfc-518d-4487-9dc0-45b9db46ed27", "metadata": {}, "outputs": [], "source": [] } ], "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.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }