diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/Dawn/views.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index c5b1f240..c6df3ed8 100644 --- a/python/Dawn/views.py +++ b/python/Dawn/views.py @@ -599,6 +599,7 @@ def edit_counterparty(cpcode): @app.route("/_ajax", methods=["GET"]) def get_bbg_id(): bbg_id = request.args.get("bbg_id") + trade_date = request.args.get("trade_date", datetime.date.today()) try: _, indextype, _, series, tenor = bbg_id.split() except ValueError: @@ -606,17 +607,14 @@ def get_bbg_id(): indextype = indextype[:2] tenor = tenor[:-1] + "yr" series = int(series[1:]) - sqlstr1 = "SELECT * FROM index_redcode(%s::index_type, %s::smallint, %s)" - sqlstr2 = ( - "SELECT maturity, coupon FROM index_maturity WHERE index=%s " - "and series=%s and tenor=%s" - ) + sql_str = ("SELECT redindexcode, maturity, coupon " + "FROM index_desc " + "WHERE index=%s and series=%s and tenor=%s " + " and lastdate >=%s ORDER BY version") db = get_db() with db.cursor() as c: - c.execute(sqlstr1, (indextype, series, datetime.date.today())) - (redcode,) = c.fetchone() - c.execute(sqlstr2, (indextype, series, tenor)) - maturity, coupon = c.fetchone() + c.execute(sql_str, (indextype, series, tenor, trade_date)) + redcode, maturity, coupon = c.fetchone() return jsonify( { "maturity": str(maturity), |
