File tree 1 file changed +15
-11
lines changed
1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const { Order } = require ( 'bfx-api-node-models' )
4
- const runExample = require ( '../util/run_example' )
4
+ const { args : { apiKey, apiSecret } , debug } = require ( '../util/setup' )
5
+ const WSv2 = require ( '../../lib/transports/ws2' )
5
6
6
7
const SYMBOL = 'tBTCUSD'
7
8
8
- module . exports = runExample ( {
9
- name : 'ws2-atomic-order-update' ,
10
- ws : {
11
- env : true ,
9
+ async function execute ( ) {
10
+ const ws = new WSv2 ( {
11
+ apiKey ,
12
+ apiSecret ,
12
13
transform : true ,
13
14
manageOrderBooks : true ,
14
15
15
16
packetWDDelay : 10 * 1000 ,
16
17
autoReconnect : true ,
17
- seqAudit : true ,
18
+ seqAudit : true
19
+ } )
20
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
21
+ await ws . open ( )
22
+ await ws . auth ( )
18
23
19
- connect : true ,
20
- auth : true
21
- }
22
- } , async ( { ws, debug } ) => {
23
24
const orderSent = false
24
25
25
26
await ws . subscribeOrderBook ( SYMBOL , 'P0' , '25' )
@@ -66,4 +67,7 @@ module.exports = runExample({
66
67
debug ( 'order updated, new price %f' , o . price )
67
68
} )
68
69
} )
69
- } )
70
+ await ws . close ( )
71
+ }
72
+
73
+ execute ( )
You can’t perform that action at this time.
0 commit comments