diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/exploration/index_arb.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/python/exploration/index_arb.py b/python/exploration/index_arb.py new file mode 100644 index 00000000..a77b083c --- /dev/null +++ b/python/exploration/index_arb.py @@ -0,0 +1,34 @@ +import datetime +import numpy as np +import pandas as pd +from analytics.basket_index import MarkitBasketIndex +from dates import bus_day +from utils.db import serenitas_engine + +ig31 = MarkitBasketIndex("IG", 31, ["5yr"]) + +dr = pd.bdate_range(datetime.date(2019, 1, 1), datetime.date(2019, 10, 8), freq=bus_day) +pvs = np.empty((125, len(dr))) +for i, d in enumerate(dr): + ig31.value_date = d + pv_vec = ig31.pv_vec()["2023-12-20"] + pvs[:, i] = pv_vec.protection_pv - pv_vec.duration * 0.01 +# these are the clean pvs +pvs = 1 - pvs +R = np.diff(pvs) / pvs[:, :-1] +Rf = pd.DataFrame(R.T, index=dr[1:], columns=ig31.tickers) +index_price = pd.read_sql_query( + "SELECT date, closeprice, modelprice " + "from index_quotes where index='IG' " + "and series=31 and tenor='5yr' ORDER BY date", + serenitas_engine, + parse_dates=["date"], + index_col=["date"], +) +model_price = index_price.loc["2019-01-02":, "modelprice"] +rf = model_price.pct_change() + +# def cost(w): +# return (Rf @ w - rf).var() + +# ABX = SingleNameCds("ABX", end_date=datetime.date(2023, 12, 20), value_date=datetime.date(2019, 1, 2)) |
