{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### Pricing a single asset" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "m = [\"Mortgage\"\n", " ,{\"originBalance\": 12000.0\n", " ,\"originRate\": [\"fix\",0.045]\n", " ,\"originTerm\": 30\n", " ,\"freq\": \"Monthly\"\n", " ,\"type\": \"Level\"\n", " ,\"originDate\": \"2021-02-01\"}\n", " ,{\"currentBalance\": 10000.0\n", " ,\"currentRate\": 0.075\n", " ,\"remainTerm\": 20\n", " ,\"status\": \"Current\"}]" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> https://absbox.org/api/dev\n",
       "
\n" ], "text/plain": [ "Connecting engine server -> \u001b[4;94mhttps://absbox.org/api/dev\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
✅Connected, local lib:0.46.5, server:0.50.1\n",
       "
\n" ], "text/plain": [ "✅Connected, local li\u001b[1;92mb:0\u001b[0m.\u001b[1;36m46.5\u001b[0m, server:\u001b[1;36m0.50\u001b[0m.\u001b[1;36m1\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath\n", "\n", "localAPI = API(EnginePath.DEV,lang='english',check=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Pricing by balance" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "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", "
PricingWALDurationConvexityAccruedInterest
095002.95-1-1-1
\n", "
" ], "text/plain": [ " Pricing WAL Duration Convexity AccruedInterest\n", "0 9500 2.95 -1 -1 -1" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "### Pricing a single Mortgage\n", "\n", "r = localAPI.runAsset(\"2020-01-02\"\n", " ,[m]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Mortgage\", {\"CDR\":0.01}\n", " , None\n", " , {\"Rate\":0.3,\"Timing\":[0.5,0.25,0.25]}\n", " , None)\n", " ,None\n", " ,None)\n", " ,pricing=[\"Current|Defaulted\",0.95,0]\n", " ,read=True)\n", "r[1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Pricing by rate" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "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", "
PricingWALDurationConvexityAccruedInterest
010142.910.920.859649061.64
\n", "
" ], "text/plain": [ " Pricing WAL Duration Convexity AccruedInterest\n", "0 10142.91 0.92 0.859649 0 61.64" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = localAPI.runAsset(\"2021-12-01\"\n", " ,[m]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Mortgage\", {\"CDR\":0.01}\n", " , None\n", " , {\"Rate\":0.3,\"Timing\":[0.5,0.25,0.25]}\n", " , None)\n", " ,None\n", " ,None)\n", " ,pricing=[\"PvRate\",0.0525]\n", " ,read=True)\n", "r[1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Pricing by curve" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "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", "
PricingWALDurationConvexityAccruedInterest
09930.160.920.852143061.64
\n", "
" ], "text/plain": [ " Pricing WAL Duration Convexity AccruedInterest\n", "0 9930.16 0.92 0.852143 0 61.64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "\n", "\n", "r = localAPI.runAsset(\"2021-12-01\"\n", " ,[m]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Mortgage\", {\"CDR\":0.01}\n", " , None\n", " , {\"Rate\":0.3,\"Timing\":[0.5,0.25,0.25]}\n", " , None)\n", " ,None\n", " ,None)\n", " ,pricing=[\"PVCurve\",[[\"2021-12-01\",0.0525]\n", " ,[\"2022-12-01\",0.0825]]]\n", " ,read=True)\n", "r[1]" ] }, { "cell_type": "code", "execution_count": null, "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": 4 }