diff options
Diffstat (limited to 'python/notebooks/Reto Report.ipynb')
| -rw-r--r-- | python/notebooks/Reto Report.ipynb | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/python/notebooks/Reto Report.ipynb b/python/notebooks/Reto Report.ipynb index f45b54ce..43bcc0e4 100644 --- a/python/notebooks/Reto Report.ipynb +++ b/python/notebooks/Reto Report.ipynb @@ -110,7 +110,8 @@ "outputs": [], "source": [ "#Calculate amount of stress for reports\n", - "df = get_index_quotes('HY', list(range(on_the_run('HY') - 10, on_the_run('HY') + 1)),\n", + "from analytics.curve_trades import on_the_run\n", + "df = get_index_quotes('HY', list(range(on_the_run('HY', spread_date) - 10, on_the_run('HY', spread_date) + 1)),\n", " tenor=['5yr'], years=5)\n", "df = df.xs('5yr', level='tenor')['close_spread'].groupby(['date', 'series']).last()\n", "\n", @@ -130,22 +131,15 @@ "outputs": [], "source": [ "#tranche positions\n", - "df_tranches = pd.read_sql_query(\"SELECT * from list_tranche_positions_by_strat(%s)\",\n", - " dawn_engine, params=(position_date,))\n", - "portf = Portfolio([DualCorrTranche(redcode=t.security_id, maturity=t.maturity,\n", - " notional=t.notional,\n", - " tranche_running=t.fixed_rate*100,\n", - " attach=t.orig_attach,\n", - " detach=t.orig_detach,\n", - " corr_attach=None, corr_detach=None) for t in df_tranches.itertuples()])\n", - "portf.trade_ids = [(strat, f\"{t.index_type} {t.series} {t.tenor} {t.attach}-{t.detach}\")\n", - " for t, strat in zip(portf.trades, df_tranches.folder)]\n", + "from risk.tranches import get_tranche_portfolio\n", + "conn = dawn_engine.raw_connection()\n", + "portf = get_tranche_portfolio(position_date, conn, by_strat=True)\n", "\n", "#swaption positions\n", "swaption_sql_string = (\"select id, folder, expiration_date from swaptions where expiration_date > %s \"\n", " \"AND swap_type = 'CD_INDEX_OPTION' \"\n", " \"AND trade_date <= %s AND termination_date IS NULL\")\n", - "conn = dawn_engine.raw_connection()\n", + "\n", "with conn.cursor() as c:\n", " c.execute(swaption_sql_string, (position_date, position_date))\n", " for trade_id, strat, expiration_date in c:\n", @@ -215,9 +209,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "results.to_clipboard(header=True)" - ] + "source": [] } ], "metadata": { |
