aboutsummaryrefslogtreecommitdiffstats
path: root/python/notebooks/Curve Trades.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'python/notebooks/Curve Trades.ipynb')
-rw-r--r--python/notebooks/Curve Trades.ipynb208
1 files changed, 3 insertions, 205 deletions
diff --git a/python/notebooks/Curve Trades.ipynb b/python/notebooks/Curve Trades.ipynb
index d749c74a..159e695d 100644
--- a/python/notebooks/Curve Trades.ipynb
+++ b/python/notebooks/Curve Trades.ipynb
@@ -54,8 +54,8 @@
"metadata": {},
"outputs": [],
"source": [
- "index = w.value\n",
- "series = 34 if index == 'IG' else 32\n",
+ "index = 'IG'\n",
+ "series = 34 if index == 'IG' else 33\n",
"model = ct.curve_model('5yr', '10yr', index=index, max_series=series)\n",
"model_results = ct.curve_model_results(model[0], model[1])"
]
@@ -85,38 +85,6 @@
"metadata": {},
"outputs": [],
"source": [
- "#HY curve trade re-ref calculator - sell protection index_1, buy protection index_2 \n",
- "date = datetime.date.today()\n",
- "index_type = 'HY'\n",
- "series_1 = '29'\n",
- "series_2 = '34'\n",
- "index_1_trade_price = 104.75\n",
- "index_2_trade_price = 104.8\n",
- "reref_2 = 104.71\n",
- "\n",
- "#-----------------------------\n",
- "index_1 = CreditIndex(index_type, series_1, '5yr', date)\n",
- "index_2 = CreditIndex(index_type, series_2, '5yr', date)\n",
- "index_1.price = index_1_trade_price\n",
- "index_2.price = index_2_trade_price\n",
- "index_2.notional = index_1.notional * index_1.risky_annuity/index_2.risky_annuity\n",
- "index_1.direction = 'Seller'\n",
- "index_2.direction = 'Buyer'\n",
- "past_pv = index_2.pv\n",
- "index_2.price = reref_2 \n",
- "index_1.pv = -index_1.pv + (index_2.pv - past_pv)\n",
- " \n",
- "pd.options.display.float_format = '{:,.4f}'.format\n",
- "d = {index_type + series_1: [index_1_trade_price, index_1.price , index_1.notional], index_type + series_2: [index_2_trade_price, reref_2, index_2.notional]}\n",
- "pd.DataFrame(d, index=['original ref', 're-ref', 'notionals'])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
"#On the run spread differences\n",
"spreads_diff = curve_spread_diff(index, 6)\n",
"spreads_diff.plot()"
@@ -286,53 +254,6 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#Do the same regression for Itrxx\n",
- "model = ct.curve_model('5yr', '10yr', index='EU')\n",
- "model_results = ct.curve_model_results(model[0], model[1])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "model_results['diff'] = model_results['predicted'] - model_results['close_spread']\n",
- "model_results"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "df = ct.forward_spread(report_date, index)\n",
- "df.plot()\n",
- "plt.ylabel('spread')\n",
- "plt.xlabel('forward spread start date')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
"source": [
"df = ct.spot_forward(index)\n",
"df = df.rename(columns={'1yr': 'Spot Spread - 1 Year Forward', 'current': 'Spot Spread - Today'})\n",
@@ -368,19 +289,6 @@
"metadata": {},
"outputs": [],
"source": [
- "#plot steepness scenario at current spread\n",
- "#df_plot = df.set_index(['spread', 'curve_per'], append=True)\n",
- "#df_plot = df_plot.xs(round(spread_df.iloc[0][0], 2), level = 'spread')\n",
- "#df_plot.name = 'pnl'\n",
- "#g.plot_color_map(df_plot, spread_range)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
"#Plot the shape of the scenario that was run above\n",
"ct.plot_curve_shape(report_date)"
]
@@ -450,116 +358,6 @@
"scen_table.pnl = scen_table.pnl/navs.iloc[-1].endbooknav *100\n",
"scen_table.pivot(index='tighter', columns='wider')"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from exploration.VaR import hist_var\n",
- "IG = ct.curve_pos(report_date, 'IG')\n",
- "ITRX = ct.curve_pos(report_date, 'EU')\n",
- "VaR = hist_var(IG, 'IG') + hist_var(ITRX, 'EU')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
@@ -578,7 +376,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.1"
+ "version": "3.8.5"
}
},
"nbformat": 4,