diff options
| -rw-r--r-- | risk_insight/insight.py (renamed from risk_insight/tranches_insight.py) | 35 | ||||
| -rw-r--r-- | risk_insight/templates/index.html | 38 | ||||
| -rw-r--r-- | risk_insight/templates/indices.html | 30 | ||||
| -rw-r--r-- | risk_insight/templates/tranches.html | 43 |
4 files changed, 105 insertions, 41 deletions
diff --git a/risk_insight/tranches_insight.py b/risk_insight/insight.py index 5ffb0383..37cb15ea 100644 --- a/risk_insight/tranches_insight.py +++ b/risk_insight/insight.py @@ -33,8 +33,8 @@ def close_connection(exception): if db is not None: db.close() -@app.route("/_data") -def get_risk_number(): +@app.route("/_data_tranches") +def get_risk_numbers(): index = request.args.get("i") series = request.args.get("s", 0, int) tenor = request.args.get("t") @@ -50,12 +50,37 @@ def get_risk_number(): return jsonify(labels=["Date"] + ["{0}-{1} {2}".format(l, u, greek) for l, u in zip(attach[:-1], attach[1:])], data=data) -@app.route("/") -def main(): +@app.route("/_data_indices") +def get_risk_numbers(): + index = request.args.get("i") + series = request.args.get("s", 0, int) + tenor = request.args.get("t") + data = [] + db = get_db() + attach = get_attach_from_name(index, series) + sqlstr = "SELECT date, closeprice, modelprice, adjcloseprice, adjmodelprice " \ + "from index_quotes WHERE index=%s and series=%s " \ + "and tenor=%s ORDER BY date" + with db.cursor() as c: + c.execute(sqlstr, (index.upper(), series, tenor)) + data = [["%s/%s/%s" % (date.year, date.month, date.day)] + val for date, val in c] + return jsonify(labels=["Date"] + ["{0}-{1} {2}".format(l, u, greek) for l, u in zip(attach[:-1], attach[1:])], + data=data) + +@app.route("/tranches.html") +def tranches(): with open(os.path.join(basedir, "code", "etc", "runs.yml")) as fh: runs = yaml.load(fh) series_list = sorted(list(set([int(name[2:]) for name in runs['name']]))) - return render_template("index.html", series=series_list) + return render_template("tranches.html", series=series_list) + +@app.route("/indices.html") +def indices(): + return render_template("indices.html") + +@app.route("/index.html") +def main(): + return render_template("index.html") if __name__ == "__main__": app.run(debug=True) diff --git a/risk_insight/templates/index.html b/risk_insight/templates/index.html index d91f2730..cde8d3dc 100644 --- a/risk_insight/templates/index.html +++ b/risk_insight/templates/index.html @@ -1,43 +1,9 @@ <!doctype html> <html> <head> -<script type="text/javascript" src="{{ url_for('static', filename='dygraph-combined.js') }}"></script> -<script type="text/javascript" src="{{ url_for('static', filename='jquery-2.1.1.min.js') }}"></script> </head> <body> - <div id="graph1" - style="width:800px; height:500px;float:left;margin:auto"> - </div> - <div id="graph2" - style="width:800px; height:500px;float:left;padding-left:5em"> - </div> - <div style="margin-top:5em;display:inline-block"> - <select id="index"> - <option value="ig">IG</option> - <option value="hy">HY</option> - </select> - <select id="series"> - {% for s in series %} - <option value="{{s}}">{{s}}</option> - {% endfor %} - </select> - <select id="tenor"> - <option value="3yr">3yr</option> - <option value="5yr">5yr</option> - <option value="7yr">7yr</option> - <option value="10yr">10yr</option> - </select> - <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="corr01">Corr01</option> - <option value="durations">Duration</option> - <option value="el">Expected Loss</option> - </select> - </div> -<script type="text/javascript" src="{{ url_for('static', filename='main.js') }}"></script> + <a href="tranches.html">Tranche Insights</a> + <a href="indices.html">Index Insights</a> </body> </html> diff --git a/risk_insight/templates/indices.html b/risk_insight/templates/indices.html new file mode 100644 index 00000000..aedfa799 --- /dev/null +++ b/risk_insight/templates/indices.html @@ -0,0 +1,30 @@ +<!doctype html> +<html> +<head> +<script type="text/javascript" src="{{ url_for('static', filename='dygraph-combined.js') }}"></script> +<script type="text/javascript" src="{{ url_for('static', filename='jquery-2.1.1.min.js') }}"></script> +</head> +<body> + <div id="graph1" + style="width:800px; height:500px;float:left;margin:auto"> + </div> + <div style="margin-top:5em;display:inline-block"> + <select id="index"> + <option value="ig">IG</option> + <option value="hy">HY</option> + </select> + <select id="series"> + {% for s in series %} + <option value="{{s}}">{{s}}</option> + {% endfor %} + </select> + <select id="tenor"> + <option value="3yr">3yr</option> + <option value="5yr">5yr</option> + <option value="7yr">7yr</option> + <option value="10yr">10yr</option> + </select> + </div> +<script type="text/javascript" src="{{ url_for('static', filename='main.js') }}"></script> +</body> +</html> diff --git a/risk_insight/templates/tranches.html b/risk_insight/templates/tranches.html new file mode 100644 index 00000000..d91f2730 --- /dev/null +++ b/risk_insight/templates/tranches.html @@ -0,0 +1,43 @@ +<!doctype html> +<html> +<head> +<script type="text/javascript" src="{{ url_for('static', filename='dygraph-combined.js') }}"></script> +<script type="text/javascript" src="{{ url_for('static', filename='jquery-2.1.1.min.js') }}"></script> +</head> +<body> + <div id="graph1" + style="width:800px; height:500px;float:left;margin:auto"> + </div> + <div id="graph2" + style="width:800px; height:500px;float:left;padding-left:5em"> + </div> + <div style="margin-top:5em;display:inline-block"> + <select id="index"> + <option value="ig">IG</option> + <option value="hy">HY</option> + </select> + <select id="series"> + {% for s in series %} + <option value="{{s}}">{{s}}</option> + {% endfor %} + </select> + <select id="tenor"> + <option value="3yr">3yr</option> + <option value="5yr">5yr</option> + <option value="7yr">7yr</option> + <option value="10yr">10yr</option> + </select> + <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="corr01">Corr01</option> + <option value="durations">Duration</option> + <option value="el">Expected Loss</option> + </select> + </div> +<script type="text/javascript" src="{{ url_for('static', filename='main.js') }}"></script> +</body> +</html> |
