diff options
Diffstat (limited to 'python/collateral/ms.py')
| -rw-r--r-- | python/collateral/ms.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/python/collateral/ms.py b/python/collateral/ms.py index bf9bddbf..0acccedb 100644 --- a/python/collateral/ms.py +++ b/python/collateral/ms.py @@ -1,5 +1,6 @@ import pandas as pd from . import DAILY_DIR +from exchangelib import FileAttachment paths = { "Serenitas": ["NYops", "Margin calls MS"], @@ -16,17 +17,25 @@ subjects = { def download_files(em, count=20, *, fund="Serenitas", **kwargs): emails = em.get_msgs( - path=paths[fund], count=count, subject__contains=subjects[fund], + path=paths[fund], + count=count, + subject__contains=subjects[fund], ) DATA_DIR = DAILY_DIR / fund / "MS_reports" for msg in emails: for attach in msg.attachments: - if "NETSwaps" in attach.name: - fname = "Trade_Detail_" + attach.name.split("_")[1] - elif "NET_Collateral" in attach.name: - fname = "Collateral_Detail_" + attach.name.rsplit("_", 1)[1] - else: - continue + if isinstance(attach, FileAttachment): + if "NETSwaps" in attach.name: + fname = "Trade_Detail_" + attach.name.split("_")[1] + elif "NETFX" in attach.name: + fname = "Trade_Detail_FX_" + attach.name.split("_")[1] + elif "NET_Collateral" in attach.name: + fname = "Collateral_Detail_" + attach.name.rsplit("_", 1)[1] + elif attach.name.endswith("pdf"): + ending = attach.name.rsplit("_", 1)[1] + fname = "Statement_" + ending.split(".")[0] + ".pdf" + else: + continue p = DATA_DIR / fname if not p.exists(): p.write_bytes(attach.content) |
