Skip to content

Instantly share code, notes, and snippets.

@mviktordev
Last active December 20, 2017 01:13
Show Gist options
  • Save mviktordev/15a6de59e1b6187ff36ef5049b7816ae to your computer and use it in GitHub Desktop.
Save mviktordev/15a6de59e1b6187ff36ef5049b7816ae to your computer and use it in GitHub Desktop.
const symbols = [];
function quantify(data) {
for(const change of data) {
if (symbols.indexOf(change.symbol) < 0) {
symbols.push(change.symbol)
symbols.sort()
// console.log(change.symbol, symbols.join('\n'))
}
}
const normalized a = symbols.map(s => s.replace(/^\./, '')).sort()
const p1 = a.map(s => s.slice(0, 3))
const p2 = a.map(s => s.slice(3))
const object = p1.concat(p2).reduce((a, key) => void (isFinite(a[key]) ? (a[key] += 1) : (a[key] = 1)) || a, {})
const c = Object.keys(r).map(key => [r[key], key]).sort((a, b) => b[0] - a[0])
}
(new WebSocket('wss://www.bitmex.com/realtime?subscribe=instrument'))
.addEventListener('message', e => quantify(JSON.parse(e.data).data))
// quantify([".BCHXBT",".BCHXBT30M",".BVOL",".BVOL10M",".BVOL1H",".BVOL24H",".BVOL30M",".BVOL7D",".BXBT",".BXBT30M",".BXBTJPY",".BXBTJPY30M",".DASHXBT",".DASHXBT30M",".ETCXBT",".ETCXBT30M",".ETHBON",".ETHBON2H",".ETHBON8H",".ETHXBT",".ETHXBT30M",".EVOL7D",".JPYBON",".JPYBON2H",".JPYBON8H",".KRWBON",".KRWBON2H",".KRWBON8H",".LTCXBT",".LTCXBT30M",".USDBON",".USDBON2H",".USDBON8H",".XBT",".XBT30M",".XBTBON",".XBTBON2H",".XBTBON8H",".XBTJPY",".XBTJPY30M",".XBTJPYPI",".XBTJPYPI2H",".XBTJPYPI8H",".XBTKRW",".XBTKRW30M",".XBTKRWPI",".XBTKRWPI2H",".XBTKRWPI8H",".XBTUSDPI",".XBTUSDPI2H",".XBTUSDPI8H",".XMRXBT",".XMRXBT30M",".XRPXBT",".XRPXBT30M",".XTZXBT",".XTZXBT30M",".ZECXBT",".ZECXBT30M","BCHZ17","B_BLOCKSZ17","DASHH18","DASHZ17","ETC7D","ETHH18","ETHZ17","LTCH18","LTCZ17","XBJZ17","XBTH18","XBTUSD","XBTZ17","XMRH18","XMRZ17","XRPH18","XRPZ17","XTZZ17","ZECH18","ZECZ17"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment