aboutsummaryrefslogtreecommitdiffstats
path: root/tranches_insight/tranches_insight.py
diff options
context:
space:
mode:
Diffstat (limited to 'tranches_insight/tranches_insight.py')
-rw-r--r--tranches_insight/tranches_insight.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tranches_insight/tranches_insight.py b/tranches_insight/tranches_insight.py
new file mode 100644
index 00000000..1e08a09a
--- /dev/null
+++ b/tranches_insight/tranches_insight.py
@@ -0,0 +1,24 @@
+from flask import Flask, render_template, jsonify, request
+import os, csv
+app = Flask(__name__)
+
+@app.route("/_data")
+def get_corr():
+ index = request.args.get("i")
+ series = request.args.get("s")
+ tenor = request.args.get("t")
+ basedir = "/home/share/CorpCDOs/Tranche_Data/Runs/"
+ data = []
+ with open(os.path.join(basedir, "{0}{1}.{2}.csv".format(index, series, tenor))) as fh:
+ csvreader = csv.DictReader(fh)
+ for line in csvreader:
+ data.append([line["date"], float(line['3 Corr']), float(line['7 Corr']),
+ float(line['10 Corr']), float(line['15 Corr'])])
+ return jsonify(data=data)
+
+@app.route("/")
+def main():
+ return render_template("index.html", labels=["Date", "3 Corr", "7 Corr", "10 Corr", "15 Corr"])
+
+if __name__ == "__main__":
+ app.run(debug=True)