{ "cells": [ { "cell_type": "markdown", "id": "9eb2e120", "metadata": {}, "source": [ "### Bond Pricing" ] }, { "cell_type": "code", "execution_count": 48, "id": "98488b88", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> https://absbox.org/api/dev\n",
       "
\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": [ "
Connected, local lib:0.26.4, server:0.27.17\n",
       "
\n" ], "text/plain": [ "✅\u001b[1;32mConnected, local li\u001b[0m\u001b[1;32mb:0\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m26.4\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.27\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m17\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath\n", "localAPI = API(EnginePath.DEV,lang='english',check=False)" ] }, { "cell_type": "markdown", "id": "f6b1e22e", "metadata": {}, "source": [ "#### Setup Pricing Assumtpion\n", "\n", "`syntax`\n", "\n", "\n", " {\n", " \"date\":\n", " ,\"curve\":\n", " }\n", " \n", " \n", " * `` : the day all bond cashflow will discount back to \n", " * `` : the rate to be used to PV calculation. if cashflow falls in the middle , it will use the rates proprotionally" ] }, { "cell_type": "code", "execution_count": 49, "id": "8e4760cc", "metadata": {}, "outputs": [], "source": [ "from absbox.examples import test01\n", "\n", "r = localAPI.run(test01\n", " ,poolAssump = (\"Pool\",(\"Mortgage\",{\"CDR\":0.01},None,None,None)\n", " ,None\n", " ,None)\n", " ,runAssump = [(\"pricing\"\n", " ,{\"date\":\"2021-09-20\"\n", " ,\"curve\":[[\"2021-01-01\",0.025]\n", " ,[\"2024-08-01\",0.025]]})]\n", " ,read=True\n", " ,showWarning=False)" ] }, { "cell_type": "markdown", "id": "8520a8f6", "metadata": {}, "source": [ "#### Access bond pricing" ] }, { "cell_type": "code", "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": [ " 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", " print(r['pricing'])" ] } ], "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.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }