aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/notebooks/Curve Trades.ipynb94
1 files changed, 66 insertions, 28 deletions
diff --git a/python/notebooks/Curve Trades.ipynb b/python/notebooks/Curve Trades.ipynb
index 1695b412..14868886 100644
--- a/python/notebooks/Curve Trades.ipynb
+++ b/python/notebooks/Curve Trades.ipynb
@@ -12,12 +12,15 @@
"import graphics as g\n",
"import globeop_reports as go\n",
"import analytics.curve_trades as ct\n",
+ "import datetime\n",
"\n",
"from ipywidgets import widgets\n",
+ "from pandas.tseries.offsets import BDay\n",
"from analytics.scenarios import run_curve_scenarios\n",
"from analytics.curve_trades import curve_spread_diff, spreads_diff_table, theta_matrix_by_series\n",
"from scipy.optimize import brentq\n",
- "from utils.db import dbengine"
+ "from utils.db import dbengine\n",
+ "from analytics import CreditIndex"
]
},
{
@@ -42,7 +45,66 @@
"outputs": [],
"source": [
"index = w.value\n",
- "report_date = (pd.datetime.today() - pd.offsets.BDay(1)).date()"
+ "report_date = (datetime.date.today() - BDay(1)).date()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "index = w.value\n",
+ "model = ct.curve_model('5yr', '10yr', index=index, max_series=33)\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": [
+ "model[1].summary()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#HY curve trade re-ref calculator - sell protection index_1, buy protection index_2.\n",
+ "index_type = 'HY'\n",
+ "series_1 = '31'\n",
+ "series_2 = '34'\n",
+ "index_1 = CreditIndex(index_type, series_1, '5yr', datetime.date.today())\n",
+ "index_2 = CreditIndex(index_type, series_2, '5yr')\n",
+ "index_1.price = 100.75\n",
+ "index_2.price = 100.25\n",
+ "reref_2 = 99.75\n",
+ "\n",
+ "before = index_1.price - index_2.price\n",
+ "index_2.notional = index_1.notional * index_1.DV01/index_2.DV01\n",
+ "#index_1.notional = 50e6\n",
+ "#index_2.notional = 35.2e6\n",
+ "index_1.direction = 'Seller'\n",
+ "index_2.direction = 'Buyer'\n",
+ "past_pv = index_2.pv\n",
+ "index_2.price = reref_2 \n",
+ "toset = index_1.pv - (index_2.pv - past_pv)\n",
+ "index_1.pv = -toset\n",
+ "{'before': (index_1.notional, before), 're_refed': (index_2.notional, index_1.price - index_2.price)}"
]
},
{
@@ -220,38 +282,14 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": [
- "model = ct.curve_model('5yr', '10yr', index='IG', max_series=33)\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": [
- "model_results.iloc[-1]"
- ]
+ "source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": [
- "model[1].summary()"
- ]
+ "source": []
},
{
"cell_type": "code",