aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/static/dawn.js
blob: 87fce916fc1e87ba69fb9ea9a2aa379508eff6da (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var index_list = [];
var bbg_map = {'CDX': ["IG", "HY"], 'ITRX': ["EUR", "XOVER"]}
var index_series = ["21", "23", "24", "25"];
var index_tenor = ["3Y", "5Y", "7Y", "10Y"];
for(var begin_index in bbg_map){
    for(var i=0; i<bbg_map[begin_index].length; i++){
        for(var j=0; j<index_series.length; j++){
            for(var k = 0; k<index_tenor.length; k++){
                index_list.push([begin_index, bbg_map[begin_index][i], 'CDSI',
                                 'S'+index_series[j], index_tenor[k]].join(' '));
            }
        }
    }
};

function callback(data) {
    data = JSON.parse(data);
    $('fixed_rate').value=data['coupon']/100;
    $('security_id').value=data['redcode'];
    $('maturity').value=data['maturity'];
    console.log(data);
};

var datalist = $('index_list');
index_list.forEach(function(item){
    var option = document.createElement('option');
    option.value = item;
    datalist.appendChild(option);
});

document.addEventListener("DOMContentLoaded", function(){
    $('swap_type').addEventListener('change',
                                    function(){
                                        if(this.value=='CD_INDEX_TRANCHE'){
                                            $('attach').parentNode.parentNode.style.display='block';
                                            $('detach').parentNode.parentNode.style.display='block';
                                        }else{
                                            $('attach').parentNode.parentNode.style.display='none';
                                            $('detach').parentNode.parentNode.style.display='none';
                                        }
                                    });
    $('security_desc').setAttribute('list', 'index_list');
    $('security_desc').addEventListener('change', function(){
        query('../_ajax', {bbg_id: this.value}, callback);
    });
    var event = new Event('change');
    $('swap_type').dispatchEvent(event);
})