forked from BitMEX/api-connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
14 lines (13 loc) · 704 Bytes
/
example.js
File metadata and controls
14 lines (13 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'use strict';
const BitMEXClient = require('./index');
// See 'options' reference below
const client = new BitMEXClient({testnet: true});
// handle errors here. If no 'error' callback is attached. errors will crash the client.
client.on('error', console.error);
client.on('open', () => console.log('Connection opened.'));
client.on('close', () => console.log('Connection closed.'));
client.on('initialize', () => console.log('Client initialized, data is flowing.'));
client.addStream('XBTUSD', 'instrument', function(data, symbol, tableName) {
console.log(`Got update for ${tableName}:${symbol}. Current state:\n${JSON.stringify(data).slice(0, 100)}...`);
// Do something with the table data...
});