{ "cells": [ { "cell_type": "markdown", "id": "d92411d3", "metadata": {}, "source": [ "### Trigger by a period-based rate curve" ] }, { "cell_type": "code", "execution_count": 1, "id": "426fe99a", "metadata": {}, "outputs": [], "source": [ "from absbox import API,Generic,EnginePath" ] }, { "cell_type": "code", "execution_count": 7, "id": "bccf1e85", "metadata": {}, "outputs": [], "source": [ "test01 = Generic(\n", " \"TriggerByPeriod\"\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\":1800,\"originRate\":[\"fix\",0.045],\"originTerm\":30\n", " ,\"freq\":\"Monthly\",\"type\":\"Level\",\"originDate\":\"2021-02-01\"}\n", " ,{\"currentBalance\":1100\n", " ,\"currentRate\":0.08\n", " ,\"remainTerm\":30\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", " ,[\"payInt\",\"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", " ,{\n", " \"BeforeDistribution\":{\"periodTest\":{\n", " \"condition\": [\"periodRateCurve\", (\"cumPoolDefaultedRate\",)\n", " , \">=\", (\"dealStat\",\"int\",\"BondPaidPeriod\")\n", " ,[[0,0.014]\n", " ,[12,0.035]\n", " ,[24,0.06]]\n", " ]\n", " ,\"effects\":(\"newStatus\",\"Ended\")\n", " ,\"status\":False\n", " ,\"curable\":False}\n", " }\n", " }\n", " ,(\"PreClosing\",\"Amortizing\")\n", " ,None\n", " ,None\n", " ,None\n", " ,{\"BondPaidPeriod\":0}\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "id": "33ca4042", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> http://localhost:8081\n",
"\n"
],
"text/plain": [
"Connecting engine server -> \u001b[4;94mhttp://localhost:8081\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"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": [ "localAPI = API(EnginePath.DEV,check=False)" ] }, { "cell_type": "code", "execution_count": 10, "id": "affc23dc-659d-46da-8432-e5043c7c77f7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'BeginDistributionWF': {'periodTest': {'trgName': '',\n", " 'trgCondition': {'tag': 'IfRateByPeriodCurve',\n", " 'contents': ['GE',\n", " {'tag': 'CumulativePoolDefaultedRate', 'contents': None},\n", " {'tag': 'DealStatInt', 'contents': 'BondPaidPeriod'},\n", " {'tag': 'CurrentVal',\n", " 'contents': [[0, 0.014], [12, 0.035], [24, 0.06]]}]},\n", " 'trgEffects': {'tag': 'DealStatusTo',\n", " 'contents': {'tag': 'Ended', 'contents': None}},\n", " 'trgStatus': False,\n", " 'trgCurable': False}}}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test01.json['contents']['triggers']" ] }, { "cell_type": "code", "execution_count": 11, "id": "83f7a2f5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Warning Message from server:Bond A1 is not paid off\n",
"Bond B is not paid off\n",
"Oustanding pool cashflow hasn't been collected yetfromList [(PoolConsol,20)]\n",
"\n"
],
"text/plain": [
"Warning Message from server:Bond A1 is not paid off\n",
"Bond B is not paid off\n",
"Oustanding pool cashflow hasn't been collected yetfromList \u001b[1m[\u001b[0m\u001b[1m(\u001b[0mPoolConsol,\u001b[1;36m20\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"r = localAPI.run(test01\n",
" ,poolAssump = (\"Pool\",(\"Mortgage\",{\"CDR\":0.02},None,None,None)\n",
" ,None\n",
" ,None)\n",
" ,read=True)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "315c009c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"| \n", " | status | \n", "memo | \n", "
|---|---|---|
| date | \n", "\n", " | \n", " |
| 2021-07-26 | \n", "False | \n", "<Tag:Right 6.290909090909091e-3 >= Just 1.4e-2> | \n", "
| 2021-08-20 | \n", "False | \n", "<Tag:Right 7.736363636363637e-3 >= Just 1.4e-2> | \n", "
| 2021-09-20 | \n", "False | \n", "<Tag:Right 9.172727272727273e-3 >= Just 1.4e-2> | \n", "
| 2021-10-20 | \n", "False | \n", "<Tag:Right 1.0554545454545455e-2 >= Just 1.4e-2> | \n", "
| 2021-11-20 | \n", "False | \n", "<Tag:Right 1.1836363636363636e-2 >= Just 1.4e-2> | \n", "
| 2021-12-20 | \n", "False | \n", "<Tag:Right 1.3109090909090909e-2 >= Just 1.4e-2> | \n", "
| 2022-01-20 | \n", "True | \n", "<Tag:Right 1.4281818181818182e-2 >= Just 1.4e-2> | \n", "