diff options
Diffstat (limited to 'python/Dawn')
| -rw-r--r-- | python/Dawn/views.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index 63ddce28..c33e12f2 100644 --- a/python/Dawn/views.py +++ b/python/Dawn/views.py @@ -483,18 +483,21 @@ def list_trades(kind): else: Orig_cp = aliased(Counterparties) Term_cp = aliased(Counterparties) - if kind not in ["swaption", "cds"]: + if kind not in ["swaption"]: trade_list = Deal.query.order_by(Deal.trade_date.desc(), Deal.id.desc()) else: trade_list = ( - Deal.query.join(Orig_cp, Deal.counterparty) - .join(Term_cp, Deal.termination_counterparty) + Deal.query.join(Orig_cp, Deal.counterparty, isouter=True) + .join(Term_cp, Deal.termination_counterparty, isouter=True) .with_entities( Deal.id, Deal.dealid, func.coalesce(Deal.termination_date, Deal.trade_date).label( "trade_date" ), + (func.coalesce(Deal.termination_date, Deal.settle_date)).label( + "settle_date" + ), Deal.notional, Deal.option_type, Deal.expiration_date, @@ -513,7 +516,7 @@ def list_trades(kind): ], else_=Deal.termination_fee, ) - * case([(Deal.buysell, 1.0)], else_=-1.0) + * case([(Deal.buysell, -1.0)], else_=1.0) ).label("fee"), Deal.security_desc, Deal.security_id, @@ -528,9 +531,9 @@ def list_trades(kind): ).label("trade_type"), Deal.folder, ) - .order_by(Deal.trade_date.desc()) .order_by( - func.coalesce(Deal.termination_date, Deal.trade_date), Deal.dealid + func.coalesce(Deal.termination_date, Deal.trade_date).desc(), + Deal.dealid, ) ) return render_template(f"{kind}_blotter.html", trades=trade_list) |
