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 ( {
@@ -13,10 +14,16 @@ const o = new Order({
13
14
type : Order . type . EXCHANGE_LIMIT
14
15
} )
15
16
16
- module . exports = runExample ( {
17
- name : 'ws2-orders' ,
18
- ws : { env : true , connect : true , auth : true , transform : true }
19
- } , async ( { ws, debug } ) => {
17
+ async function execute ( ) {
18
+ const ws = new WSv2 ( {
19
+ apiKey,
20
+ apiSecret,
21
+ transform : true
22
+ } )
23
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
24
+ await ws . open ( )
25
+ await ws . auth ( )
26
+
20
27
let orderClosed = false
21
28
22
29
// Enable automatic updates
@@ -44,4 +51,7 @@ module.exports = runExample({
44
51
debug ( 'canceling...' )
45
52
await o . cancel ( )
46
53
debug ( 'got cancel confirmation for order %d' , o . cid )
47
- } )
54
+ await ws . close ( )
55
+ }
56
+
57
+ execute ( )
You can’t perform that action at this time.
0 commit comments