File tree 1 file changed +17
-12
lines changed
1 file changed +17
-12
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 oA = new Order ( {
7
8
symbol : 'tBTCUSD' ,
@@ -17,16 +18,16 @@ const oB = new Order({
17
18
type : 'EXCHANGE LIMIT'
18
19
} )
19
20
20
- module . exports = runExample ( {
21
- name : 'ws2-oc-multi' ,
22
- ws : {
23
- env : true ,
24
- connect : true ,
25
- auth : true ,
26
- transform : true ,
27
- keepOpen : true
28
- }
29
- } , async ( { ws , debug } ) => {
21
+ async function execute ( ) {
22
+ const ws = new WSv2 ( {
23
+ apiKey ,
24
+ apiSecret ,
25
+ transform : true
26
+ } )
27
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
28
+ await ws . open ( )
29
+ await ws . auth ( )
30
+
30
31
oA . registerListeners ( ws )
31
32
oB . registerListeners ( ws )
32
33
@@ -58,4 +59,8 @@ module.exports = runExample({
58
59
} ] )
59
60
60
61
debug ( 'sent oc_multi for orders A & B' )
61
- } )
62
+
63
+ await ws . close ( )
64
+ }
65
+
66
+ execute ( )
You can’t perform that action at this time.
0 commit comments