File tree 1 file changed +12
-9
lines changed
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const { args : { apiKey, apiSecret } , debug } = require ( '../util/setup' )
3
4
const WSv2 = require ( '../../lib/transports/ws2' )
4
- const runExample = require ( '../util/run_example' )
5
5
6
6
const SYMBOL = 'tXRPBTC'
7
7
const PRECISION = 'P0'
8
8
const LENGTH = '25'
9
9
10
- module . exports = runExample ( {
11
- name : 'ws2-ob-checksum' ,
12
- ws : {
13
- env : true ,
14
- connect : true ,
10
+ async function execute ( ) {
11
+ const ws = new WSv2 ( {
12
+ apiKey,
13
+ apiSecret,
15
14
transform : true ,
16
15
manageOrderbooks : true // managed OBs are verified against incoming checksums
17
- }
18
- } , async ( { ws, debug } ) => {
16
+ } )
17
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
18
+ await ws . open ( )
19
+
19
20
ws . onOrderBookChecksum ( {
20
21
symbol : SYMBOL ,
21
22
prec : PRECISION ,
@@ -26,4 +27,6 @@ module.exports = runExample({
26
27
27
28
await ws . enableFlag ( WSv2 . flags . CHECKSUM )
28
29
await ws . subscribeOrderBook ( SYMBOL , PRECISION , LENGTH )
29
- } )
30
+ }
31
+
32
+ execute ( )
You can’t perform that action at this time.
0 commit comments