diff options
| -rw-r--r-- | python/bowdst.py | 2 | ||||
| -rw-r--r-- | python/cds_rebook.py | 12 | ||||
| -rw-r--r-- | python/collateral/__main__.py | 2 | ||||
| -rw-r--r-- | python/collateral/common.py | 2 | ||||
| -rw-r--r-- | python/exchange.py | 60 | ||||
| -rw-r--r-- | python/process_queue.py | 2 |
6 files changed, 11 insertions, 69 deletions
diff --git a/python/bowdst.py b/python/bowdst.py index 9fdacc08..5b6542d2 100644 --- a/python/bowdst.py +++ b/python/bowdst.py @@ -280,7 +280,7 @@ def send_email( if __name__ == "__main__": import argparse - from exchange import ExchangeMessage + from serenitas.utils.exchange import ExchangeMessage parser = argparse.ArgumentParser() parser.add_argument( diff --git a/python/cds_rebook.py b/python/cds_rebook.py index 46d7583e..b2685f6f 100644 --- a/python/cds_rebook.py +++ b/python/cds_rebook.py @@ -1,12 +1,12 @@ -from exchange import ExchangeMessage, FileAttachment +from serenitas.utils.exchange import ExchangeMessage, FileAttachment from io import BytesIO -from utils.db import serenitas_pool, dbconn +from serenitas.utils.db import serenitas_pool, dbconn import datetime import pandas as pd from pandas.tseries.offsets import BDay from psycopg2.extras import execute_values from pyisda.date import cds_accrued, default_accrual, previous_twentieth -from analytics.index import CreditIndex +from serenitas.analytics.index import CreditIndex from copy import copy @@ -297,6 +297,8 @@ if __name__ == "__main__": # send_csv(dawndb, datetime.date(2020, 10, 1), "PIZZAFI") # SELEGRO # rebook(conn, datetime.date(2020, 10, 20), 40769171, "Senior", "BAML") - rebook(conn, datetime.date(2020, 10, 20), 40769171, "Senior", "GS", "BOWDST") - send_csv(dawndb, datetime.date(2020, 10, 20), "SELEGRO") + # rebook(conn, datetime.date(2020, 10, 20), 40769171, "Senior", "GS", "BOWDST") + # send_csv(dawndb, datetime.date(2020, 10, 20), "SELEGRO") + # EUROPCA + rebook(conn, datetime.date(2021, 1, 13), 10758505, "Senior", "BAML") serenitas_pool.putconn(conn) diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py index a2398fc1..f0a672f1 100644 --- a/python/collateral/__main__.py +++ b/python/collateral/__main__.py @@ -1,9 +1,9 @@ import pandas as pd -from exchange import ExchangeMessage from importlib import import_module from serenitas.utils import SerenitasFileHandler from serenitas.utils.db import dawn_engine, dbconn +from serenitas.utils.exchange import ExchangeMessage from .common import get_bilateral_trades, send_email, prev_business_day diff --git a/python/collateral/common.py b/python/collateral/common.py index 96f673c2..f11b4ed9 100644 --- a/python/collateral/common.py +++ b/python/collateral/common.py @@ -83,7 +83,7 @@ def get_bilateral_trades(d: datetime.date, fund: str, engine: Engine) -> pd.Data def send_email(d: datetime.date, df: pd.DataFrame) -> None: - from exchange import ExchangeMessage + from serenitas.utils.exchange import ExchangeMessage pd.set_option("display.float_format", "{:.2f}".format) df = df.drop("date", axis=1).set_index("broker") diff --git a/python/exchange.py b/python/exchange.py deleted file mode 100644 index 7b21787f..00000000 --- a/python/exchange.py +++ /dev/null @@ -1,60 +0,0 @@ -from exchangelib import ( - Credentials, - Configuration, - Account, - DELEGATE, - Message, - FileAttachment, -) -from pathlib import Path -from typing import Iterable -import json - - -def get_account(email_address): - with open(Path.home() / ".credentials" / (email_address + ".json")) as fh: - creds = json.load(fh) - credentials = Credentials(**creds) - config = Configuration(server="autodiscover.lmcg.com", credentials=credentials) - return Account( - primary_smtp_address=email_address, - config=config, - autodiscover=False, - access_type=DELEGATE, - ) - - -class ExchangeMessage: - _account = get_account("ghorel@lmcg.com") - - def get_msgs(self, count=None, path=["GS", "Swaptions"], **filters): - folder = self._account.inbox - for p in path: - folder /= p - folder = folder.filter(**filters) - if count: - for msg in folder.all().order_by("-datetime_sent")[:count]: - yield msg - else: - for msg in folder.all().order_by("-datetime_sent"): - yield msg - - def send_email( - self, - subject, - body, - to_recipients, - cc_recipients=(), - attach: Iterable[FileAttachment] = (), - ): - m = Message( - account=self._account, - folder=self._account.sent, - subject=subject, - body=body, - to_recipients=to_recipients, - cc_recipients=cc_recipients, - ) - for attachment in attach: - m.attach(attachment) - m.send_and_save() diff --git a/python/process_queue.py b/python/process_queue.py index 214207a4..4edc046d 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -18,11 +18,11 @@ try: except KeyError: sys.exit("Please set path of daily directory in 'DAILY_DIR'") -from exchange import ExchangeMessage, FileAttachment from itertools import groupby from pickle import loads from serenitas.analytics.bbg_helpers import init_bbg_session, retrieve_data, BBG_IP from serenitas.utils.db import dbconn +from serenitas.utils.exchange import ExchangeMessage, FileAttachment from serenitas.utils.remote import FtpClient, SftpClient from serenitas.utils import get_redis_queue from functools import partial |
