diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/bowdst.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/python/bowdst.py b/python/bowdst.py index 5b6542d2..4af5a08b 100644 --- a/python/bowdst.py +++ b/python/bowdst.py @@ -21,6 +21,7 @@ def download_messages(em): if fname.endswith("csv") and ( fname.startswith("Asset Detail") or fname.startswith("Net Investment") + or fname.startswith("Settled Cash") ): date = datetime.datetime.strptime( fname.split("_")[1].split(".")[0], "%d %b %Y" @@ -217,6 +218,35 @@ def cmp_positions(cob: datetime.date, df_blotter: pd.DataFrame) -> pd.DataFrame: return check +def load_cash_report(cob: datetime.date) -> pd.DataFrame: + workdate = (cob + bus_day).date() + p = ( + DAILY_DIR + / str(workdate) + / "Reports" + / f"Settled Cash Statement_{workdate:%d %b %Y}.csv" + ) + df = pd.read_csv(p, thousands=",") + df = df.groupby(["Account Name", "Account Number", "Local Currency Code"]).sum() + df["date"] = workdate + df["fund"] = "BOWDST" + df = df[["Closing Balance Local", "date", "fund"]] + df.reset_index(inplace=True) + df["Account Number"] = df["Account Number"].astype( + "int64" + ) # Account Numbers are read in as float + df = df.rename( + { + "Account Name": "account_name", + "Account Number": "account_number", + "Local Currency Code": "currency_code", + "Closing Balance Local": "balance", + }, + axis=1, + ) + df.to_sql("cash_balances", dawn_engine, if_exists="append", index=False) + + def get_positions( cob: datetime.date, ) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]: @@ -295,6 +325,7 @@ if __name__ == "__main__": download_messages(em) cob = (args.workdate - bus_day).date() df_bonds, df_cds, df_tranches = get_positions(cob) + load_cash_report(cob) send_email(em, cob, df_bonds, df_cds, df_tranches) load_val_report(args.workdate) load_pnl_report(args.workdate) |
