aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops')
-rw-r--r--python/report_ops/__main__.py25
-rw-r--r--python/report_ops/cash.py18
-rw-r--r--python/report_ops/misc.py2
3 files changed, 31 insertions, 14 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py
index ab50c632..9ff1a3d9 100644
--- a/python/report_ops/__main__.py
+++ b/python/report_ops/__main__.py
@@ -14,11 +14,12 @@ from .sma import (
IRSwaptionPosition,
CDXSwaptionPosition,
)
-from .cash import NTCashReport, UMBCashReport, BNYCashReport
+from .cash import CashReport
from .admin import CitcoReport
from .wires import Wire
from .custodians import upload_to_custodian
from .utils import notify_payment_settlements, PaymentMonitor
+from .misc import _fund_custodians
logger = logging.getLogger(__name__)
@@ -77,16 +78,18 @@ if args.sma_positions:
logger.warning(e)
if args.cash_reports:
- for report_cls in (
- NTCashReport,
- UMBCashReport,
- BNYCashReport,
- ):
- report = report_cls(args.date)
- try:
- report.to_db()
- except ValueError as e:
- logger.warning(e)
+ for fund, custodians in _fund_custodians.items():
+ for custodian in custodians:
+ report = CashReport[
+ (
+ fund,
+ custodian,
+ )
+ ](args.date)
+ try:
+ report.to_db()
+ except ValueError as e:
+ logger.warning(e)
if args.isosel_reports:
for report in ("isosel_accrued", "citco_reports"):
diff --git a/python/report_ops/cash.py b/python/report_ops/cash.py
index 63b43bbe..ce299896 100644
--- a/python/report_ops/cash.py
+++ b/python/report_ops/cash.py
@@ -52,11 +52,21 @@ class CashReport:
_conn: ClassVar[dbconn] = dbconn("dawndb")
_staging_queue: ClassVar[set] = set()
_insert_sql = "INSERT INTO cash_balances VALUES (%s, %s, %s, %s, %s, %s) ON CONFLICT DO NOTHING"
+ _registry = {}
def __init_subclass__(cls, fund, custodian, dtkey):
cls.fund = fund
cls.custodian = custodian
cls.dtkey = dtkey
+ cls._registry[
+ (
+ fund,
+ custodian,
+ )
+ ] = cls
+
+ def __class_getitem__(cls, key):
+ return cls._registry[key]
def to_db(self, report_name):
self.download_reports(self.date)
@@ -93,7 +103,9 @@ class CashReport:
)
-class NTCashReport(CashReport, NT, fund="ISOSEL", custodian="NT", dtkey="%Y%m%d%H%M"):
+class SeleneNTCashReport(
+ CashReport, NT, fund="ISOSEL", custodian="NT", dtkey="%Y%m%d%H%M"
+):
def to_db(self):
p = super().to_db("cash_")
df = pd.read_csv(p, on_bad_lines="warn")
@@ -107,7 +119,7 @@ class NTCashReport(CashReport, NT, fund="ISOSEL", custodian="NT", dtkey="%Y%m%d%
self._staging_queue.clear()
-class UMBCashReport(
+class SerenitasUMBCashReport(
CashReport, UMB, fund="SERCGMAST", custodian="UMB", dtkey="%Y%m%d%H%M"
):
def to_db(self):
@@ -121,7 +133,7 @@ class UMBCashReport(
self._staging_queue.clear()
-class BNYCashReport(
+class BowdstBNYCashReport(
CashReport, BNY, fund="BOWDST", custodian="BNY", dtkey="%Y%m%d%H%M%S"
):
def to_db(self):
diff --git a/python/report_ops/misc.py b/python/report_ops/misc.py
index b70c0605..cdbad81e 100644
--- a/python/report_ops/misc.py
+++ b/python/report_ops/misc.py
@@ -57,6 +57,8 @@ _cc_recipients = {
"BRINKER": ("nyops@lmcg.com",),
}
+_fund_custodians = {"SERCGMAST": ("UMB",), "ISOSEL": ("NT",), "BOWDST": ("BNY",)}
+
def get_dir(
workdate: datetime.date = datetime.date.today(), archived=True