aboutsummaryrefslogtreecommitdiffstats
path: root/python/citco_ops/bowdst.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/citco_ops/bowdst.py')
-rw-r--r--python/citco_ops/bowdst.py35
1 files changed, 15 insertions, 20 deletions
diff --git a/python/citco_ops/bowdst.py b/python/citco_ops/bowdst.py
index 841e8cee..76e88bdf 100644
--- a/python/citco_ops/bowdst.py
+++ b/python/citco_ops/bowdst.py
@@ -1,13 +1,12 @@
-from dataclasses import dataclass, field
+from dataclasses import dataclass
import datetime
-from serenitas.ops.trade_dataclasses import Fund, Deal, Ccy
-from psycopg.errors import UniqueViolation
+from serenitas.ops.trade_dataclasses import Deal, Ccy
@dataclass
-class WireBase(Deal, table_name="custodian_wires", deal_type="custodian_wires"):
+class Wire(Deal, table_name="custodian_wires", deal_type="custodian_wires"):
date: datetime.date
- fund: Fund
+ fund: str
entry_date: datetime.date
value_date: datetime.date
pay_date: datetime.date
@@ -16,31 +15,27 @@ class WireBase(Deal, table_name="custodian_wires", deal_type="custodian_wires"):
wire_details: str
unique_ref: str
- def __init_subclass__(cls, fund, **kwargs):
- cls.fund = fund
-
- @classmethod
- def commit(cls):
+ def __init_subclass__(cls, **kwargs):
cls._sql_insert += " ON CONFLICT (unique_ref) DO NOTHING"
- with cls._conn.cursor() as c:
- c.executemany(cls._sql_insert, cls._insert_queue)
- cls._conn.commit()
- cls._insert_queue.clear()
+
+ def __post_init__(self):
+ self.amount = self.amount.replace(",", "")
+ if "(" in self.amount:
+ self.amount = -float(self.amount[1:-1])
+ else:
+ self.amount = float(self.amount)
-class BowdstWire(WireBase, fund="BOWDST"):
+class BowdstWire(Wire):
@classmethod
- def from_nexen_line(cls, line: dict):
+ def from_nexen_line(cls, line: dict, fund: str):
return cls(
date=line["Report Run Date"],
entry_date=line["Cash Entry Date"],
value_date=line["Cash Value Date"],
pay_date=line["Settle / Pay Date"],
currency=line["Reporting Currency Code"],
- amount=line["Local Amount"]
- .replace(",", "")
- .replace(")", "")
- .replace("(", "-"),
+ amount=line["Local Amount"],
wire_details=line["Transaction Description 1"]
if line["Transaction Type Code"] == "CW"
else line["Transaction Description 2"],