diff options
Diffstat (limited to 'python/position.py')
| -rw-r--r-- | python/position.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/python/position.py b/python/position.py index c88e030c..51280765 100644 --- a/python/position.py +++ b/python/position.py @@ -391,6 +391,22 @@ def populate_cashflow_history(conn, session, workdate=None, funds=("SERCGMAST",) conn.commit() +def update_iboxhy(conn, session, start_date: datetime.date = None): + d = retrieve_data( + session, + ["IBOXHY Index"], + fields=["PX_LAST", "CONTRBTD_ZSPREAD"], + start_date=start_date, + ) + df = d["IBOXHY Index"] + with conn.cursor() as c: + c.executemany( + "INSERT INTO iboxhy_data VALUES (%s, %s, %s)", + df.itertuples(index=True), + ) + conn.commit() + + def update_hyg_vol(conn, session, start_date: datetime.date = None): d = retrieve_data( session, @@ -461,6 +477,21 @@ def update_hyg_option_quotes(conn, session, start_date: datetime.date = None): "ON CONFLICT DO NOTHING", [(d, exp, s, t, val) for d, val in df.items()], ) + + +def update_hyg_dvd(conn, session): + d = retrieve_data( + session, + ["HYG US Equity"], + fields=["DVD_HIST_ALL"], + ) + data = d["HYG US Equity"]["DVD_HIST_ALL"] + del data["Dividend Frequency"] + with conn.cursor() as c: + c.executemany( + "INSERT INTO hyg_dvd_hist VALUES (%s, %s, %s, %s, %s, %s)", + data.itertuples(index=False), + ) conn.commit() @@ -498,6 +529,7 @@ if __name__ == "__main__": update_cash_rates(serenitas_conn, session, prev_business_day(workdate)) update_hyg_option_quotes(serenitas_conn, session, workdate) update_hyg_vol(serenitas_conn, session, workdate) + # update_hyg_dvd(serenitas_conn, session) for vol_type in ["N", "V", "N_OIS"]: update_swaption_vol( serenitas_conn, session, start_from=workdate, vol_type=vol_type |
