aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/notebooks/swaption_risk.ipynb88
1 files changed, 69 insertions, 19 deletions
diff --git a/python/notebooks/swaption_risk.ipynb b/python/notebooks/swaption_risk.ipynb
index ac08aa53..6b42cff1 100644
--- a/python/notebooks/swaption_risk.ipynb
+++ b/python/notebooks/swaption_risk.ipynb
@@ -3,18 +3,59 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
"# better formatting for large floats\n",
"import pandas as pd\n",
- "pd.options.display.float_format = \"{:,.2f}\".format"
+ "pd.options.display.float_format = \"{:,.2f}\".format\n",
+ "from ipywidgets import widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "w = widgets.Dropdown(\n",
+ " options=['BOWDST', 'SERCGMAST'],\n",
+ " value='SERCGMAST',\n",
+ " description='fund',\n",
+ " disabled=False,\n",
+ ")\n",
+ "w"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "fund = w.value"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
"from risk.swaptions import get_swaption_portfolio\n",
@@ -31,17 +72,25 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
- "portf = get_swaption_portfolio(value_date, conn, source_list=[\"MS\"])\n",
+ "portf = get_swaption_portfolio(value_date, conn, source_list=[\"MS\"], fund=fund)\n",
"portf"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
"df = portf._todf()\n",
@@ -54,18 +103,26 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
- "hedges = pd.read_sql_query(\"SELECT security_desc, notional FROM list_cds_positions_by_strat(%s) \"\n",
+ "hedges = pd.read_sql_query(\"SELECT security_desc, notional FROM list_cds_positions_by_strat(%s, %s) \"\n",
" \"WHERE folder in ('IGOPTDEL', 'HYOPTDEL')\",\n",
- " conn, params=(value_date,))"
+ " conn, params=(value_date, fund))"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
"outputs": [],
"source": [
"def f(s):\n",
@@ -86,13 +143,6 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
"source": [
"portf.theta"
]
@@ -104,7 +154,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
- "sr = np.linspace(47, 51, 100)\n",
+ "sr = np.linspace(65, 80, 100)\n",
"rec= []\n",
"for s in sr:\n",
" delta = 0.\n",
@@ -117,7 +167,7 @@
" rec.append((s, gamma, delta))\n",
"df = pd.DataFrame.from_records(rec, columns=['spread', 'gamma', 'delta'])\n",
"df = df.set_index('spread')\n",
- "df.delta += risk.loc['IG33 5yr', 'current hedge']"
+ "df.delta += risk.loc['IG34 5yr', 'current hedge']"
]
},
{