diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/misc.py | 4 | ||||
| -rw-r--r-- | python/report_ops/wires.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/python/report_ops/misc.py b/python/report_ops/misc.py index 318bb4eb..73f08f90 100644 --- a/python/report_ops/misc.py +++ b/python/report_ops/misc.py @@ -16,7 +16,7 @@ def get_dir(workdate: datetime.date, archived=True) -> pathlib.Path: return p -def dt_from_fname(f): +def dt_from_fname(f, dt_format="%Y%m%d%H%M"): return datetime.datetime.strptime( - f.name.removesuffix(".csv").removesuffix(".xlsx").rsplit("_")[-1], "%Y%m%d%H%M" + f.name.removesuffix(".csv").removesuffix(".xlsx").rsplit("_")[-1], dt_format ) diff --git a/python/report_ops/wires.py b/python/report_ops/wires.py index 0e367290..7e210ed7 100644 --- a/python/report_ops/wires.py +++ b/python/report_ops/wires.py @@ -3,9 +3,10 @@ import datetime from serenitas.ops.trade_dataclasses import Deal, Ccy from typing import ClassVar from .custodians import NT, BNY -from .misc import get_dir +from .misc import get_dir, dt_from_fname from dataclasses import field from csv import DictReader +from functools import partial _nt_to_currency = {"EURO - EUR": "EUR", "U.S. DOLLARS - USD": "USD"} @@ -43,7 +44,7 @@ class Wire(Deal, table_name="custodian_wires", deal_type="custodian_wires"): cls.download_reports(date) p = max( [f for f in get_dir(date).iterdir() if fname in f.name], - key=cls.dtkey_fun(), + key=partial(dt_from_fname, dt_format=cls.dtkey), default=None, ) if not p: |
