diff options
| -rw-r--r-- | python/position.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/python/position.py b/python/position.py index add0c91e..2f7a1ada 100644 --- a/python/position.py +++ b/python/position.py @@ -321,16 +321,29 @@ def populate_cashflow_history(conn, session, workdate=None, funds=("SERCGMAST",) data = retrieve_data( session, securities, - ["HIST_CASH_FLOW", "MTG_HIST_CPN", "FLT_CPN_HIST", "HIST_INTEREST_DISTRIBUTED"], + [ + "HIST_CASH_FLOW", + "MTG_HIST_CPN", + "FLT_CPN_HIST", + "HIST_INTEREST_DISTRIBUTED", + "MTG_HIST_FACT", + ], ) fixed_coupons = {"XS0306416982 Mtge": 7.62, "91927RAD1 Mtge": 6.77} for k, v in data.items(): if "HIST_CASH_FLOW" in v: - to_insert = v["HIST_CASH_FLOW"].merge( - v["MTG_HIST_CPN"], - how="left", - left_on="Payment Date", - right_on="Payment Date", + to_insert = ( + v["HIST_CASH_FLOW"] + .merge( + v["MTG_HIST_CPN"], + how="left", + on="Payment Date", + ) + .merge( + v["MTG_HIST_FACT"], + how="left", + on="Payment Date", + ) ) to_insert.rename( columns={ @@ -364,7 +377,7 @@ def populate_cashflow_history(conn, session, workdate=None, funds=("SERCGMAST",) logging.error(f"No cashflows for security {securities[k]}") continue cols = to_insert.columns.tolist() + ["identifier"] - update_cols = ["principal_bal", "principal", "interest", "coupon"] + update_cols = ["principal_bal", "principal", "interest", "coupon", "factor"] sql_str = ( f"INSERT INTO cashflow_history({','.join(cols)}) " f"VALUES ({','.join(['%s'] * len(cols))}) " |
