aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral/cs.py
blob: b2d5c959e37c9d2a4a4cafe2f6f5f9b094fcc418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pandas as pd
from . import DAILY_DIR


def download_files(count=20):
    from exchange import ExchangeMessage

    em = ExchangeMessage()
    emails = em.get_msgs(
        path=["NYops", "Margin calls CS"], count=count, subject__contains="Margin"
    )
    DATA_DIR = DAILY_DIR / "CS_reports"
    for msg in emails:
        for attach in msg.attachments:
            fname = attach.name
            if fname.endswith("xlsx"):
                p = DATA_DIR / fname
                if not p.exists():
                    p.write_bytes(attach.content)