1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
from dataclasses import dataclass
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"):
date: datetime.date
fund: ClassVar[str]
entry_date: datetime.date
value_date: datetime.date
pay_date: datetime.date
currency: Ccy
amount: float
wire_details: str
unique_ref: str
def __init_subclass__(cls, fund, **kwargs):
cls._sql_insert = (
cls._sql_insert.removesuffix("RETURNING *")
+ "ON CONFLICT (unique_ref) DO NOTHING RETURNING *"
)
cls.fund = fund
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(Wire, fund="BOWDST"):
@classmethod
def from_nexen_line(cls, line: dict):
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["Local Currency Code"],
amount=line["Local Amount"],
wire_details=line["Transaction Description 1"]
if line["Transaction Type Code"] == "CW"
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"],
)
|