diff options
Diffstat (limited to 'python/notebooks/bespokes/zero_recovery_EUXO.ipynb')
| -rw-r--r-- | python/notebooks/bespokes/zero_recovery_EUXO.ipynb | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/python/notebooks/bespokes/zero_recovery_EUXO.ipynb b/python/notebooks/bespokes/zero_recovery_EUXO.ipynb new file mode 100644 index 00000000..3b3204f1 --- /dev/null +++ b/python/notebooks/bespokes/zero_recovery_EUXO.ipynb @@ -0,0 +1,154 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from analytics.tranche_basket import DualCorrTranche, TrancheBasket\n", + "from pandas.tseries.offsets import BDay\n", + "\n", + "import scipy.interpolate as intp\n", + "import numpy as np\n", + "import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "index = 'EU'\n", + "series = 30\n", + "value_date=datetime.date.today() - BDay(1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx = TrancheBasket(index, series, \"5yr\", value_date=value_date)\n", + "idx.tweak()\n", + "idx.build_skew()\n", + "a,b, bond_prices =idx.tranche_pvs()\n", + "bond_prices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx.tranche_spreads()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "a,b, bond_prices = idx.tranche_pvs(zero_recovery=True)\n", + "bond_prices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx.tranche_spreads(zero_recovery=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#map rho to the new expected loss\n", + "idx_zero_loss = idx.expected_loss()/(1-idx.recovery_rates.mean())\n", + "exp_loss = np.zeros(1)\n", + "for k in idx.K[1:]:\n", + " exp_loss = np.append(exp_loss, idx.expected_loss_trunc(k))\n", + "moneyness = np.divide(idx.K, exp_loss)\n", + "zero_moneyness = np.divide(idx.K, exp_loss/(1-idx.recovery_rates.mean()))\n", + "extrapolate = intp.interp1d(moneyness[1:4], idx.rho[1:4], fill_value='extrapolate')\n", + "idx.rho[1:4] = extrapolate(zero_moneyness[1:4])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "a,b, bond_prices = idx.tranche_pvs(zero_recovery=True)\n", + "bond_prices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx.tranche_spreads(zero_recovery=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#top down - to price SS\n", + "idx.build_skew(skew_type='topdown')\n", + "extrapolate = intp.interp1d(moneyness[1:4], idx.rho[1:4], fill_value='extrapolate')\n", + "idx.rho[1:4] = extrapolate(zero_moneyness[1:4])\n", + "idx.tranche_spreads(zero_recovery=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "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.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} |
