Skip to content

Commit f7a936c

Browse files
author
Vitaliy Stoliarov
committed
uodate 'ob_checksum' example
1 parent 5368154 commit f7a936c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

examples/ws2/ob_checksum.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
'use strict'
22

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

66
const SYMBOL = 'tXRPBTC'
77
const PRECISION = 'P0'
88
const LENGTH = '25'
99

10-
module.exports = runExample({
11-
name: 'ws2-ob-checksum',
12-
ws: {
13-
env: true,
14-
connect: true,
10+
async function execute () {
11+
const ws = new WSv2({
12+
apiKey,
13+
apiSecret,
1514
transform: true,
1615
manageOrderbooks: true // managed OBs are verified against incoming checksums
17-
}
18-
}, async ({ ws, debug }) => {
16+
})
17+
ws.on('error', e => debug('WSv2 error: %s', e.message | e))
18+
await ws.open()
19+
1920
ws.onOrderBookChecksum({
2021
symbol: SYMBOL,
2122
prec: PRECISION,
@@ -26,4 +27,6 @@ module.exports = runExample({
2627

2728
await ws.enableFlag(WSv2.flags.CHECKSUM)
2829
await ws.subscribeOrderBook(SYMBOL, PRECISION, LENGTH)
29-
})
30+
}
31+
32+
execute()

0 commit comments

Comments
 (0)