|
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "code", |
13 | | - "execution_count": 1, |
| 13 | + "execution_count": null, |
14 | 14 | "id": "b8d9117c", |
15 | 15 | "metadata": {}, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | | - "%load_ext autoreload\n", |
19 | | - "%autoreload 2\n", |
20 | | - "\n", |
21 | 18 | "import pandas as pd\n", |
22 | | - "\n", |
23 | 19 | "pd.set_option('display.max_rows', None)" |
24 | 20 | ] |
25 | 21 | }, |
|
73 | 69 | "bond_ICs = [(\"A\",(\"A1\",),1.05),(\"B\",(\"A1\",\"B\"),1.03)]\n", |
74 | 70 | "\n", |
75 | 71 | "IC_triggers = {f\"IC_{tName}\":\n", |
76 | | - " {\"condition\":((\"/\",(\"accountBalance\",\"intAcc\")\n", |
77 | | - " ,(\"bondDueInt\",*b))\n", |
78 | | - " ,\"<\"\n", |
79 | | - " ,threshold)\n", |
| 72 | + " {\"condition\":[\"all\"\n", |
| 73 | + " ,[(\"bondDueInt\",*b),\">\",0]\n", |
| 74 | + " ,[(\"/\", (\"accountBalance\",\"intAcc\"),(\"bondDueInt\",*b))\n", |
| 75 | + " ,\"<\"\n", |
| 76 | + " ,threshold]\n", |
| 77 | + " ]\n", |
80 | 78 | " ,\"effects\":None\n", |
81 | 79 | " ,\"status\":False\n", |
82 | 80 | " ,\"curable\":True}\n", |
|
86 | 84 | "OC_triggerNames = list(OC_triggers.keys())\n", |
87 | 85 | "\n", |
88 | 86 | "\n", |
89 | | - "\n", |
90 | | - "\n", |
91 | 87 | "CLO_sample = Generic(\n", |
92 | 88 | " \"CLO_sample\"\n", |
93 | 89 | " ,{\"cutoff\":\"2021-03-01\",\"closing\":\"2021-06-15\",\"firstPay\":\"2021-07-26\"\n", |
94 | | - " ,\"payFreq\":[\"DayOfMonth\",20],\"poolFreq\":\"MonthEnd\",\"stated\":\"2030-01-01\"}\n", |
| 90 | + " ,\"payFreq\":[\"DayOfMonth\",20],\"poolFreq\":\"MonthEnd\",\"stated\":\"2030-01-01\"}\n", |
95 | 91 | " ,{'assets':[[\"Mortgage\"\n", |
96 | 92 | " ,{\"originBalance\":2200,\"originRate\":[\"fix\",0.045],\"originTerm\":30\n", |
97 | 93 | " ,\"freq\":\"Monthly\",\"type\":\"Level\",\"originDate\":\"2021-02-01\"}\n", |
|
107 | 103 | " ,{\"amortizing\":[\n", |
108 | 104 | " # intereset waterfall\n", |
109 | 105 | " # accrue and pay senior fee \n", |
110 | | - " [\"calcAndPayFee\",\"intAcc\",['seniorFee']]\n", |
| 106 | + " [\"calcAndPayFee\",\"intAcc\",['seniorFee']]\n", |
111 | 107 | " # accrue interest for both bonds (NO payment) \n", |
112 | | - " ,[\"calcInt\",\"A1\",\"B\"]\n", |
| 108 | + " ,[\"calcInt\",\"A1\",\"B\"]\n", |
113 | 109 | " # calculate OC and IC test\n", |
114 | | - " ,['runTriggers',*IC_triggerNames]\n", |
| 110 | + " ,['runTriggers',*(IC_triggerNames)]\n", |
115 | 111 | " # payout interest of A1 \n", |
116 | | - " ,[\"payInt\",\"intAcc\",[\"A1\"]]\n", |
| 112 | + " ,[\"payInt\",\"intAcc\",[\"A1\"]]\n", |
117 | 113 | " # if all IC test is passing \n", |
118 | | - " ,[\"IfElse\",[(\"trigger\",\"InDistribution\", \"IC_A1\"),False],\n", |
| 114 | + " ,[\"IfElse\",[(\"trigger\",\"InDistribution\", \"IC_A1\"),False],\n", |
119 | 115 | " # if passing\n", |
120 | 116 | " [[\"payInt\",\"intAcc\",[\"B\"]]\n", |
121 | | - " ,[\"calcAndPayFee\",\"intAcc\",['subFee']]\n", |
122 | | - " ,[\"payIntResidual\",\"intAcc\",\"E\"]]\n", |
| 117 | + " ,[\"calcAndPayFee\",\"intAcc\",['subFee']]\n", |
| 118 | + " ,[\"payIntResidual\",\"intAcc\",\"E\"]]\n", |
123 | 119 | " # if failing, redemption senior to satisfy IC\n", |
124 | 120 | " ,[[\"payPrin\",\"intAcc\",[\"A1\"]\n", |
125 | | - " ,{\"limit\":{\"formula\":(\"bondBalance\",\"A1\")}}\n", |
126 | | - " ]\n", |
127 | | - " # update IC test again\n", |
128 | | - " ,['runTriggers',*IC_triggerNames]\n", |
129 | | - " # if IC test is passing\n", |
| 121 | + " ,{\"limit\":{\"formula\":(\"bondBalance\",\"A1\")}}\n", |
| 122 | + " ]\n", |
| 123 | + " # update IC test again\n", |
| 124 | + " #,['runTriggers',*IC_triggerNames]\n", |
| 125 | + " # if IC test is passing\n", |
130 | 126 | " ,[\"If\",[(\"trigger\",\"InDistribution\", \"IC_A1\"), False],\n", |
131 | 127 | " # pay interest of B and residual to E\n", |
132 | 128 | " [\"payInt\",\"intAcc\",[\"B\"]],\n", |
133 | 129 | " [\"calcAndPayFee\",\"intAcc\",['subFee']],\n", |
134 | 130 | " [\"payIntResidual\",\"intAcc\",\"E\"]]\n", |
135 | 131 | " ]]\n", |
136 | 132 | " # principal waterfall\n", |
137 | | - " ,[\"payPrinBySeq\",\"prinAcc\",[\"A1\",\"B\"]]\n", |
138 | | - " ,[\"payPrinResidual\",\"prinAcc\",[\"E\"]]\n", |
139 | | - " ]}\n", |
| 133 | + " ,[\"payPrinBySeq\",\"prinAcc\",[\"A1\",\"B\"]]\n", |
| 134 | + " ,[\"payPrinResidual\",\"prinAcc\",[\"E\"]]\n", |
| 135 | + " ]}\n", |
140 | 136 | " ,[[\"CollectedInterest\",\"intAcc\"]\n", |
141 | 137 | " ,[\"CollectedPrincipal\",\"prinAcc\"]\n", |
142 | 138 | " ,[\"CollectedPrepayment\",\"prinAcc\"]\n", |
|
151 | 147 | }, |
152 | 148 | { |
153 | 149 | "cell_type": "code", |
154 | | - "execution_count": 64, |
| 150 | + "execution_count": null, |
155 | 151 | "id": "79adf3c9", |
156 | 152 | "metadata": {}, |
157 | 153 | "outputs": [ |
|
209 | 205 | }, |
210 | 206 | { |
211 | 207 | "cell_type": "code", |
212 | | - "execution_count": 65, |
| 208 | + "execution_count": null, |
213 | 209 | "id": "f748d10e", |
214 | 210 | "metadata": {}, |
215 | 211 | "outputs": [ |
|
463 | 459 | } |
464 | 460 | ], |
465 | 461 | "source": [ |
466 | | - "r['triggers']['InWF']['IC_A1']" |
| 462 | + "r['triggers']['InWF']['IC_A1'].head(20)" |
| 463 | + ] |
| 464 | + }, |
| 465 | + { |
| 466 | + "cell_type": "code", |
| 467 | + "execution_count": null, |
| 468 | + "id": "ede47df5", |
| 469 | + "metadata": {}, |
| 470 | + "outputs": [], |
| 471 | + "source": [ |
| 472 | + "r['triggers']['InWF']['IC_A1'].head(20).loc['2021-07-26'].memo" |
467 | 473 | ] |
468 | 474 | }, |
469 | 475 | { |
|
873 | 879 | ], |
874 | 880 | "metadata": { |
875 | 881 | "kernelspec": { |
876 | | - "display_name": "Python 3 (ipykernel)", |
| 882 | + "display_name": "AbsBox (3.13.3)", |
877 | 883 | "language": "python", |
878 | 884 | "name": "python3" |
879 | 885 | }, |
|
887 | 893 | "name": "python", |
888 | 894 | "nbconvert_exporter": "python", |
889 | 895 | "pygments_lexer": "ipython3", |
890 | | - "version": "3.11.9" |
| 896 | + "version": "3.13.3" |
891 | 897 | } |
892 | 898 | }, |
893 | 899 | "nbformat": 4, |
|
0 commit comments