{
"cells": [
{
"cell_type": "markdown",
"id": "751fa0b5-8962-4eea-ad90-5c1e53826a78",
"metadata": {},
"source": [
"### MultiIntBond"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "7471d1a6-f755-444c-a939-b3765eedf387",
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "88764d10-c902-489b-b9e8-1defca48a9b5",
"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.40.13\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.40\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m13\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from absbox import API,mkDeal,readInspect,EnginePath\n",
"localAPI = API(EnginePath.DEV,check=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c9f9f9a2-699a-42da-8da0-bda258fdfe89",
"metadata": {},
"outputs": [],
"source": [
"from absbox import Generic\n",
"\n",
"test01 = Generic(\n",
" \"MultiIntBond\"\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\":1200\n",
" ,\"rates\":[0.05,0.02]\n",
" ,\"originBalance\":1200\n",
" ,\"originRate\":0.07\n",
" ,\"startDate\":\"2020-01-03\"\n",
" ,\"rateTypes\":[(\"fix\",0.05),(\"fix\",0.02)]\n",
" ,\"bondType\":{\"Sequential\":None}}\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",
" ,[\"calcInt\",\"A1\"]\n",
" , [\"inspect\",\"after acc a1 all \",(\"bondDueIntTotal\",\"A1\")]\n",
" , [\"inspect\",\"after acc a1 0 \",(\"bondDueIntByIndex\",0,\"A1\")]\n",
" , [\"inspect\",\"after acc a1 0 ioi\",(\"bondDueIntOverIntByIndex\",0,\"A1\")]\n",
" , [\"inspect\",\"after acc a1 1 \",(\"bondDueIntByIndex\",1,\"A1\")]\n",
" , [\"inspect\",\"after acc a1 1 ioi\",(\"bondDueIntOverIntByIndex\",1,\"A1\")]\n",
" ,[\"payIntByIndex\",\"acc01\",[\"A1\"],0]\n",
" , [\"inspect\",\"after pay 0 a1 all \",(\"bondDueIntTotal\",\"A1\")]\n",
" , [\"inspect\",\"after pay 0 a1 0 \",(\"bondDueIntByIndex\",0,\"A1\")]\n",
" , [\"inspect\",\"after pay 0 a1 0 ioi\",(\"bondDueIntOverIntByIndex\",0,\"A1\")]\n",
" , [\"inspect\",\"after pay 0 a1 1 \",(\"bondDueIntByIndex\",1,\"A1\")]\n",
" , [\"inspect\",\"after pay 0 a1 1 ioi\",(\"bondDueIntOverIntByIndex\",1,\"A1\")]\n",
" ,[\"payIntByIndex\",\"acc01\",[\"A1\"],1]\n",
" , [\"inspect\",\"after pay 1 a1 all \",(\"bondDueIntTotal\",\"A1\")]\n",
" , [\"inspect\",\"after pay 1 a1 0 \",(\"bondDueIntByIndex\",0,\"A1\")]\n",
" , [\"inspect\",\"after pay 1 a1 1 \",(\"bondDueIntByIndex\",1,\"A1\")]\n",
" #,[\"payPrin\",\"acc01\",[\"A1\"]]\n",
" ,[\"payPrin\",\"acc01\",[\"B\"]]\n",
" ,[\"payIntResidual\",\"acc01\",\"B\"]\n",
" ]\n",
" ,\"cleanUp\":[]\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": 165,
"id": "d54c2955-6700-4748-ba4f-06121fec8749",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Warning Message from server:\n",
"Bond A1 is not paid off\n",
"Bond B is not paid off\n",
"\n"
],
"text/plain": [
"Warning Message from server:\n",
"\u001b[1;33mBond A1 is not paid off\u001b[0m\n",
"\u001b[1;33mBond B is not paid off\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"r = localAPI.run(test01\n",
" ,runAssump = [(\"stop\",\"2022-04-21\")]\n",
" ,read=True)"
]
},
{
"cell_type": "code",
"execution_count": 161,
"id": "f9351860-e499-4a39-8cb9-98c39d86b578",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" balance | \n",
" interest | \n",
" principal | \n",
" rate | \n",
" cash | \n",
" intDue | \n",
" intOverInt | \n",
" factor | \n",
" memo | \n",
"
\n",
" \n",
" | date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-02-20 | \n",
" 1200 | \n",
" 87.86 | \n",
" 0 | \n",
" 0.07 | \n",
" 87.86 | \n",
" 43.23 | \n",
" 0 | \n",
" 1.0 | \n",
" <PayInt:A1> | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 1200 | \n",
" 101.53 | \n",
" 0 | \n",
" 0.07 | \n",
" 101.53 | \n",
" 0.00 | \n",
" 0 | \n",
" 1.0 | \n",
" [<PayInt:A1>, <PayInt:A1>] | \n",
"
\n",
" \n",
" | 2022-04-20 | \n",
" 1200 | \n",
" 7.12 | \n",
" 0 | \n",
" 0.07 | \n",
" 7.12 | \n",
" 0.00 | \n",
" 0 | \n",
" 1.0 | \n",
" [<PayInt:A1>, <PayInt:A1>] | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" balance interest principal rate cash intDue intOverInt \\\n",
"date \n",
"2022-02-20 1200 87.86 0 0.07 87.86 43.23 0 \n",
"2022-03-20 1200 101.53 0 0.07 101.53 0.00 0 \n",
"2022-04-20 1200 7.12 0 0.07 7.12 0.00 0 \n",
"\n",
" factor memo \n",
"date \n",
"2022-02-20 1.0 \n",
"2022-03-20 1.0 [, ] \n",
"2022-04-20 1.0 [, ] "
]
},
"execution_count": 161,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r['bonds']['A1']"
]
},
{
"cell_type": "code",
"execution_count": 162,
"id": "fd38bd98-eaf3-42ce-a5ff-6eec867ebd86",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" balance | \n",
" change | \n",
" memo | \n",
"
\n",
" \n",
" | date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-03-20 | \n",
" 117.86 | \n",
" 0.00 | \n",
" <SeqPayFee:trusteeFee> | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 69.87 | \n",
" -47.99 | \n",
" <PayInt:A1> | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 16.33 | \n",
" -53.54 | \n",
" <PayInt:A1> | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 0.00 | \n",
" -16.33 | \n",
" <PayPrin:B> | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 0.00 | \n",
" 0.00 | \n",
" <PayYield:B> | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" balance change memo\n",
"date \n",
"2022-03-20 117.86 0.00 \n",
"2022-03-20 69.87 -47.99 \n",
"2022-03-20 16.33 -53.54 \n",
"2022-03-20 0.00 -16.33 \n",
"2022-03-20 0.00 0.00 "
]
},
"execution_count": 162,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r['accounts']['acc01'].loc['2022-03-20']"
]
},
{
"cell_type": "code",
"execution_count": 163,
"id": "e3ec122b-e929-4a85-ac32-249362a15a2a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"after acc a1 all 101.53\n",
"after acc a1 0 47.83\n",
"after acc a1 0 ioi 0.16\n",
"after acc a1 1 53.01\n",
"after acc a1 1 ioi 0.53\n",
"after pay 0 a1 all 53.54\n",
"after pay 0 a1 0 0.00\n",
"after pay 0 a1 0 ioi 0.00\n",
"after pay 0 a1 1 53.01\n",
"after pay 0 a1 1 ioi 0.53\n",
"after pay 1 a1 all 0.00\n",
"after pay 1 a1 0 0.00\n",
"after pay 1 a1 1 0.00\n",
"Name: 2022-03-20, dtype: object"
]
},
"execution_count": 163,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from absbox import readInspect\n",
"\n",
"readInspect(r['result']).loc[\"2022-03-20\"]"
]
},
{
"cell_type": "code",
"execution_count": 71,
"id": "0100214d-5fe8-4c61-b726-f6efaaf3468b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" after acc a1 0 | \n",
" after acc a1 1 | \n",
" after acc a1 2 | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2021-07-26 | \n",
" 131.16 | \n",
" 131.16 | \n",
" 131.16 | \n",
"
\n",
" \n",
" | 2021-08-20 | \n",
" 136.90 | \n",
" 136.90 | \n",
" 136.90 | \n",
"
\n",
" \n",
" | 2021-09-20 | \n",
" 144.02 | \n",
" 144.02 | \n",
" 144.02 | \n",
"
\n",
" \n",
" | 2021-10-20 | \n",
" 150.92 | \n",
" 150.92 | \n",
" 150.92 | \n",
"
\n",
" \n",
" | 2021-11-20 | \n",
" 158.04 | \n",
" 158.04 | \n",
" 158.04 | \n",
"
\n",
" \n",
" | 2021-12-20 | \n",
" 164.94 | \n",
" 164.94 | \n",
" 164.94 | \n",
"
\n",
" \n",
" | 2022-01-20 | \n",
" 172.06 | \n",
" 172.06 | \n",
" 172.06 | \n",
"
\n",
" \n",
" | 2022-02-20 | \n",
" 179.18 | \n",
" 94.40 | \n",
" 94.40 | \n",
"
\n",
" \n",
" | 2022-03-20 | \n",
" 100.84 | \n",
" 53.17 | \n",
" 0.69 | \n",
"
\n",
" \n",
" | 2022-04-20 | \n",
" 7.81 | \n",
" 2.56 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-05-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-06-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-07-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-08-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-09-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-10-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-11-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2022-12-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-01-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-02-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-03-20 | \n",
" 6.44 | \n",
" 1.84 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-04-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-05-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-06-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-07-20 | \n",
" 6.90 | \n",
" 1.97 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-08-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
" | 2023-09-20 | \n",
" 7.12 | \n",
" 2.03 | \n",
" 0.00 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" after acc a1 0 after acc a1 1 after acc a1 2 \n",
"Date \n",
"2021-07-26 131.16 131.16 131.16\n",
"2021-08-20 136.90 136.90 136.90\n",
"2021-09-20 144.02 144.02 144.02\n",
"2021-10-20 150.92 150.92 150.92\n",
"2021-11-20 158.04 158.04 158.04\n",
"2021-12-20 164.94 164.94 164.94\n",
"2022-01-20 172.06 172.06 172.06\n",
"2022-02-20 179.18 94.40 94.40\n",
"2022-03-20 100.84 53.17 0.69\n",
"2022-04-20 7.81 2.56 0.00\n",
"2022-05-20 6.90 1.97 0.00\n",
"2022-06-20 7.12 2.03 0.00\n",
"2022-07-20 6.90 1.97 0.00\n",
"2022-08-20 7.12 2.03 0.00\n",
"2022-09-20 7.12 2.03 0.00\n",
"2022-10-20 6.90 1.97 0.00\n",
"2022-11-20 7.12 2.03 0.00\n",
"2022-12-20 6.90 1.97 0.00\n",
"2023-01-20 7.12 2.03 0.00\n",
"2023-02-20 7.12 2.03 0.00\n",
"2023-03-20 6.44 1.84 0.00\n",
"2023-04-20 7.12 2.03 0.00\n",
"2023-05-20 6.90 1.97 0.00\n",
"2023-06-20 7.12 2.03 0.00\n",
"2023-07-20 6.90 1.97 0.00\n",
"2023-08-20 7.12 2.03 0.00\n",
"2023-09-20 7.12 2.03 0.00"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"readInspect(r['result'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "43d0bc98-4af1-4a7a-b48c-11db8f521fb5",
"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.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}