|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "d92411d3", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "### Trigger by a period-based rate curve" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "code", |
| 13 | + "execution_count": 1, |
| 14 | + "id": "426fe99a", |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [], |
| 17 | + "source": [ |
| 18 | + "from absbox import API,Generic,EnginePath" |
| 19 | + ] |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "code", |
| 23 | + "execution_count": 20, |
| 24 | + "id": "bccf1e85", |
| 25 | + "metadata": {}, |
| 26 | + "outputs": [], |
| 27 | + "source": [ |
| 28 | + "test01 = Generic(\n", |
| 29 | + " \"TriggerByPeriod\"\n", |
| 30 | + " ,{\"cutoff\":\"2021-03-01\",\"closing\":\"2021-06-15\",\"firstPay\":\"2021-07-26\"\n", |
| 31 | + " ,\"payFreq\":[\"DayOfMonth\",20],\"poolFreq\":\"MonthEnd\",\"stated\":\"2030-01-01\"}\n", |
| 32 | + " ,{'assets':[[\"Mortgage\"\n", |
| 33 | + " ,{\"originBalance\":1800,\"originRate\":[\"fix\",0.045],\"originTerm\":30\n", |
| 34 | + " ,\"freq\":\"Monthly\",\"type\":\"Level\",\"originDate\":\"2021-02-01\"}\n", |
| 35 | + " ,{\"currentBalance\":1100\n", |
| 36 | + " ,\"currentRate\":0.08\n", |
| 37 | + " ,\"remainTerm\":30\n", |
| 38 | + " ,\"status\":\"current\"}]]}\n", |
| 39 | + " ,((\"acc01\",{\"balance\":0}),)\n", |
| 40 | + " ,((\"A1\",{\"balance\":1000\n", |
| 41 | + " ,\"rate\":0.07\n", |
| 42 | + " ,\"originBalance\":1000\n", |
| 43 | + " ,\"originRate\":0.07\n", |
| 44 | + " ,\"startDate\":\"2020-01-03\"\n", |
| 45 | + " ,\"rateType\":{\"Fixed\":0.08}\n", |
| 46 | + " ,\"bondType\":{\"Sequential\":None}})\n", |
| 47 | + " ,(\"B\",{\"balance\":1000\n", |
| 48 | + " ,\"rate\":0.0\n", |
| 49 | + " ,\"originBalance\":1000\n", |
| 50 | + " ,\"originRate\":0.07\n", |
| 51 | + " ,\"startDate\":\"2020-01-03\"\n", |
| 52 | + " ,\"rateType\":{\"Fixed\":0.00}\n", |
| 53 | + " ,\"bondType\":{\"Equity\":None}\n", |
| 54 | + " }))\n", |
| 55 | + " ,((\"trusteeFee\",{\"type\":{\"fixFee\":30}}),)\n", |
| 56 | + " ,{\"amortizing\":[\n", |
| 57 | + " [\"payFee\",\"acc01\",['trusteeFee']]\n", |
| 58 | + " ,[\"payInt\",\"acc01\",[\"A1\"]]\n", |
| 59 | + " ,[\"payPrin\",\"acc01\",[\"A1\"]]\n", |
| 60 | + " ,[\"payPrin\",\"acc01\",[\"B\"]]\n", |
| 61 | + " ,[\"payIntResidual\",\"acc01\",\"B\"]\n", |
| 62 | + " ]}\n", |
| 63 | + " ,[[\"CollectedInterest\",\"acc01\"]\n", |
| 64 | + " ,[\"CollectedPrincipal\",\"acc01\"]\n", |
| 65 | + " ,[\"CollectedPrepayment\",\"acc01\"]\n", |
| 66 | + " ,[\"CollectedRecoveries\",\"acc01\"]]\n", |
| 67 | + " ,None\n", |
| 68 | + " ,None\n", |
| 69 | + " ,None\n", |
| 70 | + " ,{\n", |
| 71 | + " \"BeforeDistribution\":{\"periodTest\":{\n", |
| 72 | + " \"condition\": [\"periodRateCurve\", (\"cumPoolDefaultedRate\",)\n", |
| 73 | + " , \">=\", (\"dealStat\",\"int\",\"BondPaidPeriod\")\n", |
| 74 | + " ,[[0,0.014]\n", |
| 75 | + " ,[12,0.035]\n", |
| 76 | + " ,[24,0.06]]\n", |
| 77 | + " ]\n", |
| 78 | + " ,\"effects\":(\"newStatus\",\"Ended\")\n", |
| 79 | + " ,\"status\":False\n", |
| 80 | + " ,\"curable\":False}\n", |
| 81 | + " }\n", |
| 82 | + " }\n", |
| 83 | + " ,(\"PreClosing\",\"Amortizing\")\n", |
| 84 | + " ,None\n", |
| 85 | + " ,None\n", |
| 86 | + " ,None\n", |
| 87 | + " ,{\"BondPaidPeriod\":0}\n", |
| 88 | + ")" |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "cell_type": "code", |
| 93 | + "execution_count": 9, |
| 94 | + "id": "33ca4042", |
| 95 | + "metadata": {}, |
| 96 | + "outputs": [ |
| 97 | + { |
| 98 | + "data": { |
| 99 | + "text/html": [ |
| 100 | + "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Connecting engine server -> </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold; text-decoration: underline\">http://localhost:8081</span>\n", |
| 101 | + "</pre>\n" |
| 102 | + ], |
| 103 | + "text/plain": [ |
| 104 | + "\u001b[1;35mConnecting engine server -> \u001b[0m\u001b[1;4;35mhttp://localhost:8081\u001b[0m\n" |
| 105 | + ] |
| 106 | + }, |
| 107 | + "metadata": {}, |
| 108 | + "output_type": "display_data" |
| 109 | + }, |
| 110 | + { |
| 111 | + "data": { |
| 112 | + "text/html": [ |
| 113 | + "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">✅<span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">Connected, local lib:0.</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">28.7</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">, server:</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">0.42</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">.</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">7</span>\n", |
| 114 | + "</pre>\n" |
| 115 | + ], |
| 116 | + "text/plain": [ |
| 117 | + "✅\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.42\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m7\u001b[0m\n" |
| 118 | + ] |
| 119 | + }, |
| 120 | + "metadata": {}, |
| 121 | + "output_type": "display_data" |
| 122 | + } |
| 123 | + ], |
| 124 | + "source": [ |
| 125 | + "localAPI = API(EnginePath.DEV,check=False)" |
| 126 | + ] |
| 127 | + }, |
| 128 | + { |
| 129 | + "cell_type": "code", |
| 130 | + "execution_count": 21, |
| 131 | + "id": "83f7a2f5", |
| 132 | + "metadata": {}, |
| 133 | + "outputs": [ |
| 134 | + { |
| 135 | + "data": { |
| 136 | + "text/html": [ |
| 137 | + "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Warning Message from server:\n", |
| 138 | + "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">Bond A1 is not paid off</span>\n", |
| 139 | + "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">Bond B is not paid off</span>\n", |
| 140 | + "</pre>\n" |
| 141 | + ], |
| 142 | + "text/plain": [ |
| 143 | + "Warning Message from server:\n", |
| 144 | + "\u001b[1;33mBond A1 is not paid off\u001b[0m\n", |
| 145 | + "\u001b[1;33mBond B is not paid off\u001b[0m\n" |
| 146 | + ] |
| 147 | + }, |
| 148 | + "metadata": {}, |
| 149 | + "output_type": "display_data" |
| 150 | + } |
| 151 | + ], |
| 152 | + "source": [ |
| 153 | + "r = localAPI.run(test01\n", |
| 154 | + " ,poolAssump = (\"Pool\",(\"Mortgage\",{\"CDR\":0.02},None,None,None)\n", |
| 155 | + " ,None\n", |
| 156 | + " ,None)\n", |
| 157 | + " ,read=True)" |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": 22, |
| 163 | + "id": "315c009c", |
| 164 | + "metadata": {}, |
| 165 | + "outputs": [ |
| 166 | + { |
| 167 | + "data": { |
| 168 | + "text/html": [ |
| 169 | + "<div>\n", |
| 170 | + "<style scoped>\n", |
| 171 | + " .dataframe tbody tr th:only-of-type {\n", |
| 172 | + " vertical-align: middle;\n", |
| 173 | + " }\n", |
| 174 | + "\n", |
| 175 | + " .dataframe tbody tr th {\n", |
| 176 | + " vertical-align: top;\n", |
| 177 | + " }\n", |
| 178 | + "\n", |
| 179 | + " .dataframe thead th {\n", |
| 180 | + " text-align: right;\n", |
| 181 | + " }\n", |
| 182 | + "</style>\n", |
| 183 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 184 | + " <thead>\n", |
| 185 | + " <tr style=\"text-align: right;\">\n", |
| 186 | + " <th></th>\n", |
| 187 | + " <th>status</th>\n", |
| 188 | + " <th>memo</th>\n", |
| 189 | + " </tr>\n", |
| 190 | + " <tr>\n", |
| 191 | + " <th>date</th>\n", |
| 192 | + " <th></th>\n", |
| 193 | + " <th></th>\n", |
| 194 | + " </tr>\n", |
| 195 | + " </thead>\n", |
| 196 | + " <tbody>\n", |
| 197 | + " <tr>\n", |
| 198 | + " <th>2021-07-26</th>\n", |
| 199 | + " <td>False</td>\n", |
| 200 | + " <td><Tag:Right 6.290909090909091e-3 GE Just 1.4e-2></td>\n", |
| 201 | + " </tr>\n", |
| 202 | + " <tr>\n", |
| 203 | + " <th>2021-08-20</th>\n", |
| 204 | + " <td>False</td>\n", |
| 205 | + " <td><Tag:Right 7.736363636363637e-3 GE Just 1.4e-2></td>\n", |
| 206 | + " </tr>\n", |
| 207 | + " <tr>\n", |
| 208 | + " <th>2021-09-20</th>\n", |
| 209 | + " <td>False</td>\n", |
| 210 | + " <td><Tag:Right 9.172727272727273e-3 GE Just 1.4e-2></td>\n", |
| 211 | + " </tr>\n", |
| 212 | + " <tr>\n", |
| 213 | + " <th>2021-10-20</th>\n", |
| 214 | + " <td>False</td>\n", |
| 215 | + " <td><Tag:Right 1.0554545454545455e-2 GE Just 1.4e-2></td>\n", |
| 216 | + " </tr>\n", |
| 217 | + " <tr>\n", |
| 218 | + " <th>2021-11-20</th>\n", |
| 219 | + " <td>False</td>\n", |
| 220 | + " <td><Tag:Right 1.1836363636363636e-2 GE Just 1.4e-2></td>\n", |
| 221 | + " </tr>\n", |
| 222 | + " <tr>\n", |
| 223 | + " <th>2021-12-20</th>\n", |
| 224 | + " <td>False</td>\n", |
| 225 | + " <td><Tag:Right 1.3109090909090909e-2 GE Just 1.4e-2></td>\n", |
| 226 | + " </tr>\n", |
| 227 | + " <tr>\n", |
| 228 | + " <th>2022-01-20</th>\n", |
| 229 | + " <td>True</td>\n", |
| 230 | + " <td><Tag:Right 1.4281818181818182e-2 GE Just 1.4e-2></td>\n", |
| 231 | + " </tr>\n", |
| 232 | + " </tbody>\n", |
| 233 | + "</table>\n", |
| 234 | + "</div>" |
| 235 | + ], |
| 236 | + "text/plain": [ |
| 237 | + " status memo\n", |
| 238 | + "date \n", |
| 239 | + "2021-07-26 False <Tag:Right 6.290909090909091e-3 GE Just 1.4e-2>\n", |
| 240 | + "2021-08-20 False <Tag:Right 7.736363636363637e-3 GE Just 1.4e-2>\n", |
| 241 | + "2021-09-20 False <Tag:Right 9.172727272727273e-3 GE Just 1.4e-2>\n", |
| 242 | + "2021-10-20 False <Tag:Right 1.0554545454545455e-2 GE Just 1.4e-2>\n", |
| 243 | + "2021-11-20 False <Tag:Right 1.1836363636363636e-2 GE Just 1.4e-2>\n", |
| 244 | + "2021-12-20 False <Tag:Right 1.3109090909090909e-2 GE Just 1.4e-2>\n", |
| 245 | + "2022-01-20 True <Tag:Right 1.4281818181818182e-2 GE Just 1.4e-2>" |
| 246 | + ] |
| 247 | + }, |
| 248 | + "execution_count": 22, |
| 249 | + "metadata": {}, |
| 250 | + "output_type": "execute_result" |
| 251 | + } |
| 252 | + ], |
| 253 | + "source": [ |
| 254 | + "r['triggers']['BeginDistributionWF']['periodTest']" |
| 255 | + ] |
| 256 | + } |
| 257 | + ], |
| 258 | + "metadata": { |
| 259 | + "kernelspec": { |
| 260 | + "display_name": "Python 3 (ipykernel)", |
| 261 | + "language": "python", |
| 262 | + "name": "python3" |
| 263 | + }, |
| 264 | + "language_info": { |
| 265 | + "codemirror_mode": { |
| 266 | + "name": "ipython", |
| 267 | + "version": 3 |
| 268 | + }, |
| 269 | + "file_extension": ".py", |
| 270 | + "mimetype": "text/x-python", |
| 271 | + "name": "python", |
| 272 | + "nbconvert_exporter": "python", |
| 273 | + "pygments_lexer": "ipython3", |
| 274 | + "version": "3.12.3" |
| 275 | + } |
| 276 | + }, |
| 277 | + "nbformat": 4, |
| 278 | + "nbformat_minor": 5 |
| 279 | +} |
0 commit comments