diff options
Diffstat (limited to 'python/ops')
| -rw-r--r-- | python/ops/funds.py | 12 | ||||
| -rw-r--r-- | python/ops/process_queue.py | 19 |
2 files changed, 17 insertions, 14 deletions
diff --git a/python/ops/funds.py b/python/ops/funds.py index bf8ab290..1b06ec35 100644 --- a/python/ops/funds.py +++ b/python/ops/funds.py @@ -67,13 +67,14 @@ class Fund: "iam": "IamDeal", "trs": "TRSDeal", "irs": "IRSDeal", - "mtm": cls.product_type.capitalize(), } - trade_tag: str - if isinstance(trade_type, tuple): - trade_tag = d[trade_type[0]] + trade_type[1] + if cls is MTM: + trade_tag = "TRN" if trade_type == "cds" else "CDISW" else: - trade_tag = d[trade_type] + if isinstance(trade_type, tuple): + trade_tag = d[trade_type[0]] + trade_type[1] + else: + trade_tag = d[trade_type] timestamp = datetime.datetime.now() return ( @@ -149,7 +150,6 @@ class Selene(Fund, fund_name="ISOSEL"): class MTM(Fund, fund_name="MTM"): filepath_pattern = "MTM.{timestamp:%Y%m%d.%H%M%S}.{trade_tag}.csv" - product_type: str @classmethod def set_headers(cls, trade_type): diff --git a/python/ops/process_queue.py b/python/ops/process_queue.py index 17c81892..2b1f82c2 100644 --- a/python/ops/process_queue.py +++ b/python/ops/process_queue.py @@ -54,7 +54,7 @@ def process_indicative( process_fun = globals().get( f"{trade_type}_trade_process", lambda conn, session, trade: trade ) - mtm = Fund["MTM"]() + mtm = Fund["MTM"] for trade in get_trades(p, trade_type): process_fun(conn, session, trade) fund = trade["fund"] @@ -68,8 +68,10 @@ def process_indicative( "BESPOKE", ): mtm.stage(trade, trade_type=trade_type) - buf, dest = mtm.build_buffer(trade_type) - mtm.upload(buf, dest.name) + if mtm.staging_queue: + buf, dest = mtm.build_buffer(trade_type) + mtm.upload(buf, dest.name) + mtm.staging_queue.clear() p.delete(trade_type) @@ -86,6 +88,7 @@ def process_upload( buf, dest = fund.build_buffer(trade_type) if upload: fund.upload(buf, dest.name) + fund.staging_queue.clear() p.delete(key) @@ -97,16 +100,16 @@ def terminate_list( base_dir: pathlib.Path = DAILY_DIR, ): trade_type, fund, _ = key.split("_") - mtm = Fund["MTM"]() + mtm = Fund["MTM"] f = Fund[fund]() for term in p.lrange(key, 0, -1): obj = DealKind["termination"].from_dict(**loads(term)) mtm.staging_queue.append(obj.to_markit()) f.staging_queue.append(obj.to_globeop()) - # pretty crappy way, but there should be only one - mtm.product_type = obj.product_type - buf, dest = mtm.build_buffer("mtm") - mtm.upload(buf, dest.name) + if mtm.staging_queue: + buf, dest = mtm.build_buffer(trade_type) + mtm.upload(buf, dest.name) + mtm.staging_queue.clear() if upload and f.staging_queue: buf, dest = f.build_buffer((trade_type, "A")) f.upload(buf, dest.name) |
