File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const runExample = require ( '../util/run_example' )
3
+ const { args : { apiKey, apiSecret } , debug } = require ( '../util/setup' )
4
+ const WSv2 = require ( '../../lib/transports/ws2' )
4
5
5
- module . exports = runExample ( {
6
- name : 'ws2-order-books' ,
7
- ws : {
8
- env : true ,
9
- connect : true ,
6
+ async function execute ( ) {
7
+ const ws = new WSv2 ( {
8
+ apiKey,
9
+ apiSecret,
10
10
transform : true , // auto-transform array OBs to OrderBook objects
11
11
manageOrderBooks : true // tell the ws client to maintain full sorted OBs
12
- }
13
- } , async ( { ws, debug } ) => {
12
+ } )
13
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
14
+ await ws . open ( )
15
+
14
16
let lastMidPrice = - 1
15
17
let midPrice
16
18
@@ -29,4 +31,6 @@ module.exports = runExample({
29
31
} )
30
32
31
33
await ws . subscribeOrderBook ( 'tBTCUSD' )
32
- } )
34
+ }
35
+
36
+ execute ( )
You can’t perform that action at this time.
0 commit comments