aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/collateral/__main__.py6
-rw-r--r--python/collateral/baml_isda.py5
-rw-r--r--python/collateral/bnp.py5
-rw-r--r--python/collateral/citi.py7
-rw-r--r--python/collateral/cs.py7
-rw-r--r--python/collateral/gs.py5
-rw-r--r--python/collateral/ms.py5
7 files changed, 11 insertions, 29 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py
index 84736354..c9ccf3aa 100644
--- a/python/collateral/__main__.py
+++ b/python/collateral/__main__.py
@@ -1,10 +1,10 @@
import pandas as pd
+from exchange import ExchangeMessage
from importlib import import_module
from utils import SerenitasFileHandler
from utils.db import dawn_engine, dbconn
-from . import bus_day
from .common import get_dawn_trades, send_email
from pandas.tseries.offsets import BDay
@@ -33,9 +33,11 @@ parser.add_argument(
args = parser.parse_args()
counterparties = ["citi", "baml_isda", "ms", "gs", "bnp", "baml_fcm", "wells", "cs"]
if args.download:
+ em = ExchangeMessage()
for cp in counterparties:
cp_mod = import_module(f".{cp}", "collateral")
- cp_mod.download_files()
+ print(cp)
+ cp_mod.download_files(em)
dawn_trades = get_dawn_trades(args.workdate, dawn_engine)
diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py
index 9794e02a..01809bee 100644
--- a/python/collateral/baml_isda.py
+++ b/python/collateral/baml_isda.py
@@ -56,11 +56,8 @@ def download_from_secure_id(
z.extract(f, path=path)
-def download_files(d=None, count=20):
- from exchange import ExchangeMessage
-
+def download_files(em, d=None, count=20):
DATA_DIR = DAILY_DIR / "BAML_ISDA_reports"
- em = ExchangeMessage()
emails = em.get_msgs(path=["NYops", "Margin Calls Baml"], count=count)
for msg in emails:
if (
diff --git a/python/collateral/bnp.py b/python/collateral/bnp.py
index 51067014..331a2187 100644
--- a/python/collateral/bnp.py
+++ b/python/collateral/bnp.py
@@ -3,10 +3,7 @@ import pandas as pd
from . import DAILY_DIR
-def download_files(count: int = 20):
- from exchange import ExchangeMessage
-
- em = ExchangeMessage()
+def download_files(em, count: int = 20):
emails = em.get_msgs(
path=["NYops", "Margin Calls BNP"],
count=count,
diff --git a/python/collateral/citi.py b/python/collateral/citi.py
index acda4b1f..bf3cee16 100644
--- a/python/collateral/citi.py
+++ b/python/collateral/citi.py
@@ -1,6 +1,6 @@
import pandas as pd
from pandas.tseries.offsets import BDay
-from . import DAILY_DIR, bus_day
+from . import DAILY_DIR
from .common import load_pdf, get_col
@@ -16,10 +16,7 @@ def load_file(d):
return pd.read_excel(fname, skiprows=6, skipfooter=2)
-def download_files(count=20):
- from exchange import ExchangeMessage
-
- em = ExchangeMessage()
+def download_files(em, count=20):
emails = em.get_msgs(
path=["NYops", "Margin Calls Citi"], count=count, subject__startswith="262966"
)
diff --git a/python/collateral/cs.py b/python/collateral/cs.py
index 22cb6d3b..24bceb2f 100644
--- a/python/collateral/cs.py
+++ b/python/collateral/cs.py
@@ -4,11 +4,8 @@ from pandas.tseries.offsets import BDay
from .common import load_pdf
-def download_files(count=20):
- from exchange import ExchangeMessage
-
+def download_files(em, count=20):
DATA_DIR = DAILY_DIR / "CS_reports"
- em = ExchangeMessage()
emails = em.get_msgs(
path=["NYops", "Margin Calls CS"], count=count, subject__contains="DERV048829"
)
@@ -42,8 +39,6 @@ def download_files(count=20):
def get_collateral(d):
DATA_DIR = DAILY_DIR / "CS_reports"
- # get most recent file before current date
- pdf_file = DATA_DIR / f"CollateralCptyStatement161SerenitasCGMFRVM_{d:%m%d%Y}.pdf"
collat = 0
for collat_type in ("RVM", "IM"):
pdf_file = (
diff --git a/python/collateral/gs.py b/python/collateral/gs.py
index 5d69dc14..3a6ee5be 100644
--- a/python/collateral/gs.py
+++ b/python/collateral/gs.py
@@ -2,10 +2,7 @@ import pandas as pd
from . import DAILY_DIR
-def download_files(count=20):
- from exchange import ExchangeMessage
-
- em = ExchangeMessage()
+def download_files(em, count=20):
emails = em.get_msgs(
path=["NYops", "Margin calls"], count=count, subject__contains="Margin"
)
diff --git a/python/collateral/ms.py b/python/collateral/ms.py
index c8bdbc8a..415b92c8 100644
--- a/python/collateral/ms.py
+++ b/python/collateral/ms.py
@@ -2,10 +2,7 @@ import pandas as pd
from . import DAILY_DIR
-def download_files(count=20):
- from exchange import ExchangeMessage
-
- em = ExchangeMessage()
+def download_files(em, count=20):
emails = em.get_msgs(
path=["NYops", "Margin calls MS"],
count=count,