diff options
Diffstat (limited to 'python/mtm_status.py')
| -rw-r--r-- | python/mtm_status.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/python/mtm_status.py b/python/mtm_status.py index b2af76cc..e5521f6d 100644 --- a/python/mtm_status.py +++ b/python/mtm_status.py @@ -4,7 +4,6 @@ import pandas as pd from serenitas.utils.db import dbconn from psycopg2.errors import UniqueViolation from zipfile import ZipFile -import numpy as np def latest(f): @@ -18,22 +17,16 @@ def run(conn, date): with sftp.client.open(f"outbound/{target_file}") as sftp_handle: with ZipFile(sftp_handle).open(target_file.removesuffix(".zip")) as zip_handle: - df = pd.read_csv(zip_handle, skiprows=2) + df = pd.read_csv(zip_handle, skiprows=2, na_filter=False) df = df[(df["SwapType"] == "NEW") & (df["Executed"])] - breakpoint() - df = df.replace({np.nan: None}) place_holders = ",".join(["%s"] * 7) sql_str = f"INSERT INTO mtm_submissions VALUES({place_holders})" with conn.cursor() as c: for row in df.itertuples(): - cpty_id = ( - int(row.BrokerSecRef) - if type(row.BrokerSecRef) == float - else row.BrokerSecRef - ) + cpty_id = row.BrokerSecRef try: c.execute( sql_str, @@ -52,7 +45,7 @@ def run(conn, date): else: _product_type = {"CDISW": "swaptions", "TRN": "cds"} sql_str = f"UPDATE {_product_type[row.ProductType]} SET cpty_id = %s WHERE dealid = %s" - if (row.SwapType == "NEW") and (row.BrokerId != "BNPBNY") and (cpty_id): + if (row.SwapType == "NEW") and (row.BrokerId != "BNPBNY") and cpty_id: c.execute(sql_str, (cpty_id, row.TicketNo)) conn.commit() |
