aboutsummaryrefslogtreecommitdiffstats
path: root/python/trade_dataclasses.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/trade_dataclasses.py')
-rw-r--r--python/trade_dataclasses.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/python/trade_dataclasses.py b/python/trade_dataclasses.py
index a8230508..ece094de 100644
--- a/python/trade_dataclasses.py
+++ b/python/trade_dataclasses.py
@@ -427,6 +427,40 @@ class MTMDeal:
return cls(**{k: v for k, v in kwargs.items() if k in cls._sql_fields})
+from csv_headers.citco import GIL
+
+
+class CitcoDeal:
+ _citco_queue: ClassVar[list] = []
+ _citco_headers = None
+ _sftp = SftpClient.from_creds("citco")
+ product_type: str
+
+ def __init_subclass__(cls, deal_type, **kwargs):
+ super().__init_subclass__(deal_type, **kwargs)
+ cls._citco_headers = GIL
+
+ @classmethod
+ def citco_upload(cls):
+ if not cls._citco_queue: # early exit
+ return
+ buf = StringIO()
+ csvwriter = csv.writer(buf)
+ csvwriter.writerow(cls._citco_headers)
+ csvwriter.writerows(
+ [row.get(h, None) for h in cls._citco_headers] for row in cls._citco_queue
+ )
+ buf = buf.getvalue().encode()
+ fname = f"i.innocap_serenitas.{datetime.datetime.now():%Y%m%d%H%M%S}.csv"
+ # cls._sftp.put(buf, fname)
+ dest = DAILY_DIR / str(datetime.date.today()) / fname
+ dest.write_bytes(buf)
+ cls._citco_queue.clear()
+
+ def citco_stage(self):
+ self._citco_queue.append(self.to_citco())
+
+
@dataclass
class CDSDeal(
BbgDeal,
@@ -1295,6 +1329,7 @@ _citco_ratesource = {"SOFRRATE": 17819}
@dataclass
class IRSProduct(
+ CitcoDeal,
Deal,
deal_type=DealType.IRSProduct,
table_name="citco_irs",