aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops/sma.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops/sma.py')
-rw-r--r--python/report_ops/sma.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/python/report_ops/sma.py b/python/report_ops/sma.py
index e982f069..9a3bf77a 100644
--- a/python/report_ops/sma.py
+++ b/python/report_ops/sma.py
@@ -12,27 +12,24 @@ from typing import ClassVar
@dataclass
class SMA:
date: datetime.date
- fund: str
+ fund: ClassVar[str]
+ _conn: ClassVar = dbconn("dawndb")
_em: ClassVar = ExchangeMessage()
def __init_subclass__(cls, fund):
cls.fund = fund
- def __init__(self, date):
- self.date = date
-
def get_positions(self):
- dawndb = dbconn("dawndb")
df_blotter = pd.read_sql_query(
"SELECT * FROM risk_positions(%s, NULL, %s)",
- dawndb,
+ self._conn,
params=(self.date, self.fund),
index_col=["identifier"],
)
cds_positions = pd.read_sql_query(
"SELECT * FROM list_cds_marks_pre(%s, NULL, %s)",
- dawndb,
+ self._conn,
params=(self.date, self.fund),
index_col=["security_id"],
)
@@ -42,7 +39,7 @@ class SMA:
"accrued, cp_code, cpty_id from list_cds(%s, %s) a "
"LEFT JOIN tranche_risk ON id=tranche_id AND date=%s "
"WHERE orig_attach IS NOT NULL",
- dawndb,
+ self._conn,
params=(self.date, self.fund, self.date),
index_col=["id"],
)