File tree 1 file changed +13
-18
lines changed
1 file changed +13
-18
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const _isEmpty = require ( 'lodash/isEmpty ' )
4
- const runExample = require ( '../util/run_example ' )
3
+ const { args : { apiKey , apiSecret } , debug } = require ( '../util/setup ' )
4
+ const WSv2 = require ( '../../lib/transports/ws2 ' )
5
5
6
- module . exports = runExample ( {
7
- name : 'ws2-trades' ,
8
- ws : {
9
- env : true ,
10
- connect : true ,
11
- keepOpen : true ,
6
+ async function execute ( ) {
7
+ const ws = new WSv2 ( {
8
+ apiKey,
9
+ apiSecret,
12
10
transform : true
13
- } ,
14
- params : {
15
- market : 'tBTCUSD'
16
- }
17
- } , async ( { ws, debug, params } ) => {
18
- const { market } = params
11
+ } )
12
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
13
+ await ws . open ( )
19
14
20
- if ( _isEmpty ( market ) ) {
21
- throw new Error ( 'market required' )
22
- }
15
+ const market = 'tBTCUSD'
23
16
24
17
if ( market [ 0 ] === 't' ) {
25
18
ws . onTradeEntry ( { symbol : market } , ( trade ) => {
@@ -36,4 +29,6 @@ module.exports = runExample({
36
29
} )
37
30
38
31
await ws . subscribeTrades ( market )
39
- } )
32
+ }
33
+
34
+ execute ( )
You can’t perform that action at this time.
0 commit comments