var index_list = []; var bbg_map = {'CDX': ["IG", "HY"], 'ITRX': ["EUR", "XOVER"]}; var series_map = {'CDX': ["24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35"], 'ITRX': ["24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34"]}; var index_tenor = ["3Y", "5Y", "7Y", "10Y"]; for(var begin_index in bbg_map){ for(var index_type of bbg_map[begin_index]){ for(var series of series_map[begin_index]){ for(var tenor of index_tenor){ index_list.push(`${begin_index} ${index_type} CDSI S${series} ${tenor}`); } } } }; $(function() { $('#security_desc').attr('list', 'index_list'); var security_desc = document.getElementById('security_desc'); if (security_desc) { security_desc.addEventListener('change', (event) => { fetch(`../../_ajax?bbg_id=${encodeURIComponent(event.target.value)}&` + `trade_date=${$('#trade_date').val()}`) .then(data => data.json()) .then(data => { $('#fixed_rate').val(data['coupon']/100); $('#security_id').val(data['redcode']); $('#maturity').val(data['maturity']); }); if (event.target.value.startsWith("ITRX")) { $('#currency').val("EUR"); } else{ $('#currency').val("USD"); } }); } $('#folder').change(function() { if ($('#swap_type').val() == 'CD_INDEX') { switch ($(this).val()) { case 'IGOPTDEL': case 'HYOPTDEL': $('#portfolio').val('OPTIONS'); break; case 'SER_HYCURVE': case 'SER_ITRXCURVE': case 'SER_IGCURVE': case 'XCURVE': $('#portfolio').val('CURVE'); break; case 'HYEQY': case 'HYMEZ': case 'HYSNR': case 'IGEQY': case 'IGMEZ': case 'IGSNR': case 'XOEQY': case 'XOMEZ': case 'BSPK': $('#portfolio').val('TRANCHE'); $('#swap_type').val('CD_INDEX_TRANCHE'); $('#swap_type').change(); break; case 'HYINX': case 'IGINX': case 'XOINX': $('#portfolio').val('TRANCHE'); break; case 'HEDGE_CLO': $('#portfolio').val('CLO'); break; case 'HEDGE_MAC': $('#portfolio').val('HEDGE_MAC'); break; case 'HEDGE_CSO': $('#portfolio').val('STRUCTURED'); break; case 'HEDGE_MBS': case 'MBSCDS': $('#portfolio').val('MORTGAGES'); break; } } var strat = $(this).val(); if (strat.startsWith('CRT')) { $('#asset_class').val('CRT'); } else if (strat.includes('MTG')) { $('#asset_class').val('Subprime'); } else if (strat.includes('CLO')) { $('#asset_class').val('CLO'); } else { $('#asset_class').val('CSO'); } }); $('#swap_type').change(function() { var to_hide, to_show; const hide = (arr) => arr.forEach(id => { document.getElementById(id) .parentElement .parentElement .style.display = 'none'; }); const show = (arr) => arr.forEach(id => { document.getElementById(id) .parentElement .parentElement .style.display = 'block'; }); switch ($(this).val()) { case 'CD_BASKET_TRANCHE': case 'CD_INDEX_TRANCHE': case 'BESPOKE': show(['orig_attach', 'orig_detach', 'initial_margin_percentage', 'index_ref', 'corr_attach', 'corr_detach']); hide(['clearing_facility', 'account_code']); $('#clearing_facility').val(''); $('#portfolio').val('TRANCHE'); break; case 'CD_INDEX': hide(['orig_attach', 'orig_detach', 'initial_margin_percentage', 'index_ref', 'corr_attach', 'corr_detach']); show(['clearing_facility', 'account_code']); $('#clearing_facility').val('ICE-CREDIT'); $('#folder').change(); break; case 'ABS_CDS': hike(['orig_attach', 'orig_detach', 'index_ref', 'corr_attach', 'corr_detach', 'clearing_facility']); show(['initial_margin_percentage']); $('#clearing_facility').val(''); $('#portfolio').val('MORTGAGES'); break; case 'SWAPTION': hide(['fixed_rate', 'index_ref', 'security_desc']); $('#portfolio').val('IR'); $('#settlement_type').val('Cash'); break; case 'CD_INDEX_OPTION': show(['fixed_rate', 'index_ref', 'security_desc']); $('#portfolio').val('OPTIONS'); $('#settlement_type').val('Delivery'); break; } }); $('#partial_termination').change( function() { if( $(this).prop('checked') ) { $('#termination_amount').parent().parent().css('display', 'block'); } else { $('#termination_amount').val(''); $('#termination_amount').parent().parent().css('display', 'none'); } } ); $('#partial_termination').change(); $('#swap_type').change(); var datalist = $('#index_list'); index_list.forEach(item => { var option = document.createElement('option'); option.value = item; datalist.append(option); }); $('#fund').change( function() { if (window.location.pathname.includes('future') || window.location.pathname.includes('spot')) { return; } switch ($(this).val()) { case 'SERCGMAST': $('#custodian').val('BAC'); $('#cashaccount').val('V0NSCLMAMB'); break; case 'BOWDST': $('#custodian').val('BONY'); $('#cashaccount').val('BPMG10240000'); $('#account_code').val('GS'); break; case 'BRINKER': $('#custodian').val('BBH'); $('#cashaccount').val('4023461'); break; } }); $('#fund').change(); //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(); $('#spot_rate').attr('data-toggle', 'tooltip'); $('#spot_rate').attr('title', 'Spot rate must be entered with pairs ordered by dominance. EUR > GBP > USD > CAD > CHF > YEN'); $('#spot_rate').tooltip(); });