aboutsummaryrefslogtreecommitdiffstats
path: root/tranches_insight/tranches_insight.py
blob: 1e08a09aeb19df842604a14799ce742422ae3017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)