Skip to content

Commit

Permalink
update case
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed May 8, 2024
1 parent 6e433d5 commit 0daf541
Showing 1 changed file with 36 additions and 57 deletions.
93 changes: 36 additions & 57 deletions docs/source/nbsample/bond_pricing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
"cells": [
{
"cell_type": "markdown",
"id": "d21a6f4a",
"id": "9eb2e120",
"metadata": {},
"source": [
"### Bond Pricing"
]
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 48,
"id": "98488b88",
"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\">http://localhost:8081</span>\n",
"<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;35mhttp://localhost:8081\u001b[0m\n"
"\u001b[1;35mConnecting engine server -> \u001b[0m\u001b[1;4;35mhttps://absbox.org/api/dev\u001b[0m\n"
]
},
"metadata": {},
Expand All @@ -43,12 +43,12 @@
],
"source": [
"from absbox import API,EnginePath\n",
"localAPI = API(EnginePath.LOCAL,lang='english',check=False)"
"localAPI = API(EnginePath.DEV,lang='english',check=False)"
]
},
{
"cell_type": "markdown",
"id": "e66aff24",
"id": "f6b1e22e",
"metadata": {},
"source": [
"#### Setup Pricing Assumtpion\n",
Expand All @@ -68,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 49,
"id": "8e4760cc",
"metadata": {},
"outputs": [],
Expand All @@ -89,75 +89,54 @@
},
{
"cell_type": "markdown",
"id": "81203f75",
"id": "8520a8f6",
"metadata": {},
"source": [
"#### Access bond pricing"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "b103ecaa",
"execution_count": 50,
"id": "76cbb746",
"metadata": {},
"outputs": [],
"source": [
"if localAPI.server_info['_version']>'0.27.17':\n",
" print(r['pricing']['summary'])"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "31d5bb66",
"metadata": {},
"outputs": [],
"source": [
"if localAPI.server_info['_version']>'0.27.17':\n",
" print(r['pricing']['breakdown']['A1'])"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "1ef0ee62",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'summary': pricing face WAL duration convexity accure interest\n",
"A1 201.65 20.165 0.11 0.10 0.12 0\n",
"B 1291.17 129.117 0.54 0.51 1.09 0, 'breakdown': {'A1': balance interest principal rate cash factor memo\n",
"date \n",
"2021-10-20 200.61 1.15 0.00 0.07 1.15 0.20061 <PayInt:A1>\n",
"2021-10-20 84.68 0.00 115.93 0.00 115.93 0.08468 <PayPrin:A1>\n",
"2021-11-20 84.68 0.50 0.00 0.07 0.50 0.08468 <PayInt:A1>\n",
"2021-11-20 0.00 0.00 84.68 0.00 84.68 0.00000 <PayPrin:A1>, 'B': balance interest principal rate cash factor memo\n",
"date \n",
"2021-10-20 1000.00 0.00 0.00 0 0.00 1.00000 <PayPrin:B>\n",
"2021-10-20 1000.00 0.00 0.00 0 0.00 1.00000 <PayYield:B>\n",
"2021-11-20 968.20 0.00 31.80 0 31.80 0.96820 <PayPrin:B>\n",
"2021-11-20 968.20 0.00 0.00 0 0.00 0.96820 <PayYield:B>\n",
"2021-12-20 851.32 0.00 116.88 0 116.88 0.85132 <PayPrin:B>\n",
"2021-12-20 851.32 0.00 0.00 0 0.00 0.85132 <PayYield:B>\n",
"2022-01-20 734.54 0.00 116.78 0 116.78 0.73454 <PayPrin:B>\n",
"2022-01-20 734.54 0.00 0.00 0 0.00 0.73454 <PayYield:B>\n",
"2022-02-20 617.86 0.00 116.68 0 116.68 0.61786 <PayPrin:B>\n",
"2022-02-20 617.86 0.00 0.00 0 0.00 0.61786 <PayYield:B>\n",
"2022-03-20 501.27 0.00 116.59 0 116.59 0.50127 <PayPrin:B>\n",
"2022-03-20 501.27 0.00 0.00 0 0.00 0.50127 <PayYield:B>\n",
"2022-04-20 384.78 0.00 116.49 0 116.49 0.38478 <PayPrin:B>\n",
"2022-04-20 384.78 0.00 0.00 0 0.00 0.38478 <PayYield:B>\n",
"2022-05-20 268.38 0.00 116.40 0 116.40 0.26838 <PayPrin:B>\n",
"2022-05-20 268.38 0.00 0.00 0 0.00 0.26838 <PayYield:B>\n",
"2022-06-20 152.08 0.00 116.30 0 116.30 0.15208 <PayPrin:B>\n",
"2022-06-20 152.08 0.00 0.00 0 0.00 0.15208 <PayYield:B>\n",
"2022-07-20 35.87 0.00 116.21 0 116.21 0.03587 <PayPrin:B>\n",
"2022-07-20 35.87 0.00 0.00 0 0.00 0.03587 <PayYield:B>\n",
"2022-08-20 0.00 0.00 35.87 0 35.87 0.00000 <PayPrin:B>\n",
"2022-08-20 0.00 80.24 0.00 0 80.24 0.00000 <PayYield:B>\n",
"2022-09-20 0.00 116.01 0.00 0 116.01 0.00000 <PayYield:B>\n",
"2022-10-20 0.00 115.92 0.00 0 115.92 0.00000 <PayYield:B>}}\n"
" pricing face WAL duration convexity accure interest\n",
"A1 201.66 20.166 0.11 0.11 0.12 0\n",
"B 1291.18 129.118 0.54 0.52 1.09 0\n"
]
}
],
"source": [
"if localAPI.server_info['_version']>'0.27.17':\n",
" \n",
" print(r['pricing']['summary'])\n",
" print(r['pricing']['breakdown']['A1'])\n",
" \n",
"else:\n",
"if localAPI.server_info['_version']<='0.27.17':\n",
" print(r['pricing'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f6f93d8",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 0daf541

Please sign in to comment.