aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral/gs_fcm.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral/gs_fcm.py')
-rw-r--r--python/collateral/gs_fcm.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/python/collateral/gs_fcm.py b/python/collateral/gs_fcm.py
index 661408fc..49a9f427 100644
--- a/python/collateral/gs_fcm.py
+++ b/python/collateral/gs_fcm.py
@@ -14,7 +14,7 @@ def get_filename(d: datetime.date, name: str):
try:
fname = next(
(DAILY_DIR / "BowdSt" / "GS_fcm_reports").glob(
- f"GS-OTCSDIReporting-{name}-*-{d:%Y%m%d}-*.csv"
+ f"GS-*-{name}-*-{d:%Y%m%d}-*.csv"
)
)
except StopIteration:
@@ -63,7 +63,6 @@ def collateral(d: datetime.date, positions, *, engine, **kwargs):
)
df = df.rename(columns={"folder": "Strategy", "currency": "Currency"})
df["date"] = cob_date
-
df_margin = pd.read_csv(
get_filename(
d + datetime.timedelta(days=1), "Account_Balances_and_Margin_extended"
@@ -85,9 +84,29 @@ def collateral(d: datetime.date, positions, *, engine, **kwargs):
"Commissions (local)": "transaction_fees",
}
df_margin = df_margin.rename(columns=col_mapping)
+ df_margin["current_im"] *= -1.0
cols = col_mapping.values()
+ df_margin_futures = pd.read_csv(
+ get_filename(d + datetime.timedelta(days=1), "Account_Balances_By_Currency"),
+ parse_dates=["COB Date"],
+ thousands=",",
+ )
+ col_mapping = {
+ "Beginning Account Balance (Local)": "beginning_balance",
+ "Ending Account Balance (Local)": "ending_balance",
+ "Initial Margin Requirement (Local)": "current_im",
+ "GS Account Number": "account",
+ "COB Date": "date",
+ "Excess/Deficit (Local)": "current_excess_deficit",
+ "Total Equity (Local)": "account_value_market",
+ "Currency": "currency",
+ "Gross Realized P&L (Local)": "realized_pnl",
+ "Commission & Fees (Local)": "transaction_fees",
+ }
+ df_margin_futures = df_margin_futures.rename(columns=col_mapping)
+ df_margin_futures["pai"] = 0.0
+ df_margin = pd.concat([df_margin, df_margin_futures])
place_holders = ",".join(["%s"] * len(cols))
- df_margin["current_im"] *= -1.0
engine.execute(
f"INSERT INTO fcm_moneyline({','.join(cols)}) VALUES({place_holders})"
"ON CONFLICT (date, account, currency) "