aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/notebooks/risk_sabo.ipynb48
1 files changed, 45 insertions, 3 deletions
diff --git a/python/notebooks/risk_sabo.ipynb b/python/notebooks/risk_sabo.ipynb
index 1ee43fdb..dda7b7b7 100644
--- a/python/notebooks/risk_sabo.ipynb
+++ b/python/notebooks/risk_sabo.ipynb
@@ -3,7 +3,11 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
"import datetime\n",
@@ -87,14 +91,52 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "from analytics.index_data import load_all_curves\n",
+ "from utils.db import serenitas_pool\n",
+ "conn = serenitas_pool.getconn()\n",
+ "surv_curves = load_all_curves(conn, spread_date)\n",
+ "serenitas_pool.putconn(conn)\n",
+ "surv_prob = pd.concat([surv_curves['curve'].apply(lambda sc: sc.survival_probability(d)) for d in jtd.columns.date], axis=1, keys=jtd.columns)\n",
+ "surv_prob = surv_prob.loc[jtd.index]"
+ ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "jtd = (1-surv_prob) * jtd\n",
+ "jtd = jtd.groupby(jtd.index.str.extract(\"([^_]*)\", expand=False)).sum()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "jtd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ref_names = surv_curves.groupby(surv_curves.index.str.extract(\"([^_]*)\", expand=False))['name'].first()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ref_names[jtd.index]"
+ ]
},
{
"cell_type": "code",