{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import portfolio_var as port\n", "from analytics import Swaption, BlackSwaption, Index, VolatilitySurface, Portfolio\n", "from analytics.scenarios import run_swaption_scenarios, run_index_scenarios, run_portfolio_scenarios\n", "import datetime\n", "import pandas as pd\n", "from pandas.tseries.offsets import BDay, BMonthEnd\n", "\n", "#import exploration.swaption_calendar_spread as spread\n", "import exploration.swaption_calendar_spread as spread" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#Oct ME Bond HY Equiv\n", "report_date = (datetime.date.today() + BMonthEnd(-1)).date()\n", "bond_HY_equiv = -.12088\n", "percentile = .95" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#The 95%tile \n", "df, spread, dur = port.rel_spread_diff(report_date)\n", "stress = pd.DataFrame()\n", "stress.at[('2SD_widen', 'spread')] = df.quantile(.975) \n", "stress.at[('2SD_tighten', 'spread')] = df.quantile(.025) \n", "stress.at[('worst_widen', 'spread')] = df.max()\n", "stress['pts'] = -stress * spread * dur/100\n", "stress['nav_impact'] = bond_HY_equiv * stress['pts']" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
spreadptsnav_impact
2SD_widen0.157884-2.2080360.266907
2SD_tighten-0.1634802.286301-0.276368
worst_widen0.359386-5.0260820.607553
\n", "
" ], "text/plain": [ " spread pts nav_impact\n", "2SD_widen 0.157884 -2.208036 0.266907\n", "2SD_tighten -0.163480 2.286301 -0.276368\n", "worst_widen 0.359386 -5.026082 0.607553" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stress" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
level_1notionalfactorcoupondurationthetapriceclosespreadclean_navaccruedonTR_notionalwidentightentotal
strategy
HEDGE_MBS3-30500000.02.920.159.5795860.091530323.911577728.775311-2.454496e+06-173891.666667-2.271120e+07-392951.746260439165.979817439165.979817
SER_IGCURVE1-11000000.02.000.024.2029550.005495203.16606338.112262-2.220374e+04-12833.3333331.006705e+063787.727425-3681.2184673787.727425
SER_ITRXCURVE139300000.02.000.0214.6382350.021951203.615045138.5901582.027082e+0653396.910000-3.481913e+06-15658.88272216533.67451916533.674519
\n", "
" ], "text/plain": [ " level_1 notional factor coupon duration theta \\\n", "strategy \n", "HEDGE_MBS 3 -30500000.0 2.92 0.15 9.579586 0.091530 \n", "SER_IGCURVE 1 -11000000.0 2.00 0.02 4.202955 0.005495 \n", "SER_ITRXCURVE 1 39300000.0 2.00 0.02 14.638235 0.021951 \n", "\n", " price closespread clean_nav accrued \\\n", "strategy \n", "HEDGE_MBS 323.911577 728.775311 -2.454496e+06 -173891.666667 \n", "SER_IGCURVE 203.166063 38.112262 -2.220374e+04 -12833.333333 \n", "SER_ITRXCURVE 203.615045 138.590158 2.027082e+06 53396.910000 \n", "\n", " onTR_notional widen tighten total \n", "strategy \n", "HEDGE_MBS -2.271120e+07 -392951.746260 439165.979817 439165.979817 \n", "SER_IGCURVE 1.006705e+06 3787.727425 -3681.218467 3787.727425 \n", "SER_ITRXCURVE -3.481913e+06 -15658.882722 16533.674519 16533.674519 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "port.cleared_cds_margins(report_date, percentile)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120816.55576340854" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "port.index_curve_margins(report_date)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }