diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/collateral/jpm.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/python/collateral/jpm.py b/python/collateral/jpm.py index 1d15df6a..8a5123c2 100644 --- a/python/collateral/jpm.py +++ b/python/collateral/jpm.py @@ -1,7 +1,9 @@ +import datetime import pandas as pd from io import BytesIO from pikepdf import Pdf from . import DAILY_DIR +from .common import load_pdf def load_file(d, fund): @@ -20,6 +22,24 @@ paths = { } +def load_file(d, fund): + try: + fname = next( + (DAILY_DIR / fund / "JPM_reports").glob( + f"CSCFTCSTMT-*-{d:%y%m%d}-909271_2.pdf" + ) + ) + except StopIteration: + raise FileNotFoundError(f"JPM file not found for date {d}") + return fname + + +def get_collateral(d: datetime.date, fund): + pdf_file = load_file(d, fund) + collat_page = load_pdf(pdf_file, pages=True)[3] + return float(get_col(pomme, 200, 300, 1000, 1100)[0].replace(",", "")) + + def download_files(em, count=20, *, fund="BowdSt", **kwargs): if fund not in paths: return |
