{ "cells": [ { "cell_type": "markdown", "id": "723dea80-1f1f-4da3-b600-aa9588446e7d", "metadata": {}, "source": [ "### First Loss Example" ] }, { "cell_type": "markdown", "id": "6a5c410a", "metadata": {}, "source": [ "#### Init" ] }, { "cell_type": "code", "execution_count": 9, "id": "a791a17b", "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.7, server:0.42.4\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.7\u001b[0m\u001b[1;32m, server:\u001b[0m\u001b[1;32m0.42\u001b[0m\u001b[1;32m.\u001b[0m\u001b[1;32m4\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import examples,API,EnginePath\n", "\n", "localAPI = API(EnginePath.DEV, lang='english', check=False)" ] }, { "cell_type": "markdown", "id": "af9dedfe", "metadata": {}, "source": [ "#### Run Input\n", "\n", "Using endpoint ``runRootFinder()``\n", "\n", "Start with a tuple with :\n", "* \"firstLoss\"\n", "* deal object\n", "* performance assumption\n", "* run assumption\n", "* bond name" ] }, { "cell_type": "code", "execution_count": null, "id": "e03297f6", "metadata": {}, "outputs": [], "source": [ "r0 = localAPI.runRootFinder(\n", " examples.test01\n", " ,(\"Pool\",(\"Mortgage\",{\"CDRPadding\":[0.01,0.02]},{\"CPR\":0.02},{\"Rate\":0.1,\"Lag\":5},None)\n", " ,None\n", " ,None)\n", " ,[]\n", " ,(\"firstLoss\", \"A1\")\n", " )" ] }, { "cell_type": "markdown", "id": "2b73c5d2-2f27-4c48-8a02-c4a8734c50e6", "metadata": {}, "source": [ "#### Result\n", "\n", "The first element in the ``r0`` is the factor which will cause first 0.01 loss on the bond" ] }, { "cell_type": "code", "execution_count": null, "id": "c5af85e6-07ea-49bf-bd99-960c0e2c7113", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "38.68723442313214" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r0[0]" ] }, { "cell_type": "markdown", "id": "8159eec0-8cfc-483a-95b6-525b1027a45b", "metadata": {}, "source": [ "The second element in the ``r0`` is \n", "* the deal\n", "* the stressed performance assumption used\n", "* the run assumption used" ] }, { "cell_type": "code", "execution_count": null, "id": "3163b313", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'tag': 'PoolLevel',\n", " 'contents': [{'tag': 'MortgageAssump',\n", " 'contents': [{'tag': 'DefaultVecPadding',\n", " 'contents': [{'numerator': 1361186051031351,\n", " 'denominator': 3518437208883200},\n", " {'numerator': 1361186051031351, 'denominator': 1759218604441600}]},\n", " {'tag': 'PrepaymentCPR', 'contents': {'numerator': 1, 'denominator': 50}},\n", " {'tag': 'Recovery', 'contents': [{'numerator': 1, 'denominator': 10}, 5]},\n", " None]},\n", " [],\n", " {'tag': 'DummyDefaultAssump'}]}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r0[1]" ] } ], "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.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }