Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit 230661d

Browse files
author
Jon Eyrick
authored
WebSocket Ticker Example
1 parent 54fe1e8 commit 230661d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

examples/websocket-ticker.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const Binance = require( 'node-binance-api' );
2+
const binance = new Binance();
3+
global.ticker = {};
4+
5+
// Show contents of BNBUSDT ticker object once per second
6+
setInterval( () => {
7+
if ( !global.ticker.BNBUSDT ) return;
8+
console.log( global.ticker.BNBUSDT );
9+
console.log( `BNB ask: ${global.ticker.BNBUSDT.bestAsk} bid: ${global.ticker.BNBUSDT.bestBid}` );
10+
}, 1000 );
11+
12+
// Get 24h price change statistics for all symbols
13+
binance.websockets.prevDay( false, function ( error, obj ) {
14+
global.ticker[obj.symbol] = obj;
15+
} );

0 commit comments

Comments
 (0)