diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/collateral/baml_fcm.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/python/collateral/baml_fcm.py b/python/collateral/baml_fcm.py index 6847eb93..9ce7d8bd 100644 --- a/python/collateral/baml_fcm.py +++ b/python/collateral/baml_fcm.py @@ -2,6 +2,9 @@ from . import DAILY_DIR, SftpClient from .common import compare_notionals, compare_notionals_rates, STRATEGY_CASH_MAPPING import pandas as pd from sqlalchemy.exc import IntegrityError +import logging + +logger = logging.getLogger(__name__) def download_files(*args, fund="Serenitas", **kwargs): @@ -119,6 +122,8 @@ def collateral(d, positions, *, engine, fund="Serenitas", positions_irs, **kwarg parse_dates=["Statement Date"], index_col=["Statement Date"], ) + df_margin_fut = df_margin[df_margin.AT == "R1"] + df_margin = df_margin[df_margin.AT != "R1"] df_margin.AT = df_margin.AT.replace( { "Q4": "EUR", @@ -131,6 +136,8 @@ def collateral(d, positions, *, engine, fund="Serenitas", positions_irs, **kwarg df_margin = df_margin.set_index("AT", append=True) df_margin = df_margin.groupby(level=(0, 1)).sum() df_margin = df_margin.reset_index() + df_margin_fut.AT = "USD" + df_margin_fut = df_margin_fut.reset_index() col_names.pop(2) try: place_holders = ",".join(["%s"] * (len(col_names) - 1)) @@ -139,7 +146,12 @@ def collateral(d, positions, *, engine, fund="Serenitas", positions_irs, **kwarg f"INSERT INTO fcm_moneyline VALUES(%s, 'V0NSCLMFCM', {place_holders})", list(df_margin[col_names].itertuples(index=False)), ) - except IntegrityError: + conn.execute( + f"INSERT INTO fcm_moneyline VALUES(%s, 'MLNSCLMAFU', {place_holders})", + list(df_margin_fut[col_names].itertuples(index=False)), + ) + except IntegrityError as e: + logger.debug(str(e)) pass df = pd.concat([df, df_rates]) df = ( |
