Skip to content

Commit

Permalink
add loan nb
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Apr 13, 2024
1 parent bd4039a commit 0f47553
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/source/nbsample/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Notebook Samples
.. toctree::
:maxdepth: 1

single_invoice
single_invoice
single_loan
178 changes: 178 additions & 0 deletions docs/source/nbsample/single_loan.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Loan"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<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 -&gt; </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold; text-decoration: underline\">https://absbox.org/api/dev</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1;35mConnecting engine server -> \u001b[0m\u001b[1;4;35mhttps://absbox.org/api/dev\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<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\">26.6</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.26</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">.</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">5</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1;32mConnected, local li\u001b[0m\u001b[1;32mb:0\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m26.6\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.26\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m5\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from absbox import API\n",
"\n",
"localAPI = API(\"https://absbox.org/api/dev\",lang='english',check=False)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"loan1 = [\"Loan\"\n",
" ,{\"originBalance\": 80000\n",
" ,\"originRate\": [\"floater\",0.045,{\"index\":\"SOFR3M\"\n",
" ,\"spread\":0.01\n",
" ,\"reset\":\"QuarterEnd\"}]\n",
" ,\"originTerm\": 24\n",
" ,\"freq\": \"Monthly\"\n",
" ,\"type\": \"i_p\"\n",
" ,\"originDate\": \"2021-03-01\"}\n",
" ,{\"currentBalance\": 65000\n",
" ,\"currentRate\": 0.06\n",
" ,\"remainTerm\": 12\n",
" ,\"status\": \"Current\"}]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[('2022-03-01', 65000, 0, 0., 0, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0),\n",
" ('2022-04-01', 65000, 0, 331.23, 0, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0),\n",
" ('2022-05-01', 65000, 0, 320.54, 0, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0),\n",
" ('2022-06-01', 65000, 0, 331.23, 0, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0),\n",
" ('2022-07-01', 65000, 0, 267.12, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2022-08-01', 65000, 0, 276.02, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2022-09-01', 65000, 0, 276.02, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2022-10-01', 65000, 0, 267.12, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2022-11-01', 65000, 0, 276.02, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2022-12-01', 65000, 0, 267.12, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2023-01-01', 65000, 0, 276.02, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2023-02-01', 65000, 0, 276.02, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0),\n",
" ('2023-03-01', 0, 65000, 249.31, 0, 0, 0, 0, 0.05, 65000, 0, 0, 0, 0, 0)]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r = localAPI.runAsset(\"2020-01-02\"\n",
" ,[loan1]\n",
" ,poolAssump=(\"Pool\",(\"Loan\",None,None,None,None)\n",
" ,None\n",
" ,None)\n",
" ,rateAssump=[(\"SOFR3M\",0.04)]\n",
" ,read=True)\n",
"\n",
"list(r[0].to_records())"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[('2022-03-01', 65000., 0., 0., 0, 0., 0, 0., 0.06, 0., 0, 0, 0., 0, 0.),\n",
" ('2022-04-01', 64944.55, 0., 330.95, 0, 55.45, 0, 55.45, 0.06, 0., 0, 0, 55.45, 0, 55.45),\n",
" ('2022-05-01', 64890.93, 0., 320.01, 0, 53.62, 0, 53.62, 0.06, 0., 0, 0, 109.07, 0, 109.07),\n",
" ('2022-06-01', 64835.57, 0., 330.39, 0, 55.36, 0, 55.36, 0.06, 0., 0, 0, 164.43, 0, 164.43),\n",
" ('2022-07-01', 64782.04, 0., 266.22, 0, 53.53, 0, 53.53, 0.05, 0., 0, 0, 217.96, 0, 217.96),\n",
" ('2022-08-01', 64726.77, 0., 274.86, 0, 55.27, 0, 55.27, 0.05, 0., 0, 0, 273.23, 0, 273.23),\n",
" ('2022-09-01', 64671.55, 0., 274.63, 0, 55.22, 0, 55.22, 0.05, 0., 0, 0, 328.45, 0, 328.45),\n",
" ('2022-10-01', 64618.15, 0., 265.55, 0, 53.4, 0, 53.4, 0.05, 0., 0, 0, 381.85, 0, 381.85),\n",
" ('2022-11-01', 64563.02, 0., 274.17, 0, 55.13, 0, 55.13, 0.05, 0., 0, 0, 436.98, 0, 436.98),\n",
" ('2022-12-01', 64509.71, 0., 265.1, 0, 53.31, 0, 53.31, 0.05, 0., 0, 0, 490.29, 0, 490.29),\n",
" ('2023-01-01', 64454.67, 0., 273.71, 0, 55.04, 0, 55.04, 0.05, 0., 0, 0, 545.33, 0, 545.33),\n",
" ('2023-02-01', 64399.68, 0., 273.47, 0, 54.99, 0, 54.99, 0.05, 0., 0, 0, 600.32, 0, 600.32),\n",
" ('2023-03-01', 0., 64350.05, 246.82, 0, 49.63, 0, 49.63, 0.05, 64350.05, 0, 0, 649.95, 0, 649.95)]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r = localAPI.runAsset(\"2020-01-02\"\n",
" ,[loan1]\n",
" ,poolAssump=(\"Pool\",(\"Loan\",{\"CDR\":0.01},None,None,None)\n",
" ,None\n",
" ,None)\n",
" ,rateAssump=[(\"SOFR3M\",0.04)]\n",
" ,read=True)\n",
"\n",
"list(r[0].to_records())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 0f47553

Please sign in to comment.