aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/load_bbh_reports.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/python/load_bbh_reports.py b/python/load_bbh_reports.py
index 06b656f6..b4a6d6e5 100644
--- a/python/load_bbh_reports.py
+++ b/python/load_bbh_reports.py
@@ -75,17 +75,31 @@ def val_report(f):
df.to_sql("bbh_val", dbengine("dawndb"), if_exists="append", index=False)
+def bond_report(f, date):
+ df = pd.read_csv(
+ f,
+ parse_dates=["Trade Date", "Settle Date"],
+ )
+ for col in df.select_dtypes(include="object"):
+ df[col] = df[col].str.strip()
+ df.columns = df.columns.str.lower().str.replace(" ", "_").str.replace("/", "_")
+ df["row"] = df.index
+ df["report_date"] = date
+ df.to_sql("bbh_bond", dbengine("dawndb"), if_exists="append", index=False)
+
+
def load_reports(date):
path = DAILY_DIR / str(date) / "Reports"
pnl_report(path / f"BBH_PNL.{date:%Y%m%d}.csv")
val_report(path / f"BBH_VAL.{date:%Y%m%d}.csv")
+ bond_report(path / f"BBH_BOND.{date:%Y%m%d}.csv", date)
def download_val_report(date):
reports_dir = DAILY_DIR / str(date) / "Reports"
sftp = SftpClient.from_creds("bbh")
for f in sftp.client.listdir("frombbh"):
- if f.split(".")[1] == f"{date:%Y%m%d}":
+ if f.split(".")[1].split("_")[0] == f"{date:%Y%m%d}":
sftp.client.get(f"frombbh/{f}", localpath=reports_dir / f)