File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
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 o = new Order ( {
7
8
cid : Date . now ( ) ,
@@ -12,10 +13,16 @@ const o = new Order({
12
13
tif : '2019-03-08 15:00:00'
13
14
} )
14
15
15
- module . exports = runExample ( {
16
- name : 'ws2-order-tif' ,
17
- ws : { env : true , connect : true , auth : true , transform : true }
18
- } , async ( { ws, debug } ) => {
16
+ async function execute ( ) {
17
+ const ws = new WSv2 ( {
18
+ apiKey,
19
+ apiSecret,
20
+ transform : true
21
+ } )
22
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
23
+ await ws . open ( )
24
+ await ws . auth ( )
25
+
19
26
o . registerListeners ( ws )
20
27
21
28
o . on ( 'update' , ( ) => debug ( 'updated: %s' , o . toString ( ) ) )
@@ -28,4 +35,7 @@ module.exports = runExample({
28
35
'got submit confirmation for order %d [%d] [tif: %d]' ,
29
36
o . cid , o . id , o . mtsTIF
30
37
)
31
- } )
38
+ await ws . close ( )
39
+ }
40
+
41
+ execute ( )
You can’t perform that action at this time.
0 commit comments