aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/static/dawn.js
blob: fcf3687db03f1e40bb9656d1079adf52e07bae29 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var index_list = [];
var bbg_map = {'CDX': ["IG", "HY"], 'ITRX': ["EUR", "XOVER"]}
var series_map = {'CDX': ["23", "24", "25", "26", "27", "28", "29"],
                  'ITRX': ["22", "24", "25", "26", "27", "28"]};
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 < series_map[begin_index].length; j++){
            for(var k = 0; k<index_tenor.length; k++){
                index_list.push([begin_index, bbg_map[begin_index][i], 'CDSI',
                                 'S'+series_map[begin_index][j], index_tenor[k]].join(' '));
            }
        }
    }
};

$(function() {
    $('#security_desc').attr('list', 'index_list');
    $('#security_desc').change(function(){
        $.getJSON('../../_ajax', {bbg_id: $(this).val(),
                                  trade_date: $('#trade_date').val()}).
            done(function(data) {
                $('#fixed_rate').val(data['coupon']/100);
                $('#security_id').val(data['redcode']);
                $('#maturity').val(data['maturity']);
            });
    });
    $('#swap_type').change(function() {
        switch ($(this).val()) {
        case 'CD_INDEX_TRANCHE':
            $('#attach').parent().parent().css('display','block');
            $('#detach').parent().parent().css('display','block');
            $('#clearing_facility').val('');
            $('#initial_margin_percentage').parent().parent().css('display', 'block');
            break;
        case 'CD_INDEX':
            $('#attach').parent().parent().css('display', 'none');
            $('#detach').parent().parent().css('display', 'none');
            $('#initial_margin_percentage').parent().parent().css('display', 'none');
            $('#clearing_facility').val('ICE-CREDIT');
            break;
        case 'ABS_CDS':
            $('#attach').parent().parent().css('display', 'none');
            $('#detach').parent().parent().css('display', 'none');
            $('#initial_margin_percentage').parent().parent().css('display', 'block');
            $('#clearing_facility').val('');
            break;
        case 'CD_BASKET_TRANCHE':
            $('#attach').parent().parent().css('display','block');
            $('#detach').parent().parent().css('display','block');
            $('#initial_margin_percentage').parent().parent().css('display', 'block');
            $('#clearing_facility').val('');
            break;
        }
    });
    $('#swap_type').change();
    var datalist = $('#index_list');
    index_list.forEach(function(item) {
        var option = document.createElement('option');
        option.value = item;
        datalist.append(option);
    });
    //change default value to Following
    $('#payment_rolldate').val('Following');
    $('#upfront').attr('data-toggle', 'tooltip');
    $('#upfront').attr('title', 'This is Cash Amount on the bloomberg ticket, i.e. the net amount we receive.');
    $('#upfront').tooltip();
});