aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/load_bbh_reports.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/python/load_bbh_reports.py b/python/load_bbh_reports.py
index 3dacc44c..6162a1f4 100644
--- a/python/load_bbh_reports.py
+++ b/python/load_bbh_reports.py
@@ -2,6 +2,7 @@ import datetime
import pandas as pd
from env import DAILY_DIR
from utils.db import dbengine
+from remote import SftpClient
def pnl_report(f):
@@ -62,15 +63,26 @@ def val_report(f):
)
for col in df.select_dtypes(include="object"):
df[col] = df[col].str.strip()
+ df.columns = df.columns.str.lower().str.replace(" ", "_")
df["row"] = df.index
df.to_sql("bbh_val", dbengine("dawndb"), if_exists="append", index=False)
-def load_reports(date=datetime.date.today()):
+def load_reports(date):
+ path = DAILY_DIR / str(date) / "Reports"
+ filename = "BBH_PNL." + date.strftime("%Y%m%d") + ".csv"
+ pnl_report(path / filename)
+ filename = "BBH_VAL." + date.strftime("%Y%m%d") + ".csv"
+ val_report(path / filename)
+
+
+def download_val_report(date):
path = DAILY_DIR / str(date) / "Reports"
- pnl_report(path / "BBH_PNL.csv")
- val_report(path / "BBH_VAL.csv")
+ sftp = SftpClient.from_creds("bbh")
+ sftp.download_files("frombbh", path)
if __name__ == "__main__":
- load_reports()
+ date = datetime.date.today()
+ download_val_report(date)
+ load_reports(date)