aboutsummaryrefslogtreecommitdiffstats
path: root/python/notebooks/Single Names Monitoring.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'python/notebooks/Single Names Monitoring.ipynb')
-rw-r--r--python/notebooks/Single Names Monitoring.ipynb32
1 files changed, 13 insertions, 19 deletions
diff --git a/python/notebooks/Single Names Monitoring.ipynb b/python/notebooks/Single Names Monitoring.ipynb
index 0c32e617..62a1383a 100644
--- a/python/notebooks/Single Names Monitoring.ipynb
+++ b/python/notebooks/Single Names Monitoring.ipynb
@@ -23,7 +23,7 @@
"outputs": [],
"source": [
"w = widgets.Dropdown(\n",
- " options=['IG', 'HY', 'EU'],\n",
+ " options=['IG', 'HY', 'EU', 'XO'],\n",
" value='IG',\n",
" description='Index:',\n",
" disabled=False,\n",
@@ -37,7 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
- "w_1 = widgets.IntSlider(value=30, min=22, max=30, description = 'Series')\n",
+ "w_1 = widgets.IntSlider(value=31, min=22, max=31, description = 'Series')\n",
"w_1"
]
},
@@ -47,7 +47,7 @@
"metadata": {},
"outputs": [],
"source": [
- "trade_date = (pd.datetime.today() - pd.offsets.BDay(1)).date()\n",
+ "value_date = (pd.datetime.today() - pd.offsets.BDay(2)).date()\n",
"index_type = w.value\n",
"series = w_1.value"
]
@@ -59,8 +59,8 @@
"outputs": [],
"source": [
"sql_string = \"select * from index_members(%s, %s)\"\n",
- "df = pd.read_sql_query(sql_string, engine, params=(index_type + str(series), trade_date), index_col=['markit_ticker'])\n",
- "df1 = pd.read_sql_query(sql_string, engine, params=(index_type + str(series-1), trade_date), index_col=['markit_ticker'])"
+ "df = pd.read_sql_query(sql_string, engine, params=(index_type + str(series), value_date), index_col=['markit_ticker'])\n",
+ "df1 = pd.read_sql_query(sql_string, engine, params=(index_type + str(series-2), value_date), index_col=['markit_ticker'])"
]
},
{
@@ -89,7 +89,7 @@
"metadata": {},
"outputs": [],
"source": [
- "date_range = pd.bdate_range(trade_date - 52 * pd.offsets.Week(), trade_date, freq='5B')\n",
+ "date_range = pd.bdate_range(value_date - 52 * pd.offsets.Week(), value_date, freq='5B')\n",
"index = MarkitBasketIndex(index_type, series, ['5yr'])\n",
"default_prob = {}\n",
"maturity = np.array([np.datetime64(index.maturities[0]).view('int') + 134774])\n",
@@ -107,10 +107,13 @@
"outputs": [],
"source": [
"#Top 20 highest cumulative\n",
- "top20 = default_prob.unstack(-1)[default_prob[trade_date].nlargest(20).index]\n",
+ "top20 = default_prob.unstack(-1)[default_prob[value_date].nlargest(20).index]\n",
"top20.index.name='date'\n",
"top20.columns.name='tickers'\n",
- "top20.plot(title=f'market implied default probabilities to {index.maturities[0]}')"
+ "ax = top20.plot(title=f'market implied default probabilities to {index.maturities[0]}', figsize=(10,6))\n",
+ "ax.legend(loc='upper center', bbox_to_anchor=(1.3, 1), ncol=1)\n",
+ "ax.set(xlabel='date', ylabel='probability')\n",
+ "plt.tight_layout()"
]
},
{
@@ -118,16 +121,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": [
- "title = 'market implied default probabilities to ' + str(temp.maturities[0])\n",
- "fig, ax = plt.subplots()\n",
- "ax.plot(dp_top.T)\n",
- "ax.set(xlabel='date', ylabel='probability',\n",
- " title=title)\n",
- "ax.legend(dp_top.index, loc='upper center', bbox_to_anchor=(1.3, 1), ncol=1)\n",
- "fig.set_size_inches(10, 6)\n",
- "fig.tight_layout()"
- ]
+ "source": []
}
],
"metadata": {
@@ -146,7 +140,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.5"
+ "version": "3.7.0"
}
},
"nbformat": 4,