Created
May 20, 2020 17:02
-
-
Save maxgfr/a557864c520c46c16cce829e8f793a2d to your computer and use it in GitHub Desktop.
Example of node application using kraken websocket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws'); | |
const ws = new WebSocket('wss://ws.kraken.com'); | |
ws.on('open', function open() { | |
ws.send(JSON.stringify({ | |
"event": "subscribe", | |
"pair": [ | |
"BTC/USD", | |
"ETH/USD", | |
"XRP/USD" | |
], | |
"subscription": { | |
"name": "ticker" | |
} | |
})); | |
}); | |
ws.on('message', function incoming(data) { | |
var arr = JSON.parse(data) | |
if(arr[1]) { | |
console.log(new Date()) | |
console.log('for ' + arr[3]) | |
// console.log(arr[1]) | |
console.log('y a un mec qui prend à '+arr[1].a[0]) | |
console.log('y a un mec qui vend à '+arr[1].b[0]) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment