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 2
2
3
3
const Promise = require ( 'bluebird' )
4
4
const { Order } = require ( 'bfx-api-node-models' )
5
- const runExample = require ( '../util/run_example' )
5
+ const { args : { apiKey, apiSecret } , debug } = require ( '../util/setup' )
6
+ const WSv2 = require ( '../../lib/transports/ws2' )
6
7
7
8
// Build new order
8
9
const o = new Order ( {
@@ -16,10 +17,16 @@ const o = new Order({
16
17
priceAuxLimit : 1000
17
18
} )
18
19
19
- module . exports = runExample ( {
20
- name : 'ws2-oco-order' ,
21
- ws : { env : true , connect : true , auth : true , transform : true }
22
- } , async ( { ws, debug } ) => {
20
+ async function execute ( ) {
21
+ const ws = new WSv2 ( {
22
+ apiKey,
23
+ apiSecret,
24
+ transform : true
25
+ } )
26
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
27
+ await ws . open ( )
28
+ await ws . auth ( )
29
+
23
30
o . registerListeners ( ws ) // enable automatic updates
24
31
25
32
let orderClosed = false
@@ -48,4 +55,7 @@ module.exports = runExample({
48
55
49
56
await o . cancel ( )
50
57
debug ( 'got cancel confirmation for order %d' , o . cid )
51
- } )
58
+ await ws . close ( )
59
+ }
60
+
61
+ execute ( )
You can’t perform that action at this time.
0 commit comments