bfx-api-node-ws1 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
package/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ # 2.0.0
2
+ - Require Node.js >= 22
3
+ - meta: bump ws to 7.5.13, bfx-api-node-util to 2.0.0, lodash to 4.18.1
4
+ - meta: drop debug, unused bluebird and chai
5
+ - meta: remove docs/, jsdoc-to-markdown and Travis config
6
+ - Tests: migrate from mocha to brittle, lint with @bitfinex/lint-js
7
+
1
8
  # 1.0.3
2
9
  - fix: use relative paths to allow generic mocha execution
3
10
  - feature: add isOpen() method
package/LICENSE.md CHANGED
File without changes
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Bitfinex WSv1 Reference Implementation for Node.JS
2
2
 
3
- [![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-ws1.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-ws1)
4
-
5
3
  This repo contains the reference implementation for version 1 of the websocket Bitfinex API. It is deprecated in favour of version 2, and should no longer be used.
6
4
 
7
5
  For the version 2 API library, see [bitfinex-api-node](https://github.com/bitfinexcom/bitfinex-api-node)
@@ -34,10 +32,6 @@ ws.on('trades', (pair, trade) => {
34
32
  })
35
33
  ```
36
34
 
37
- ### Docs
38
-
39
- For JSDoc-generated API documentation, [see `docs/ws1.md`](/docs/ws1.md)
40
-
41
35
  ### Contributing
42
36
 
43
37
  1. Fork it
package/index.js CHANGED
File without changes
package/lib/ws.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { EventEmitter } = require('events')
4
4
  const { isSnapshot, genAuthSig } = require('bfx-api-node-util')
5
- const debug = require('debug')('bfx:api:ws1')
5
+ const debug = require('util').debuglog('bfx:api:ws1')
6
6
  const _isArray = require('lodash/isArray')
7
7
  const WebSocket = require('ws')
8
8
 
@@ -32,7 +32,7 @@ class WSv1 extends EventEmitter {
32
32
  * @return {boolean} open
33
33
  */
34
34
  isOpen () {
35
- return this._ws.isOpen()
35
+ return !!this._ws && this._ws.readyState === WebSocket.OPEN
36
36
  }
37
37
 
38
38
  /**
@@ -291,10 +291,27 @@ class WSv1 extends EventEmitter {
291
291
  * @param {*} msg
292
292
  */
293
293
  send (msg) {
294
- debug('Sending %j', msg)
294
+ debug('Sending %j', this._redact(msg))
295
295
  this._ws.send(JSON.stringify(msg))
296
296
  }
297
297
 
298
+ /**
299
+ * Returns a copy of the packet that is safe to log: the api key is masked
300
+ * to a short prefix and the auth signature is hidden.
301
+ *
302
+ * @param {object} msg
303
+ * @returns {object} safe
304
+ * @private
305
+ */
306
+ _redact (msg) {
307
+ const safe = { ...msg }
308
+
309
+ if (safe.apiKey) safe.apiKey = `${safe.apiKey.slice(0, 5)}***`
310
+ if (safe.authSig) safe.authSig = '***'
311
+
312
+ return safe
313
+ }
314
+
298
315
  /**
299
316
  * Subscribe to order book updates. Snapshot will be sent as multiple updates.
300
317
  * Event will be emited as `PAIRNAME_book`.
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "bfx-api-node-ws1",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "Legacy WSv1 transport for the Bitfinex Node API",
5
5
  "engines": {
6
- "node": ">=7"
6
+ "node": ">=22.0.0"
7
7
  },
8
8
  "main": "index.js",
9
9
  "scripts": {
10
- "lint": "standard",
11
- "test": "npm run lint && npm run unit",
12
- "unit": "NODE_ENV=test mocha -b --recursive",
13
- "docs": "npm run ws1_docs",
14
- "ws1_docs": "node_modules/jsdoc-to-markdown/bin/cli.js lib/ws.js > docs/ws1_docs.md"
10
+ "lint": "bfx-lint-js .",
11
+ "lint:fix": "bfx-lint-js . --fix",
12
+ "test": "npm run lint && npm run test:unit",
13
+ "test:unit": "NODE_ENV=test brittle-node --bail 'test/**/*.js'"
15
14
  },
16
15
  "repository": {
17
16
  "type": "git",
@@ -36,17 +35,12 @@
36
35
  "url": "https://github.com/bitfinexcom/bfx-api-node-ws1/issues"
37
36
  },
38
37
  "devDependencies": {
39
- "babel-eslint": "^10.0.3",
40
- "chai": "^4.2.0",
41
- "jsdoc-to-markdown": "^5.0.1",
42
- "mocha": "^6.2.0",
43
- "standard": "^14.1.0"
38
+ "@bitfinex/lint-js": "^1.1.0",
39
+ "brittle": "^4.5.0"
44
40
  },
45
41
  "dependencies": {
46
- "bfx-api-node-util": "^1.0.2",
47
- "bluebird": "^3.5.5",
48
- "debug": "^4.1.1",
49
- "lodash": "^4.17.15",
50
- "ws": "^3.0.0"
42
+ "bfx-api-node-util": "^2.0.0",
43
+ "lodash": "^4.18.1",
44
+ "ws": "7.5.13"
51
45
  }
52
46
  }
File without changes
@@ -1,7 +1,6 @@
1
- /* eslint-env mocha */
2
1
  'use strict'
3
2
 
4
- const assert = require('assert')
3
+ const test = require('brittle')
5
4
  const BfxWs = require('../../lib/ws')
6
5
 
7
6
  const bfxWs = new BfxWs({
@@ -9,41 +8,44 @@ const bfxWs = new BfxWs({
9
8
  apiSecret: 'dummy'
10
9
  })
11
10
 
12
- describe('ws1 channel msg handling', () => {
13
- it('ws1 transforms & normalizes well - R0 update', (done) => {
11
+ test('ws1 channel msg handling', async (t) => {
12
+ await t.test('ws1 transforms & normalizes well - R0 update', (t) => {
13
+ t.plan(1)
14
+
14
15
  bfxWs._channelMap = {
15
16
  32755: { channel: 'book', prec: 'R0', symbol: 'tBTCUSD' }
16
17
  }
17
18
 
18
19
  bfxWs.once('orderbook', (symbol, data) => {
19
- assert.deepStrictEqual(data, { price: 2477.1, orderId: 2919111002, amount: 0.0125 })
20
- done()
20
+ t.alike(data, { price: 2477.1, orderId: 2919111002, amount: 0.0125 })
21
21
  })
22
22
 
23
23
  bfxWs._handleChannel([32755, 2919111002, 2477.1, 0.0125])
24
24
  })
25
25
 
26
- it('ws1 transforms & normalizes well - P1 update', (done) => {
26
+ await t.test('ws1 transforms & normalizes well - P1 update', (t) => {
27
+ t.plan(1)
28
+
27
29
  bfxWs._channelMap = {
28
30
  182: { channel: 'book', prec: 'P1', symbol: 'tBTCUSD' }
29
31
  }
30
32
 
31
33
  bfxWs.once('orderbook', (symbol, data) => {
32
- assert.deepStrictEqual(data, { price: 2494, count: 2, amount: 5.9895 })
33
- done()
34
+ t.alike(data, { price: 2494, count: 2, amount: 5.9895 })
34
35
  })
35
36
 
36
37
  bfxWs._handleChannel([182, 2494, 2, 5.9895])
37
38
  })
38
39
 
39
- it('ws1 transforms & normalizes well - P1 snap', (done) => {
40
+ await t.test('ws1 transforms & normalizes well - P1 snap', (t) => {
41
+ t.plan(1)
42
+
40
43
  bfxWs._channelMap = {
41
44
  39: { channel: 'book', prec: 'P1', symbol: 'tBTCUSD' }
42
45
  }
43
46
 
44
47
  bfxWs.once('orderbook', (symbol, data) => {
45
- assert.deepStrictEqual(data[1], { price: 2494, count: 3, amount: 0.14606853 })
46
- done()
48
+ t.alike(data[1], { price: 2494, count: 3, amount: 0.14606853 })
47
49
  })
48
50
 
49
51
  const snap = [39, [
@@ -55,17 +57,18 @@ describe('ws1 channel msg handling', () => {
55
57
  bfxWs._handleChannel(snap)
56
58
  })
57
59
 
58
- it('ws1 transforms & normalizes well - R0 snap', (done) => {
60
+ await t.test('ws1 transforms & normalizes well - R0 snap', (t) => {
61
+ t.plan(1)
62
+
59
63
  bfxWs._channelMap = {
60
64
  34513: { channel: 'book', prec: 'R0', symbol: 'tBTCUSD' }
61
65
  }
62
66
 
63
67
  bfxWs.once('orderbook', (symbol, data) => {
64
- assert.deepStrictEqual(
68
+ t.alike(
65
69
  data[1],
66
70
  { price: 2494.5, orderId: 2919279471, amount: 0.07288 }
67
71
  )
68
- done()
69
72
  })
70
73
 
71
74
  const snap = [34513, [
@@ -76,8 +79,4 @@ describe('ws1 channel msg handling', () => {
76
79
 
77
80
  bfxWs._handleChannel(snap)
78
81
  })
79
-
80
- it('ws1 _handleChannel ignores heartbeats')
81
- it('ws1 _processUserEvent emits data, breaks up snapshots')
82
- it('ws1 _processTradeEvent emits a single trade for te & tu messages')
83
82
  })
@@ -1,20 +1,19 @@
1
- /* eslint-env mocha */
2
1
  'use strict'
3
2
 
4
3
  const PORT = 1337
5
4
 
6
- const assert = require('assert')
5
+ const test = require('brittle')
7
6
  const WebSocket = require('ws')
8
7
  const WSv1 = require('../../lib/ws')
9
8
 
10
- describe('websocket1 parsing non json', () => {
9
+ test('websocket1 parsing non json', async (t) => {
11
10
  let ws = null
12
11
  let wss = null
13
12
 
14
- afterEach(async () => {
13
+ const teardown = async () => {
15
14
  try { // may fail due to being modified by a test, it's not a problem
16
15
  if (ws && ws.isOpen()) {
17
- await new Promise(resolve => ws.close(resolve))
16
+ ws.close()
18
17
  }
19
18
  } catch (e) {}
20
19
 
@@ -25,9 +24,12 @@ describe('websocket1 parsing non json', () => {
25
24
  }
26
25
 
27
26
  wss = null
28
- })
27
+ }
28
+
29
+ await t.test('should not crash the client', (t) => {
30
+ t.teardown(teardown)
31
+ t.plan(1)
29
32
 
30
- it('should not crash the client', (done) => {
31
33
  ws = new WSv1({
32
34
  apiKey: 'dummy',
33
35
  apiSecret: 'dummy',
@@ -44,8 +46,7 @@ describe('websocket1 parsing non json', () => {
44
46
  wss.on('connection', function connection (ws) {
45
47
  ws.on('message', function incoming (msg) {
46
48
  msg = JSON.parse(msg)
47
- assert.strictEqual(msg.len, '25')
48
- done()
49
+ t.is(msg.len, '25')
49
50
  })
50
51
 
51
52
  ws.send("HTTP Code 408 - I'm a Tea Pot")
@@ -1,7 +1,6 @@
1
- /* eslint-env mocha */
2
1
  'use strict'
3
2
 
4
- const assert = require('assert')
3
+ const test = require('brittle')
5
4
  const WebSocket = require('ws')
6
5
  const _isObject = require('lodash/isObject')
7
6
 
@@ -16,11 +15,12 @@ const getWSInstance = (args) => (
16
15
  })
17
16
  )
18
17
 
19
- describe('WebSocket v1 integration', () => {
18
+ test('WebSocket v1 integration', async (t) => {
20
19
  let ws = null
21
20
  let wss = null
22
21
 
23
- afterEach(async () => {
22
+ const opts = { timeout: 10 * 1000 }
23
+ const teardown = async () => {
24
24
  try { // may fail due to being modified by a test, it's not a problem
25
25
  if (ws && ws.isOpen()) {
26
26
  ws.close()
@@ -34,9 +34,12 @@ describe('WebSocket v1 integration', () => {
34
34
  }
35
35
 
36
36
  wss = null
37
- })
37
+ }
38
+
39
+ await t.test('plays ping pong', opts, (t) => {
40
+ t.teardown(teardown)
41
+ t.plan(1)
38
42
 
39
- it('plays ping pong', (done) => {
40
43
  wss = new WebSocket.Server({
41
44
  perMessageDeflate: false,
42
45
  port: PORT
@@ -50,11 +53,14 @@ describe('WebSocket v1 integration', () => {
50
53
  })
51
54
 
52
55
  ws.on('open', () => ws.send({ event: 'ping' }))
53
- ws.on('pong', () => done())
56
+ ws.on('pong', () => t.pass())
54
57
  ws.open()
55
58
  })
56
59
 
57
- it('should receive info message', (done) => {
60
+ await t.test('should receive info message', opts, (t) => {
61
+ t.teardown(teardown)
62
+ t.plan(4)
63
+
58
64
  wss = new WebSocket.Server({
59
65
  perMessageDeflate: false,
60
66
  port: PORT
@@ -73,17 +79,19 @@ describe('WebSocket v1 integration', () => {
73
79
  })
74
80
 
75
81
  ws.on('info', (data) => {
76
- assert(_isObject(data.platform))
77
- assert.strictEqual(data.event, 'info')
78
- assert.strictEqual(data.version, 1.1)
79
- assert.strictEqual(data.platform.status, 1)
80
- done()
82
+ t.ok(_isObject(data.platform))
83
+ t.is(data.event, 'info')
84
+ t.is(data.version, 1.1)
85
+ t.is(data.platform.status, 1)
81
86
  })
82
87
 
83
88
  ws.open()
84
89
  })
85
90
 
86
- it('should emit an error when authorization fails', (done) => {
91
+ await t.test('should emit an error when authorization fails', opts, (t) => {
92
+ t.teardown(teardown)
93
+ t.plan(1)
94
+
87
95
  wss = new WebSocket.Server({
88
96
  perMessageDeflate: false,
89
97
  port: PORT
@@ -98,15 +106,17 @@ describe('WebSocket v1 integration', () => {
98
106
  })
99
107
 
100
108
  ws.on('error', (err) => {
101
- assert.strictEqual(err.event, 'auth')
102
- done()
109
+ t.is(err.event, 'auth')
103
110
  })
104
111
 
105
112
  ws.on('open', ws.auth.bind(ws))
106
113
  ws.open()
107
114
  })
108
115
 
109
- it('should unsubscribe by channelId', (done) => {
116
+ await t.test('should unsubscribe by channelId', opts, (t) => {
117
+ t.teardown(teardown)
118
+ t.plan(2)
119
+
110
120
  wss = new WebSocket.Server({
111
121
  perMessageDeflate: false,
112
122
  port: PORT
@@ -130,9 +140,8 @@ describe('WebSocket v1 integration', () => {
130
140
  const channelId = data.chanId
131
141
 
132
142
  ws.once('unsubscribed', (data) => {
133
- assert.strictEqual(data.status, 'OK')
134
- assert.strictEqual(data.chanId, channelId)
135
- done()
143
+ t.is(data.status, 'OK')
144
+ t.is(data.chanId, channelId)
136
145
  })
137
146
 
138
147
  ws.unsubscribe(channelId)
@@ -142,7 +151,10 @@ describe('WebSocket v1 integration', () => {
142
151
  ws.open()
143
152
  })
144
153
 
145
- it('should receive a subscribed success messages', (done) => {
154
+ await t.test('should receive a subscribed success messages', opts, (t) => {
155
+ t.teardown(teardown)
156
+ t.plan(2)
157
+
146
158
  wss = new WebSocket.Server({
147
159
  perMessageDeflate: false,
148
160
  port: PORT
@@ -156,16 +168,18 @@ describe('WebSocket v1 integration', () => {
156
168
  })
157
169
 
158
170
  ws.on('subscribed', (data) => {
159
- assert.strictEqual(data.channel, 'trades')
160
- assert.strictEqual(data.pair, 'BTCUSD')
161
- done()
171
+ t.is(data.channel, 'trades')
172
+ t.is(data.pair, 'BTCUSD')
162
173
  })
163
174
 
164
175
  ws.on('open', () => ws.subscribeTrades('BTCUSD'))
165
176
  ws.open()
166
177
  })
167
178
 
168
- it('#orderBook data should have the defined fields', (done) => {
179
+ await t.test('#orderBook data should have the defined fields', opts, (t) => {
180
+ t.teardown(teardown)
181
+ t.plan(5)
182
+
169
183
  wss = new WebSocket.Server({
170
184
  perMessageDeflate: false,
171
185
  port: PORT
@@ -189,19 +203,21 @@ describe('WebSocket v1 integration', () => {
189
203
 
190
204
  ws = getWSInstance({ transform: true })
191
205
  ws.once('orderbook', (pair, data) => {
192
- assert.strictEqual(pair, 'BTCUSD')
193
- assert.strictEqual(typeof data[0].price, 'number')
194
- assert.strictEqual(typeof data[0].orderId, 'number')
195
- assert.strictEqual(typeof data[0].amount, 'number')
196
- assert.strictEqual(data.length, 50)
197
- done()
206
+ t.is(pair, 'BTCUSD')
207
+ t.is(typeof data[0].price, 'number')
208
+ t.is(typeof data[0].orderId, 'number')
209
+ t.is(typeof data[0].amount, 'number')
210
+ t.is(data.length, 50)
198
211
  })
199
212
 
200
213
  ws.on('open', () => ws.subscribeOrderBook('BTCUSD'))
201
214
  ws.open()
202
- }).timeout(10 * 1000)
215
+ })
216
+
217
+ await t.test('#ticker data should have the defined fields', opts, (t) => {
218
+ t.teardown(teardown)
219
+ t.plan(11)
203
220
 
204
- it('#ticker data should have the defined fields', (done) => {
205
221
  wss = new WebSocket.Server({
206
222
  perMessageDeflate: false,
207
223
  port: PORT
@@ -218,25 +234,27 @@ describe('WebSocket v1 integration', () => {
218
234
  ws = getWSInstance()
219
235
 
220
236
  ws.once('ticker', (pair, data) => {
221
- assert.strictEqual(pair, 'BTCUSD')
222
- assert.strictEqual(typeof data.bid, 'number')
223
- assert.strictEqual(typeof data.bidSize, 'number')
224
- assert.strictEqual(typeof data.ask, 'number')
225
- assert.strictEqual(typeof data.askSize, 'number')
226
- assert.strictEqual(typeof data.dailyChange, 'number')
227
- assert.strictEqual(typeof data.dailyChangePerc, 'number')
228
- assert.strictEqual(typeof data.lastPrice, 'number')
229
- assert.strictEqual(typeof data.volume, 'number')
230
- assert.strictEqual(typeof data.high, 'number')
231
- assert.strictEqual(typeof data.low, 'number')
232
- done()
237
+ t.is(pair, 'BTCUSD')
238
+ t.is(typeof data.bid, 'number')
239
+ t.is(typeof data.bidSize, 'number')
240
+ t.is(typeof data.ask, 'number')
241
+ t.is(typeof data.askSize, 'number')
242
+ t.is(typeof data.dailyChange, 'number')
243
+ t.is(typeof data.dailyChangePerc, 'number')
244
+ t.is(typeof data.lastPrice, 'number')
245
+ t.is(typeof data.volume, 'number')
246
+ t.is(typeof data.high, 'number')
247
+ t.is(typeof data.low, 'number')
233
248
  })
234
249
 
235
250
  ws.on('open', () => ws.subscribeTicker('BTCUSD'))
236
251
  ws.open()
237
252
  })
238
253
 
239
- it('#trade data should have the defined fields', (done) => {
254
+ await t.test('#trade data should have the defined fields', opts, (t) => {
255
+ t.teardown(teardown)
256
+ t.plan(4)
257
+
240
258
  wss = new WebSocket.Server({
241
259
  perMessageDeflate: false,
242
260
  port: PORT
@@ -269,14 +287,13 @@ describe('WebSocket v1 integration', () => {
269
287
  ws = getWSInstance()
270
288
 
271
289
  ws.once('trade', (pair, data) => {
272
- assert.strictEqual(pair, 'BTCUSD')
273
- assert.strictEqual(typeof data[0].timestamp, 'number')
274
- assert.strictEqual(typeof data[0].price, 'number')
275
- assert.strictEqual(typeof data[0].amount, 'number')
276
- done()
290
+ t.is(pair, 'BTCUSD')
291
+ t.is(typeof data[0].timestamp, 'number')
292
+ t.is(typeof data[0].price, 'number')
293
+ t.is(typeof data[0].amount, 'number')
277
294
  })
278
295
 
279
296
  ws.on('open', () => ws.subscribeTrades('BTCUSD'))
280
297
  ws.open()
281
298
  })
282
- }).timeout(10 * 1000)
299
+ })
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "standard"
3
- }
package/.eslintrc.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "parser": "babel-eslint",
3
- "extends": [
4
- "standard"
5
- ],
6
- "rules": {
7
- "jsx-quotes": ["error", "prefer-single"],
8
- "semi": [1, "never"],
9
- "max-len": 0,
10
- "import/no-named-as-default": 0,
11
- "import/no-named-as-default-member": 0
12
- },
13
- "settings": {
14
- "import/resolver": {
15
- "node": {
16
- "moduleDirectory": [
17
- "node_modules",
18
- "lib"
19
- ]
20
- }
21
- }
22
- },
23
- "env": {
24
- "jest": true
25
- }
26
- }
package/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- sudo: false
2
-
3
- language: node_js
4
- node_js:
5
- - "stable"
6
-
7
- install:
8
- - npm install
9
-
10
- script:
11
- - npm run lint
12
- - npm run unit
package/docs/.keep DELETED
File without changes
package/docs/ws1_docs.md DELETED
@@ -1,114 +0,0 @@
1
- <a name="WSv1"></a>
2
-
3
- ## WSv1
4
- Communicates with v1 of the Bitfinex WebSocket API
5
-
6
- **Kind**: global class
7
-
8
- * [WSv1](#WSv1)
9
- * [new WSv1()](#new_WSv1_new)
10
- * [.open()](#WSv1+open)
11
- * [.close()](#WSv1+close)
12
- * [.send(msg)](#WSv1+send)
13
- * [.subscribeOrderBook(pair, precision, length)](#WSv1+subscribeOrderBook)
14
- * [.subscribeTrades(pair)](#WSv1+subscribeTrades)
15
- * [.subscribeTicker(pair)](#WSv1+subscribeTicker)
16
- * [.unsubscribe(chanId)](#WSv1+unsubscribe)
17
- * [.auth()](#WSv1+auth)
18
-
19
- <a name="new_WSv1_new"></a>
20
-
21
- ### new WSv1()
22
-
23
- | Param | Type | Description |
24
- | --- | --- | --- |
25
- | opts.apiKey | <code>sting</code> | |
26
- | opts.apiSecret | <code>string</code> | |
27
- | opts.url | <code>string</code> | ws connection url |
28
-
29
- <a name="WSv1+open"></a>
30
-
31
- ### wSv1.open()
32
- Opens a new websocket conection to the configured URL
33
-
34
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
35
- <a name="WSv1+close"></a>
36
-
37
- ### wSv1.close()
38
- Close the websocket connection
39
-
40
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
41
- <a name="WSv1+send"></a>
42
-
43
- ### wSv1.send(msg)
44
- Send a packet via the ws connection; automatically converted to a JSON
45
- string.
46
-
47
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
48
-
49
- | Param | Type |
50
- | --- | --- |
51
- | msg | <code>\*</code> |
52
-
53
- <a name="WSv1+subscribeOrderBook"></a>
54
-
55
- ### wSv1.subscribeOrderBook(pair, precision, length)
56
- Subscribe to order book updates. Snapshot will be sent as multiple updates.
57
- Event will be emited as `PAIRNAME_book`.
58
-
59
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
60
- **See**: http://docs.bitfinex.com/#order-books
61
-
62
- | Param | Type | Default | Description |
63
- | --- | --- | --- | --- |
64
- | pair | <code>string</code> | <code>&quot;BTCUSD&quot;</code> | |
65
- | precision | <code>string</code> | | price aggregation level (P0 (def), P1, P2, P3) |
66
- | length | <code>string</code> | | number of price points. 25 (default) or 100. |
67
-
68
- <a name="WSv1+subscribeTrades"></a>
69
-
70
- ### wSv1.subscribeTrades(pair)
71
- Subscribe to trades. Snapshot will be sent as multiple updates.
72
- Event will be emited as `PAIRNAME_trades`.
73
-
74
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
75
- **See**: http://docs.bitfinex.com/#trades75
76
-
77
- | Param | Type | Default |
78
- | --- | --- | --- |
79
- | pair | <code>string</code> | <code>&quot;BTCUSD&quot;</code> |
80
-
81
- <a name="WSv1+subscribeTicker"></a>
82
-
83
- ### wSv1.subscribeTicker(pair)
84
- Subscribe to ticker updates. The ticker is a high level overview of the
85
- state of the market. It shows you the current best bid and ask, as well as
86
- the last trade price.
87
-
88
- Event will be emited as `PAIRNAME_ticker`.
89
-
90
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
91
- **See**: http://docs.bitfinex.com/#ticker76
92
-
93
- | Param | Type | Default | Description |
94
- | --- | --- | --- | --- |
95
- | pair | <code>string</code> | <code>&quot;BTCUSD&quot;</code> | pair |
96
-
97
- <a name="WSv1+unsubscribe"></a>
98
-
99
- ### wSv1.unsubscribe(chanId)
100
- Unsubscribe from a channel.
101
-
102
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
103
-
104
- | Param | Type | Description |
105
- | --- | --- | --- |
106
- | chanId | <code>number</code> | ID of the channel received on `subscribed` event |
107
-
108
- <a name="WSv1+auth"></a>
109
-
110
- ### wSv1.auth()
111
- Authenticate the user. Will receive executed traded updates.
112
-
113
- **Kind**: instance method of [<code>WSv1</code>](#WSv1)
114
- **See**: http://docs.bitfinex.com/#wallet-updates