aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/bowdst_wire.py24
-rw-r--r--python/citco_ops/bowdst.py17
-rw-r--r--python/citco_ops/cash.py10
3 files changed, 42 insertions, 9 deletions
diff --git a/python/bowdst_wire.py b/python/bowdst_wire.py
index b53e4624..8153ecb7 100644
--- a/python/bowdst_wire.py
+++ b/python/bowdst_wire.py
@@ -1,6 +1,7 @@
from bowdst import get_dir, download_messages
from csv import DictReader
-from citco_ops.bowdst import BowdstWire
+from citco_ops.bowdst import BowdstWire, IsoselWire
+from citco_ops.cash import IsoselCashReport, dt_from_fname as nt_key
import datetime
@@ -10,7 +11,7 @@ def dt_from_fname(f):
)
-def load_wire_report(workdate: datetime.date):
+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,
@@ -24,6 +25,21 @@ def load_wire_report(workdate: datetime.date):
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,
+ )
+ 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
@@ -39,4 +55,6 @@ if __name__ == "__main__":
args = parser.parse_args()
em = ExchangeMessage()
download_messages(em)
- load_wire_report(args.workdate)
+ IsoselCashReport.download_reports(args.workdate)
+ load_bowdst_wire_report(args.workdate)
+ load_isosel_wire_report(args.workdate)
diff --git a/python/citco_ops/bowdst.py b/python/citco_ops/bowdst.py
index 527a35a8..15759895 100644
--- a/python/citco_ops/bowdst.py
+++ b/python/citco_ops/bowdst.py
@@ -3,6 +3,8 @@ import datetime
from serenitas.ops.trade_dataclasses import Deal, Ccy
from typing import ClassVar
+_nt_to_currency = {"EURO - EUR": "EUR", "U.S. DOLLARS - USD": "USD"}
+
@dataclass
class Wire(Deal, table_name="custodian_wires", deal_type="custodian_wires"):
@@ -43,3 +45,18 @@ class BowdstWire(Wire, fund="BOWDST"):
else line["Transaction Description 2"],
unique_ref=line["Reference Number"],
)
+
+
+class IsoselWire(Wire, fund="ISOSEL"):
+ @classmethod
+ def from_passport_line(cls, line: dict):
+ return cls(
+ date=line["Through date"],
+ entry_date=line["D-GL-POST"],
+ value_date=line["D-TRAN-EFF"],
+ pay_date=line["D-TRAN-EFF"],
+ currency=_nt_to_currency[line["N-GL-AC30"]],
+ amount=line["Net amount - local"],
+ wire_details=line["narrative"],
+ unique_ref=line["C-EXTL-SYS-TRN-DSC-3"],
+ )
diff --git a/python/citco_ops/cash.py b/python/citco_ops/cash.py
index 78f26330..84a8c80b 100644
--- a/python/citco_ops/cash.py
+++ b/python/citco_ops/cash.py
@@ -61,15 +61,13 @@ class CashReport:
class IsoselCashReport(CashReport, fund="ISOSEL", account_number="ISOS01"):
- def download_reports(self):
+ @classmethod
+ def download_reports(cls, date=datetime.date.today()):
em = ExchangeMessage()
for msg in em.get_msgs(path=["SeleneOps", "Passport"]):
for attach in msg.attachments:
message_time = attach.last_modified_time
- if (
- attach.name == "Attachment1.pgp"
- and prev_business_day(message_time.date()) == self.date
- ):
+ if attach.name == "Attachment1.pgp" and message_time.date() == date:
dest = get_dir(message_time.date())
dest.mkdir(exist_ok=True, parents=True)
with attach.fp as fp:
@@ -87,7 +85,7 @@ class IsoselCashReport(CashReport, fund="ISOSEL", account_number="ISOS01"):
csvFile.write(text)
def to_db(self):
- self.download_reports()
+ self.download_reports(self.date)
p = max(
[
f