aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn')
-rw-r--r--python/Dawn/templates/cds_blotter.html4
-rw-r--r--python/Dawn/views.py72
2 files changed, 50 insertions, 26 deletions
diff --git a/python/Dawn/templates/cds_blotter.html b/python/Dawn/templates/cds_blotter.html
index c114db8d..72470fed 100644
--- a/python/Dawn/templates/cds_blotter.html
+++ b/python/Dawn/templates/cds_blotter.html
@@ -14,6 +14,7 @@
<td>Attach</td>
<td>Detach</td>
<td>Counterparty</td>
+ <td>Trade Type</td>
<td>Strategy</td>
</tr>
</thead>
@@ -30,7 +31,8 @@
<td>{{trade.orig_attach if trade.attach is not none}}</td>
<td>{{trade.orig_detach if trade.detach is not none}}</td>
<td><a href="{{url_for('edit_counterparty',
- cpcode=trade.counterparty.code)}}">{{trade.counterparty.name}}</a></td>
+ cpcode=trade.cp_code)}}">{{trade.name}}</a></td>
+ <td>{{trade.trade_type}}</td>
<td>{{trade.folder}}</td>
</tr>
{% endfor %}
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index c33e12f2..983e7ca9 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -483,7 +483,7 @@ def list_trades(kind):
else:
Orig_cp = aliased(Counterparties)
Term_cp = aliased(Counterparties)
- if kind not in ["swaption"]:
+ if kind not in ["cds", "swaption"]:
trade_list = Deal.query.order_by(Deal.trade_date.desc(), Deal.id.desc())
else:
trade_list = (
@@ -495,33 +495,11 @@ def list_trades(kind):
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,
- Deal.strike,
- case(
- [(Deal.termination_cp.is_(None), Deal.buysell)],
- else_=~Deal.buysell,
- ).label("buysell"),
- (
- case(
- [
- (
- Deal.termination_cp.is_(None),
- Deal.notional * Deal.price / 100,
- )
- ],
- else_=Deal.termination_fee,
- )
- * case([(Deal.buysell, -1.0)], else_=1.0)
- ).label("fee"),
Deal.security_desc,
Deal.security_id,
- func.coalesce(Orig_cp.code, Term_cp.code).label("cp_code"),
- func.coalesce(Orig_cp.name, Term_cp.name).label("name"),
+ func.coalesce(Term_cp.code, Orig_cp.code).label("cp_code"),
+ func.coalesce(Term_cp.name, Orig_cp.name).label("name"),
case(
[
(Deal.termination_cp.is_(None), "New"),
@@ -536,6 +514,50 @@ def list_trades(kind):
Deal.dealid,
)
)
+ if kind == "swaption":
+ trade_list = trade_list.add_columns(
+ case(
+ [(Deal.termination_cp.is_(None), Deal.settle_date)], else_=None
+ ).label("settle_date"),
+ Deal.option_type,
+ Deal.expiration_date,
+ Deal.strike,
+ case(
+ [(Deal.termination_cp.is_(None), Deal.buysell)], else_=~Deal.buysell
+ ).label("buysell"),
+ (
+ case(
+ [
+ (
+ Deal.termination_cp.is_(None),
+ Deal.notional
+ * Deal.price
+ / 100
+ * (2 * Deal.buysell.cast(db.Integer) - 1.0),
+ )
+ ],
+ else_=-Deal.termination_fee,
+ )
+ ).label("fee"),
+ )
+ elif kind == "cds":
+ trade_list = trade_list.add_columns(
+ case(
+ [(Deal.termination_cp.is_(None), Deal.protection.cast(db.String))],
+ else_=case([(Deal.protection == "Buyer", "Seller")], else_="Buyer"),
+ ).label("protection"),
+ Deal.orig_attach,
+ Deal.orig_detach,
+ Deal.attach,
+ Deal.detach,
+ (
+ case(
+ [(Deal.termination_cp.is_(None), Deal.upfront)],
+ else_=-Deal.termination_fee,
+ )
+ ).label("upfront"),
+ Deal.ref,
+ )
return render_template(f"{kind}_blotter.html", trades=trade_list)