diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/risk_insight/static/tranches.js | 2 | ||||
| -rw-r--r-- | python/risk_insight/templates/tranches.html | 12 | ||||
| -rw-r--r-- | python/risk_insight/views.py | 20 |
3 files changed, 20 insertions, 14 deletions
diff --git a/python/risk_insight/static/tranches.js b/python/risk_insight/static/tranches.js index 10f40eaa..f9404edf 100644 --- a/python/risk_insight/static/tranches.js +++ b/python/risk_insight/static/tranches.js @@ -4,7 +4,7 @@ function update_graph(g) { t: $('tenor').value, g: $('greek').value}; if( g.maindiv_.id == "graph1"){ - payload['g'] = "skew"; + payload['g'] = "corr_at_detach"; } query("_data_tranches", payload, function(data){ diff --git a/python/risk_insight/templates/tranches.html b/python/risk_insight/templates/tranches.html index b6c88d3c..608da3d0 100644 --- a/python/risk_insight/templates/tranches.html +++ b/python/risk_insight/templates/tranches.html @@ -28,13 +28,13 @@ <div class="select-box2"> <select id="greek"> <option value="Dealer Deltas">Dealer Delta</option> - <option value="Model Deltas">Model Delta</option> - <option value="Forward Deltas">Forward Delta</option> - <option value="gammas">Gamma</option> - <option value="thetas">Theta</option> + <option value="delta">Model Delta</option> + <option value="forward_delta">Forward Delta</option> + <option value="gamma">Gamma</option> + <option value="theta">Theta</option> <option value="corr01">Corr01</option> - <option value="durations">Duration</option> - <option value="el">Expected Loss</option> + <option value="duration">Duration</option> + <option value="EL">Expected Loss</option> </select> </div> <script type="text/javascript" src="{{ url_for('static', filename='utils.js') }}"></script> diff --git a/python/risk_insight/views.py b/python/risk_insight/views.py index 216da1eb..93c8906b 100644 --- a/python/risk_insight/views.py +++ b/python/risk_insight/views.py @@ -1,8 +1,12 @@ -from risk_insight import app -from flask import render_template, jsonify, request, g -import os, csv, yaml +import csv import datetime +import os import psycopg2 +import yaml + +from risk_insight import app +from flask import render_template, jsonify, request, g +from psycopg2 import sql def get_attach_from_name(index_type, series): if index_type.lower() == "ig": @@ -41,14 +45,16 @@ def get_risk_numbers(): series = request.args.get("s", 0, int) tenor = request.args.get("t") greek = request.args.get("g") - data = [] db = get_db() attach = get_attach_from_name(index, series) - sqlstr = "SELECT to_char(date, 'YYYY/MM/DD'), \"{0}\" from risk_numbers " \ - "WHERE index=%s and series=%s and tenor=%s ORDER BY date".format(greek) + sqlstr = (sql.SQL("SELECT to_char(date, 'YYYY/MM/DD'), array_agg({}) FROM " \ + "(SELECT date, {} FROM risk_numbers_new " \ + "WHERE index=%s AND series=%s AND tenor=%s ORDER BY attach) "\ + "AS a GROUP BY date ORDER BY date"). + format(sql.Identifier(greek), sql.Identifier(greek))) with db.cursor() as c: c.execute(sqlstr, (index.upper(), series, tenor)) - data = [[val[0]]+val[1] for val in c] + data = [[date] + arr for date, arr in c] return jsonify(labels=["Date"] + ["{0}-{1} {2}".format(l, u, greek) for l, u in zip(attach[:-1], attach[1:])], data=data) |
