diff options
Diffstat (limited to 'python/custodian_wire.py')
| -rw-r--r-- | python/custodian_wire.py | 50 |
1 files changed, 3 insertions, 47 deletions
diff --git a/python/custodian_wire.py b/python/custodian_wire.py index 7c246696..e7b0a5bd 100644 --- a/python/custodian_wire.py +++ b/python/custodian_wire.py @@ -1,47 +1,6 @@ -from bowdst import get_dir, download_messages -from csv import DictReader -from citco_ops.bowdst import BowdstWire, IsoselWire -from citco_ops.cash import IsoselCashReport, dt_from_fname as nt_key +from citco_ops.bowdst import BowdstWire, NTWire import datetime - -def dt_from_fname(f): - return datetime.datetime.strptime( - f.name.split("_")[1].split(".")[0], "%Y%m%d%H%M%S" - ) - - -def load_bowdst_wire_report(workdate: datetime.date): - p = max( - [f for f in get_dir(workdate).iterdir() if "BowdstWires" in f.name], - key=dt_from_fname, - default=None, - ) - if not p: # No files available - return - with open(p) as fh: - reader = DictReader(fh) - for line in reader: - BowdstWire.from_nexen_line(line).stage() - BowdstWire.commit() - - -def load_isosel_wire_report(workdate: datetime.date): - p = max( - [f for f in get_dir(workdate).iterdir() if "custodian_wires" in f.name], - key=nt_key, - default=None, - ) - if not p: # No files available - return - with open(p) as fh: - reader = DictReader(fh) - for line in reader: - if "sponsor" in line["narrative"].lower(): - IsoselWire.from_passport_line(line).stage() - IsoselWire.commit() - - if __name__ == "__main__": import argparse from serenitas.utils.exchange import ExchangeMessage @@ -55,8 +14,5 @@ if __name__ == "__main__": help="working date", ) args = parser.parse_args() - em = ExchangeMessage() - download_messages(em) - IsoselCashReport.download_reports(args.workdate) - load_bowdst_wire_report(args.workdate) - load_isosel_wire_report(args.workdate) + for wire_report in (BowdstWire, NTWire): + wire_report.to_db(args.workdate) |
