diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/report_ops/__main__.py | 18 | ||||
| -rw-r--r-- | python/report_ops/cash.py | 5 |
2 files changed, 14 insertions, 9 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py index 3c6732e9..04c1b5de 100644 --- a/python/report_ops/__main__.py +++ b/python/report_ops/__main__.py @@ -5,6 +5,7 @@ import datetime from serenitas.analytics.dates import prev_business_day from serenitas.utils.db import dbconn from serenitas.utils.exchange import ExchangeMessage +from serenitas.analytics.exceptions import MissingDataError from .sma import SMA from .cash import CashReport @@ -87,20 +88,23 @@ if args.cash_reports or args.wire_reports: get_custodian_download_fun(custodian)(args.date, fund, em=em) if args.cash_reports: cash_report = CashReport[custodian] - cash_report.to_db(args.date, fund) + try: + cash_report.to_db(args.date, fund) + except MissingDataError as e: + logger.warning(e) if args.wire_reports: wire_report = WireReport[custodian] - wire_report.to_db(args.date, fund) + try: + wire_report.to_db(args.date, fund) + except MissingDataError as e: + logger.warning(e) if args.isosel_reports: for fund in ("ISOSEL",): for report in ("isosel_accrued", "citco_reports"): - try: - report = CitcoReport[report](cob, fund) - report.to_db() - except ValueError as e: - logger.warning(e) + report = CitcoReport[report](cob, fund) + report.to_db() if args.send_to_custodians: for account in ( diff --git a/python/report_ops/cash.py b/python/report_ops/cash.py index 3d4157a1..c71fcdc0 100644 --- a/python/report_ops/cash.py +++ b/python/report_ops/cash.py @@ -7,6 +7,7 @@ import pandas as pd from serenitas.utils.env import DAILY_DIR from serenitas.utils.db2 import dbconn from serenitas.analytics.dates import prev_business_day +from serenitas.analytics.exceptions import MissingDataError from .misc import get_dir, dt_from_fname, Custodian @@ -40,7 +41,7 @@ class CashReport: default=None, ) if not p: - raise ValueError( + raise MissingDataError( f"No reports found for fund: {prefix.split('_')[-1]} date: {date}" ) return p @@ -138,4 +139,4 @@ class ScotiaCashReport(CashReport, custodian="SCOTIA", dtkey="%Y%m%d%H%M%S"): ) ) except StopIteration as e: - raise ValueError(f"No file available for Scotia on {date}") from e + raise MissingDataError(f"No file available for Scotia on {date}") from e |
