Last active
September 17, 2018 02:37
-
-
Save qrpike/19742081e35b60c850363276c01c26e1 to your computer and use it in GitHub Desktop.
This file contains 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://socket.polygon.io/forex') | |
// Connection Opened: | |
ws.on('open', () => { | |
ws.send(`{"action":"auth","params":"APIKEY"}`) | |
ws.send(`{"action":"subscribe","params":"C.AUD/USD,C.USD/EUR,C.USD/JPY"}`) | |
}) | |
// Per message packet: | |
ws.on('message', ( data ) => { | |
(JSON.parse( data )).map(( msg ) => { | |
if( msg.ev === 'status' ) | |
return console.log('Status Update:', msg.message) | |
console.log('Tick:', msg) | |
}) | |
}) | |
ws.on('error', console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment