aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/Dawn/views.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 366a14cb..707c5999 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -23,6 +23,7 @@ from .models import (
CCY,
BondDeal,
CDSDeal,
+ FUND,
SwaptionDeal,
FutureDeal,
CashFlowDeal,
@@ -34,6 +35,8 @@ from .models import (
)
from sqlalchemy.exc import IntegrityError
+from sqlalchemy.sql import text
+from sqlalchemy.sql.expression import func
from wtforms.fields import BooleanField
from .utils import bump_rev, simple_serialize
@@ -495,12 +498,20 @@ def list_trades(kind, fund):
app.logger.error(e)
abort(404)
else:
- if kind not in ["cds", "swaption"]:
+ if kind not in ("cds", "swaption"):
trade_list = Deal.query.order_by(Deal.trade_date.desc(), Deal.id.desc())
if fund is not None:
- trade_list = trade_list.filter(Deal.fund == fund)
+ trade_list = trade_list.filter(
+ Deal.fund == func.cast(func.upper(fund), FUND)
+ )
else:
- trade_list = db.session.execute(f"SELECT * FROM {kind}_trades")
+ if fund is not None:
+ sql_str = text(
+ f"SELECT * FROM {kind}_trades WHERE fund=UPPER(:fund)::fund"
+ )
+ trade_list = db.session.execute(sql_str, {"fund": fund})
+ else:
+ trade_list = db.session.execute(f"SELECT * FROM {kind}_trades")
return render_template(f"{kind}_blotter.html", trades=trade_list)