{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "37c71485-964c-4b1a-8290-dcefddfa814d", "metadata": { "jupyter": { "source_hidden": true } }, "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": 8, "id": "20bc2c95-fc01-4c26-aa34-65dddfed1ec0", "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.5, server:0.30.5\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.5\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.30\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m5\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath\n", "\n", "localAPI = API(EnginePath.DEV,check=False)" ] }, { "cell_type": "markdown", "id": "7eca722c-f214-4057-964e-4492a417f8c9", "metadata": {}, "source": [ "### Test Calls" ] }, { "cell_type": "markdown", "id": "b8a717e0-8f2f-4407-8e63-1ac17f1d3e86", "metadata": {}, "source": [ "#### Legacy, but works" ] }, { "cell_type": "code", "execution_count": 40, "id": "b1d642d6-9a38-4f91-b122-6745fa1f5f8f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Account acc01 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;33mAccount acc01 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "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", "
DateFromTo
02021-06-15PreClosingAmortizing
12023-04-20AmortizingCalled
22023-04-20DealEndClean Up
\n", "
" ], "text/plain": [ " Date From To\n", "0 2021-06-15 PreClosing Amortizing\n", "1 2023-04-20 Amortizing Called\n", "2 2023-04-20 DealEnd Clean Up" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.run(test01\n", " ,runAssump = [(\"call\", {\"or\":[{\"afterDate\":\"2023-06-01\"} # clean up any of them met\n", " ,{\"poolFactor\":0.3}]}\n", " )]\n", " ,read=True)\n", "\n", "r['result']['status']" ] }, { "cell_type": "markdown", "id": "27afbbed-5449-46e6-a75c-303b40e4826e", "metadata": {}, "source": [ "### New `callWhen`\n", "\n", "\n", "`callWhen` has two options:\n", "\n", "* `OnDates` which the `condition` list will be tested on the dates described by a `DatePattern`\n", "* `if` which the `condition` list will be tested on the waterfall payment dates.\n", "\n", "#### Call On Dates\n" ] }, { "cell_type": "code", "execution_count": 37, "id": "7c7b0b89-5864-4f5c-b661-13eee7e2d942", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Account acc01 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;33mAccount acc01 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "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", "
DateFromTo
02021-06-15PreClosingAmortizing
12022-11-30AmortizingCalled
22022-11-30DealEndClean Up
\n", "
" ], "text/plain": [ " Date From To\n", "0 2021-06-15 PreClosing Amortizing\n", "1 2022-11-30 Amortizing Called\n", "2 2022-11-30 DealEnd Clean Up" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.run(test01\n", " ,runAssump = [(\"callWhen\", (\"onDates\", \"MonthEnd\", [\"all\", [(\"poolFactor\",),\"<\",0.5]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ])\n", " )]\n", " ,read=True)\n", "r['result']['status']" ] }, { "cell_type": "markdown", "id": "0ea86c04-66e2-40dd-a8d4-d57acd1263f2", "metadata": {}, "source": [ "#### Call by `Condition`" ] }, { "cell_type": "code", "execution_count": 41, "id": "78c41cd4-4aa6-4402-a855-30067b63df77", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Account acc01 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;33mAccount acc01 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "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", "
DateFromTo
02021-06-15PreClosingAmortizing
12023-06-20AmortizingCalled
22023-06-20DealEndClean Up
\n", "
" ], "text/plain": [ " Date From To\n", "0 2021-06-15 PreClosing Amortizing\n", "1 2023-06-20 Amortizing Called\n", "2 2023-06-20 DealEnd Clean Up" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.run(test01\n", " ,runAssump = [(\"callWhen\", (\"if\", [\"all\", [(\"poolFactor\",),\"<\",0.2]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ])\n", " )]\n", " ,read=True)\n", "r['result']['status']" ] }, { "cell_type": "markdown", "id": "32e14a41-9ca6-452d-88f2-1fb16425bc6a", "metadata": {}, "source": [ "#### Combine of both" ] }, { "cell_type": "code", "execution_count": 42, "id": "be216067-daf4-4b4f-ad89-e679a6171c61", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Account acc01 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;33mAccount acc01 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "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", "
DateFromTo
02021-06-15PreClosingAmortizing
12023-04-20AmortizingCalled
22023-04-20DealEndClean Up
\n", "
" ], "text/plain": [ " Date From To\n", "0 2021-06-15 PreClosing Amortizing\n", "1 2023-04-20 Amortizing Called\n", "2 2023-04-20 DealEnd Clean Up" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.run(test01\n", " ,runAssump = [(\"callWhen\", (\"if\", [\"all\", [(\"poolFactor\",),\"<\",0.2]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ])\n", " , (\"if\", [\"all\", [(\"poolFactor\",),\"<\",0.3]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ]) \n", " )]\n", " ,read=True)\n", "r['result']['status']" ] }, { "cell_type": "code", "execution_count": 43, "id": "282cc68a-ae79-4124-ad8f-980e32f5f8af", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:\n",
       "Bond B is not paid off\n",
       "Account acc01 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;33mAccount acc01 has cash to be distributed\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "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", "
DateFromTo
02021-06-15PreClosingAmortizing
12022-11-30AmortizingCalled
22022-11-30DealEndClean Up
\n", "
" ], "text/plain": [ " Date From To\n", "0 2021-06-15 PreClosing Amortizing\n", "1 2022-11-30 Amortizing Called\n", "2 2022-11-30 DealEnd Clean Up" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.run(test01\n", " ,runAssump = [(\"callWhen\", (\"if\", [\"all\", [(\"poolFactor\",),\"<\",0.2]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ])\n", " ,(\"onDates\", \"MonthEnd\", [\"all\", [(\"poolFactor\",),\"<\",0.5]\n", " , [\"date\",\">\",\"2022-01-01\"]\n", " ]) \n", " )]\n", " ,read=True)\n", "r['result']['status']" ] }, { "cell_type": "code", "execution_count": null, "id": "a23ea2e2-220c-491a-adab-0c6bcfb11c35", "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.11.2" } }, "nbformat": 4, "nbformat_minor": 5 }