Skip to content

Commit 5df2121

Browse files
author
Vitaliy Stoliarov
committed
update 'funding_info' example
1 parent 4aea70c commit 5df2121

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

examples/ws2/funding_info.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
'use strict'
22

3-
const runExample = require('../util/run_example')
3+
const { args: { apiKey, apiSecret }, debug } = require('../util/setup')
4+
const WSv2 = require('../../lib/transports/ws2')
45
const symbol = 'fUSD'
56

6-
module.exports = runExample({
7-
name: 'ws2-funding-info',
8-
ws: { env: true, connect: true, auth: true, transform: true }
9-
}, async ({ ws, debug }) => {
10-
ws.onFundingInfoUpdate({}, fiu => {
11-
fiu.forEach(fl => debug('fl: %j', fl.toJS()))
7+
async function execute () {
8+
const ws = new WSv2({
9+
apiKey,
10+
apiSecret,
11+
transform: true
12+
})
13+
ws.on('error', e => debug('WSv2 error: %s', e.message | e))
14+
await ws.open()
15+
await ws.auth()
16+
17+
ws.onFundingInfoUpdate({}, fi => {
18+
debug('fl: %j', fi.toJS())
19+
ws.close()
1220
})
1321

1422
ws.requestCalc([`funding_sym_${symbol}`])
15-
})
23+
}
24+
25+
execute()

0 commit comments

Comments
 (0)