- KRW
const ws = new WebSocket("wss://your-gateway.example.com/stream?symbol=BTC-KRW"); // 서버는 {bids:[[price,qty],...], asks:[[price,qty],...], last:164994000, trades:[{p,q,t,side},...]} 형식 송신 ws.onmessage = (e)=>{ const {bids, asks, last, trades} = JSON.parse(e.data); document.getElementById('lastPrice').textContent = last.toLocaleString(); renderSide('.bids', bids, 'bid'); renderSide('.asks', asks, 'ask'); renderTrades(trades); }; function renderSide(sel, rows, cls){ const el = document.querySelector(sel); el.innerHTML = rows.slice(0,15).map(([p,q])=>`
${Number(p).toLocaleString()} ${q}
`).join(''); } function renderTrades(tr){ const el = document.getElementById('trades'); el.innerHTML = tr.slice(0,40).map(x=>`
${x.p.toLocaleString()} ${x.q}${new Date(x.t).toLocaleTimeString()}
`).join(''); }