diff options
Diffstat (limited to 'python/collateral')
| -rw-r--r-- | python/collateral/__main__.py | 1 | ||||
| -rw-r--r-- | python/collateral/common.py | 7 | ||||
| -rw-r--r-- | python/collateral/jpm.py | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py index 11fa69f1..dcf4e18a 100644 --- a/python/collateral/__main__.py +++ b/python/collateral/__main__.py @@ -107,7 +107,6 @@ for fund in ("Serenitas", "Brinker", "BowdSt"): cp, fund, bilat_positions, workdate, dawn_engine ) - df = pd.concat(df, names=["fund", "broker", "strategy"]).reset_index() df.strategy = df.strategy.str.replace("^(M_|SER_)?", "", 1, regex=True) df["fund"] = df.fund.map(fund_mapping) diff --git a/python/collateral/common.py b/python/collateral/common.py index 1fd31d05..a210c5fb 100644 --- a/python/collateral/common.py +++ b/python/collateral/common.py @@ -92,7 +92,12 @@ def get_bilateral_trades(d: datetime.date, fund: str, engine: Engine) -> pd.Data engine, params=(d, fund, d), ) - df = pd.concat([df_cds, df_swaptions, df_caps, df_forwards]) + df_trs = pd.read_sql_query( + "SELECT cpty_id, folder, initial_margin_percentage * notional/100 as IA from trs where cpty_id is NOT NULL and trade_date <= %s and fund=%s", + engine, + params=(d, fund), + ) + df = pd.concat([df_cds, df_swaptions, df_caps, df_forwards, df_trs]) df = df.replace({"folder": STRATEGY_CASH_MAPPING}) return df diff --git a/python/collateral/jpm.py b/python/collateral/jpm.py index 84fff107..7d4d51ad 100644 --- a/python/collateral/jpm.py +++ b/python/collateral/jpm.py @@ -82,6 +82,11 @@ def collateral(d, dawn_trades, *, fund="BowdSt", **kwargs): except IndexError: collat = 0.0 df = load_positions(pages[4]) + try: + df = pd.concat([load_positions(pages[4]), load_positions(pages[5])]) + except StopIteration: + # No TRS + df = load_positions(pages[4]) df = df.merge(dawn_trades, how="left", left_on="Deal ID", right_on="cpty_id") missing_ids = df.loc[df.cpty_id.isnull(), "Deal ID"] if not missing_ids.empty: |
