aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/trade_dataclasses.py137
1 files changed, 69 insertions, 68 deletions
diff --git a/python/trade_dataclasses.py b/python/trade_dataclasses.py
index 8c1020a0..6895e14e 100644
--- a/python/trade_dataclasses.py
+++ b/python/trade_dataclasses.py
@@ -175,12 +175,7 @@ SwaptionStrat = Literal[
]
SpotStrat = Literal[
- 'M_STR_MAV',
- 'M_STR_MEZZ',
- 'SER_IRTXCURVE',
- 'M_CSH_CASH',
- 'TCSH',
- "*"
+ "M_STR_MAV", "M_STR_MEZZ", "SER_IRTXCURVE", "M_CSH_CASH", "TCSH", "*"
]
AssetClass = Literal["CSO", "Subprime", "CLO", "CRT"]
@@ -708,32 +703,33 @@ class SpotDeal(
insert_ignore=("id", "dealid"),
):
folder: SpotStrat
- spot_rate : float
- buy_currency : str
- buy_amount : float
- sell_currency : str
- sell_amount : float
- commission_currency : str
- commission : float
- fund : Fund
- cp_code : str
+ spot_rate: float
+ buy_currency: str
+ buy_amount: float
+ sell_currency: str
+ sell_amount: float
+ commission_currency: str
+ commission: float
+ fund: Fund
+ cp_code: str
id: int = field(default=None, metadata={"insert": False})
dealid: str = field(default=None, metadata={"insert": False})
- trade_date : datetime.date = field(
+ trade_date: datetime.date = field(
default_factory=datetime.date.today(),
)
- settle_date : datetime.date = field(
+ settle_date: datetime.date = field(
default_factory=datetime.date.today(),
)
+
@classmethod
def from_bbg_line(cls, line: dict):
- return cls(
- folder = 'TCSH',
- spot_rate = line['']
- )
+ return cls(folder="TCSH", spot_rate=line[""])
+
+
+_fx_cp = {"BAST": "BAMSNY", "MSST": "MSCSNY"}
+_fx_funds = {"serenitas": "SERCGMAST", "bowdst": "BOWDST"}
+
-_fx_cp = {'BAST': 'BAMSNY', 'MSST': 'MSCSNY'}
-_fx_funds = {'serenitas': 'SERCGMAST', 'bowdst': 'BOWDST'}
@dataclass
class FxswapDeal(
BbgDeal,
@@ -744,63 +740,68 @@ class FxswapDeal(
):
folder: str
portfolio: str
- trade_date : datetime.date
- near_settle_date : datetime.date
- near_buy_currency: str
+ trade_date: datetime.date
+ near_settle_date: datetime.date
+ near_buy_currency: str
near_buy_amount: float
near_sell_currency: str
- near_sell_amount: float
+ near_sell_amount: float
near_rate: float
- far_rate: float
+ far_rate: float
far_settle_date: datetime.date
far_buy_currency: str
far_buy_amount: float
far_sell_currency: str
far_sell_amount: str
- fund : Fund
- cp_code : str
- cash_account : str
+ fund: Fund
+ cp_code: str
+ cash_account: str
id: int = field(default=None, metadata={"insert": False})
dealid: str = field(default=None, metadata={"insert": False})
+
@classmethod
def from_bbg_line(cls, line: dict):
- if line['Side'] == 'S':
- near_buy_currency = line['Currency 1']
- near_buy_amount = line['Amount Dealt']
- near_sell_currency = line['Currency 2']
- near_sell_amount = line['Counter Amount']
- far_buy_currency = line['Currency 2']
- far_buy_amount = line['Far Counter Amount']
- far_sell_currency = line['Currency 1']
- far_sell_amount = line['Far Amount Dealt']
- elif line['Side'] == 'B':
- near_sell_currency = line['Currency 1']
- near_sell_amount = line['Amount Dealt']
- near_buy_currency = line['Currency 2']
- near_buy_amount = line['Counter Amount']
- far_sell_currency = line['Currency 2']
- far_sell_amount = line['Far Counter Amount']
- far_buy_currency = line['Currency 1']
- far_buy_amount = line['Far Amount Dealt']
+ if line["Side"] == "S":
+ near_buy_currency = line["Currency 1"]
+ near_buy_amount = line["Amount Dealt"]
+ near_sell_currency = line["Currency 2"]
+ near_sell_amount = line["Counter Amount"]
+ far_buy_currency = line["Currency 2"]
+ far_buy_amount = line["Far Counter Amount"]
+ far_sell_currency = line["Currency 1"]
+ far_sell_amount = line["Far Amount Dealt"]
+ elif line["Side"] == "B":
+ near_sell_currency = line["Currency 1"]
+ near_sell_amount = line["Amount Dealt"]
+ near_buy_currency = line["Currency 2"]
+ near_buy_amount = line["Counter Amount"]
+ far_sell_currency = line["Currency 2"]
+ far_sell_amount = line["Far Counter Amount"]
+ far_buy_currency = line["Currency 1"]
+ far_buy_amount = line["Far Amount Dealt"]
sql_line = [None if not value else value for value in list(line.values())]
cls._bbg_insert_queue.append(sql_line)
return cls(
- folder = '*',
- portfolio= 'UNALLOCATED',
- cp_code = _fx_cp[line['Counterparty Deal Code']],
- trade_date = datetime.datetime.strptime(line['Date Of Deal'], "%Y%m%d"),
- near_settle_date = datetime.datetime.strptime(line['Value Date Period 1 Currency 1'], "%Y%m%d"),
- far_settle_date = datetime.datetime.strptime(line['Value Date Period 2 Currency 1'], "%Y%m%d"),
- near_buy_currency = near_buy_currency,
- near_buy_amount = near_buy_amount,
- near_sell_currency = near_sell_currency,
- near_sell_amount = near_sell_amount,
- far_buy_currency = far_buy_currency,
- far_buy_amount = far_buy_amount,
- far_sell_currency = far_sell_currency,
- far_sell_amount = far_sell_amount,
- fund = _fx_funds[line['ALOC Account 1']],
- near_rate = line['Exchange Rate Period 1'],
- far_rate = line['Exchange Rate Period 2'],
- cash_account = 'V0NSCLMAMB',
- ) \ No newline at end of file
+ folder="*",
+ portfolio="UNALLOCATED",
+ cp_code=_fx_cp[line["Counterparty Deal Code"]],
+ trade_date=datetime.datetime.strptime(line["Date Of Deal"], "%Y%m%d"),
+ near_settle_date=datetime.datetime.strptime(
+ line["Value Date Period 1 Currency 1"], "%Y%m%d"
+ ),
+ far_settle_date=datetime.datetime.strptime(
+ line["Value Date Period 2 Currency 1"], "%Y%m%d"
+ ),
+ near_buy_currency=near_buy_currency,
+ near_buy_amount=near_buy_amount,
+ near_sell_currency=near_sell_currency,
+ near_sell_amount=near_sell_amount,
+ far_buy_currency=far_buy_currency,
+ far_buy_amount=far_buy_amount,
+ far_sell_currency=far_sell_currency,
+ far_sell_amount=far_sell_amount,
+ fund=_fx_funds[line["ALOC Account 1"]],
+ near_rate=line["Exchange Rate Period 1"],
+ far_rate=line["Exchange Rate Period 2"],
+ cash_account="V0NSCLMAMB",
+ )