diff options
| -rw-r--r-- | python/bowdst.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/python/bowdst.py b/python/bowdst.py index ff3b7574..b6b4fb16 100644 --- a/python/bowdst.py +++ b/python/bowdst.py @@ -1,6 +1,8 @@ import datetime +import pandas as pd from env import DAILY_DIR from exchange import ExchangeMessage +from utils.db import dbconn em = ExchangeMessage() for msg in em.get_msgs( @@ -16,4 +18,21 @@ for msg in em.get_msgs( p = DAILY_DIR / str(date) / "Reports" / fname if not p.parent.exists(): p.parent.mkdir(parents=True) - p.write_bytes(attach.content) + if not p.exists(): + p.write_bytes(attach.content) + +workdate = datetime.date.today() +p = DAILY_DIR / str(workdate) / "Reports" / f"Asset Detail_{workdate:%d %b %Y}.csv" +df = pd.read_csv(p, thousands=",") +df = df[df["Asset Type"] == "FIXED INCOME SECURITIES"] +df = df.set_index("CUSIP") +df = df[["Shares/Par", "Base Price", "Local Market Value"]] +df["Local Market Value"] = pd.to_numeric(df["Local Market Value"].str.replace(",", "")) +dawndb = dbconn("dawndb") +df_blotter = pd.read_sql_query( + "SELECT * FROM risk_positions(%s, NULL, %s)", + dawndb, + params=(workdate, "BOWDST"), + index_col=["identifier"], +) +check = df.join(df_blotter) |
