diff options
| -rw-r--r-- | python/position.py | 32 | ||||
| -rw-r--r-- | sql/serenitasdb.sql | 11 |
2 files changed, 42 insertions, 1 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 diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 1e49ed7b..9b3ded65 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -1256,7 +1256,7 @@ CREATE TYPE quote_firmness AS ENUM('FIRM', 'INDICATIVE'); CREATE TABLE markit_singlename_quotes (
quoteid int8 primary key,
redcode text,
- ticker text,
+ ticker text,
maturity date,
tenor text,
runningcoupon int,
@@ -1293,4 +1293,13 @@ CREATE TABLE hyg_option_quotes ( option_type option_type NOT NULL,
price float NOT NULL,
UNIQUE (date, expiry, strike, option_type)
+
+CREATE TYPE div_type AS ENUM ('Income');
+CREATE TABLE hyg_dvd_hist(
+ declared date,
+ ex date,
+ record date,
+ payable date PRIMARY KEY,
+ amount float,
+ dividend_type div_type
);
|
