{ "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", " \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", " \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", "
balanceinterestprincipalratecashintDueintOverIntfactormemo
date
2022-02-20120087.8600.0787.8643.2301.0<PayInt:A1>
2022-03-201200101.5300.07101.530.0001.0[<PayInt:A1>, <PayInt:A1>]
2022-04-2012007.1200.077.120.0001.0[<PayInt:A1>, <PayInt:A1>]
\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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
balancechangememo
date
2022-03-20117.860.00<SeqPayFee:trusteeFee>
2022-03-2069.87-47.99<PayInt:A1>
2022-03-2016.33-53.54<PayInt:A1>
2022-03-200.00-16.33<PayPrin:B>
2022-03-200.000.00<PayYield:B>
\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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
after acc a1 0after acc a1 1after acc a1 2
Date
2021-07-26131.16131.16131.16
2021-08-20136.90136.90136.90
2021-09-20144.02144.02144.02
2021-10-20150.92150.92150.92
2021-11-20158.04158.04158.04
2021-12-20164.94164.94164.94
2022-01-20172.06172.06172.06
2022-02-20179.1894.4094.40
2022-03-20100.8453.170.69
2022-04-207.812.560.00
2022-05-206.901.970.00
2022-06-207.122.030.00
2022-07-206.901.970.00
2022-08-207.122.030.00
2022-09-207.122.030.00
2022-10-206.901.970.00
2022-11-207.122.030.00
2022-12-206.901.970.00
2023-01-207.122.030.00
2023-02-207.122.030.00
2023-03-206.441.840.00
2023-04-207.122.030.00
2023-05-206.901.970.00
2023-06-207.122.030.00
2023-07-206.901.970.00
2023-08-207.122.030.00
2023-09-207.122.030.00
\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 }