diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/Dawn/views.py | 9 | ||||
| -rw-r--r-- | python/process_queue.py | 13 |
2 files changed, 15 insertions, 7 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index bf9c6b1d..a3b40ee6 100644 --- a/python/Dawn/views.py +++ b/python/Dawn/views.py @@ -399,10 +399,12 @@ def terminate(dealid, kind): {"dealid": dealid}, ) notional, terminated_amount, currency, globeop_id, cp_code = next(rec) + is_assignment = True if not termination.partial_termination: termination.termination_amount = notional - terminated_amount if termination.termination_cp is None: termination.termination_cp = cp_code + is_assignment = False session.add(termination) try: session.commit() @@ -410,7 +412,12 @@ def terminate(dealid, kind): app.logger.error(e) session.rollback() else: - buf = simple_serialize(termination, ccy=currency, globeopid=globeop_id) + buf = simple_serialize( + termination, + ccy=currency, + globeopid=globeop_id, + is_assignment=is_assignment, + ) q = get_queue() q.rpush(f"{kind}_termination", buf) return redirect(url_for("list_trades", kind=kind)) diff --git a/python/process_queue.py b/python/process_queue.py index 51427d17..1c3ca590 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -871,6 +871,7 @@ def build_termination( termination_cp=None, globeopid=None, partial_termination: bool = False, + is_assignment: bool = False, ccy: str = "USD", **kwargs, ): @@ -905,11 +906,11 @@ def build_termination( headers += ["Reserved"] * 3 headers += ["FeePaymentDate", "SpecialInstructions"] - if termination_cp is not None: + if is_assignment: headers += ["AssignedCounterparty"] else: headers += ["Reserved"] - if deal_type == "CreditDefaultSwapDeal" and termination_cp is not None: + if deal_type == "CreditDefaultSwapDeal" and is_assignment: headers += [ "AssignmentFee", "AssignedFeeTradeDate", @@ -930,16 +931,16 @@ def build_termination( if deal_type == "SwaptionDeal": headers += ["Reserved"] * 2 + ["InMoney", "FeeCurrency"] elif deal_type == "CreditDefaultSwapDeal": - if termination_cp is None: + if is_assignment: headers += ["Reserved"] * 3 else: headers += ["AssignedDealFunction"] + ["Reserved"] * 2 headers += ["InitialMargin", "InitialMarginCurrency"] - if termination_cp is None: + if not is_assignment: headers += ["Reserved"] * 4 + ["CreditEventOccured"] d = { "DealType": deal_type, - "GoTradeId": int(globeopid[3:9]), + "GoTradeId": int(globeopid[3:9]) if globeopid else None, "Action": "Update", "Client": "Serenitas", "SubAction": "Termination", @@ -952,7 +953,7 @@ def build_termination( } if "FeeCurrency" in headers: d["FeeCurrency"] = ccy - if termination_cp is not None: + if is_assignment: d["AssignedCounterparty"] = termination_cp buf = StringIO() csvwriter = csv.DictWriter(buf, headers) |
