//환율API - 수시로 출력되지 않을 수 있음 var exchangeDataUrl = 'https://quotation-api-cdn.dunamu.com/v1/forex/recent?codes=FRX.KRWUSD'; var exchange = 1; //코인베이스 var coinbaseData; var coinbaseDataUrl = 'https://api.pro.coinbase.com/products/'+currancy.toUpperCase()+'-USD/ticker'; var coinbaseStats; var coinbaseStatsUrl = 'https://api.pro.coinbase.com/products/'+currancy.toUpperCase()+'-USD/stats'; //업비트(한국프리미엄 적용하기 위함) var upbitData; var upbitDataUrl = 'https://api.upbit.com/v1/ticker?markets=KRW-'+currancy.toUpperCase(); //거래소 링크 변경 jQuery('#coinbase_link_light').attr('href','https://pro.coinbase.com/trade/'+currancy.toUpperCase()+'-USD'); jQuery.when( jQuery.getJSON(exchangeDataUrl, function(data) { exchangeData = data; }), jQuery.getJSON(coinbaseDataUrl, function(data) { coinbaseData = data; }), jQuery.getJSON(coinbaseStatsUrl, function(data) { coinbaseStats = data; }), jQuery.getJSON(upbitDataUrl, function(data) { upbitData = data; }) ).then(function() { if(exchangeData){ exchange = exchangeData[0]['basePrice']; jQuery('#exchange_coinbase').number(exchange,2); } if (coinbaseData) { var coin_company = 'coinbase_light'; var closing_price = coinbaseData['price']*exchange; var closing_price_usd = coinbaseData['price']; var prev_closing_price = coinbaseStats['open']*exchange; var variation_price = closing_price - prev_closing_price; var variation_rate = parseFloat((closing_price-prev_closing_price)/prev_closing_price*100); if (upbitData) { var upbit_closing_price = upbitData[0]['trade_price']; var korean_premium = upbit_closing_price - closing_price; } else { var korean_premium = 0; } var min_price = coinbaseData['low']*exchange; var max_price = coinbaseData['high']*exchange; var traded_volume = coinbaseData['volume']; var price_unit = ''; if(!closing_price) jQuery('#'+coin_company+'_closing_price').number(0); if(!closing_price_usd) jQuery('#'+coin_company+'_closing_price_usd').number(0); if(!variation_price) jQuery('#'+coin_company+'_variation_price').number(0); if(!variation_rate) jQuery('#'+coin_company+'_variation_rate').number(0); if(!min_price) jQuery('#'+coin_company+'_min_price').number(0); if(!max_price) jQuery('#'+coin_company+'_max_price').number(0); if(!traded_volume) jQuery('#'+coin_company+'_traded_volume').number(0); jQuery('#'+coin_company+'_closing_price_area').removeClass(); jQuery('#'+coin_company+'_closing_price_usd_area').removeClass(); jQuery('#'+coin_company+'_variation_price_area').removeClass(); jQuery('#'+coin_company+'_variation_price_mark').html(''); jQuery('#'+coin_company+'_variation_rate_area').removeClass(); jQuery('#'+coin_company+'_variation_rate_mark').html(''); jQuery('#'+coin_company+'_korean_premium_mark').html(''); if(variation_price>0){ jQuery('#'+coin_company+'_closing_price_area').addClass('up'); jQuery('#'+coin_company+'_closing_price_usd_area').addClass('up'); jQuery('#'+coin_company+'_variation_price_area').addClass('up'); jQuery('#'+coin_company+'_variation_price_mark').html('+'); jQuery('#'+coin_company+'_variation_rate_area').addClass('up'); jQuery('#'+coin_company+'_variation_rate_mark').html('+'); } else if(variation_price<0){ jQuery('#'+coin_company+'_closing_price_area').addClass('down'); jQuery('#'+coin_company+'_closing_price_usd_area').addClass('down'); jQuery('#'+coin_company+'_variation_price_area').addClass('down'); //jQuery('#'+coin_company+'_variation_price_mark').html('-'); jQuery('#'+coin_company+'_variation_rate_area').addClass('down'); //jQuery('#'+coin_company+'_variation_rate_mark').html('-'); } jQuery('#'+coin_company+'_closing_price').number(closing_price); jQuery('#'+coin_company+'_closing_price_usd').number(closing_price_usd,2); if(variation_price!='-'){ jQuery('#'+coin_company+'_variation_price').number(variation_price); jQuery('#'+coin_company+'_variation_rate').number(variation_rate,2); } else { jQuery('#'+coin_company+'_variation_price').html('-'); jQuery('#'+coin_company+'_variation_rate').html('-'); jQuery('#'+coin_company+'_variation_rate_unit').hide(); } jQuery('#'+coin_company+'_min_price').number(min_price); jQuery('#'+coin_company+'_max_price').number(max_price); jQuery('#'+coin_company+'_traded_volume').number(traded_volume,4); if(korean_premium>0){ jQuery('#'+coin_company+'_korean_premium_mark').html('+'); } else if(korean_premium<0){ jQuery('#'+coin_company+'_korean_premium_mark').html('+'); } jQuery('#'+coin_company+'_korean_premium').number(korean_premium); } });