aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops/wires.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops/wires.py')
-rw-r--r--python/report_ops/wires.py63
1 files changed, 57 insertions, 6 deletions
diff --git a/python/report_ops/wires.py b/python/report_ops/wires.py
index e2f4ea6f..63aca32a 100644
--- a/python/report_ops/wires.py
+++ b/python/report_ops/wires.py
@@ -1,14 +1,17 @@
-from dataclasses import dataclass
+import datetime
+from csv import DictReader
+from functools import partial
+from dataclasses import dataclass, field
import pandas as pd
from typing import Literal
-import datetime
+
from serenitas.ops.trade_dataclasses import Deal, Ccy
+from serenitas.analytics.dates import prev_business_day
+from serenitas.utils.env import DAILY_DIR
from typing import ClassVar
-from .custodians import NT, BNY, UMB
+
+from .custodians import NT, BNY, UMB, SCOTIA
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"}
@@ -65,6 +68,9 @@ class Wire(Deal, table_name="custodian_wires", deal_type="custodian_wires"):
return p
+Wire._registry.clear()
+
+
class BowdstBNYWire(Wire, BNY, fund="BOWDST", custodian="BNY", dtkey="%Y%m%d%H%M%S"):
@classmethod
def from_report_line(cls, line: dict):
@@ -155,3 +161,48 @@ class SerenitasUMBWire(
continue
cls.from_report_line(row_dict).stage()
cls.commit()
+
+
+class SeleneSCOTIAWire(Wire, SCOTIA, fund="ISOSEL", custodian="SCOTIA", dtkey=None):
+ @classmethod
+ def from_report_line(cls, line: dict):
+ return cls(
+ date=line["Value Date"],
+ entry_date=line["Posting Date"],
+ value_date=line["Value Date"],
+ pay_date=line["Value Date"],
+ currency=line["Curr."],
+ amount=line["Cr Amount"] if line["Dr/Cr"] == "Cr" else -line["Dr Amount"],
+ wire_details=line["Reference Data"],
+ unique_ref=line["Bank Ref."],
+ )
+
+ @classmethod
+ def to_db(cls, date):
+ p = cls.get_newest_report(date)
+ conn = cls._conn
+ with conn.cursor() as c:
+ c.execute(
+ "DELETE FROM custodian_wires WHERE date=%s AND fund=%s AND custodian=%s",
+ (
+ prev_business_day(date),
+ cls.fund,
+ cls.custodian,
+ ),
+ )
+ conn.commit()
+ df = pd.read_excel(p, skipfooter=2)
+ df["index"] = df.index
+ for row_dict in df.to_dict(orient="records"):
+ cls.from_report_line(row_dict).stage()
+ cls.commit()
+
+ @classmethod
+ def get_newest_report(cls, date):
+ cls.download_reports(date)
+ REPORT_DIR = DAILY_DIR / "Selene" / "Scotia_reports"
+ return next(
+ REPORT_DIR.glob(
+ f"IsoSelene_{prev_business_day(date):%d-%b-%Y}_*_xlsx.JOAAPKO3.JOAAPKO1"
+ )
+ )