Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Added book ticker to BinanceClient. #324

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
92a57b7
Merge pull request #1 from karimhossenbux/master
jargote May 11, 2021
15afe1f
Ignoring vscode history
jargote May 11, 2021
83e2727
Defined BookTicker class for representing an orderbook ticker event
jargote May 11, 2021
008c904
Added generic functions for subscribing to orderbook ticker in basic …
jargote May 11, 2021
e98d31a
Implementing concrete subscribe and unsubscribe functions for binance…
jargote May 11, 2021
6845ef1
Added bookTicker enum value
jargote May 12, 2021
ed27d5b
Marking ws alive when bookTicker events are received
jargote May 12, 2021
514c1ba
Removed non-existent property
jargote May 12, 2021
0360fd9
resubscribe to bookTicker on reconnection
jargote May 12, 2021
16aa412
Added handlers for bookTicker on MultiClient
jargote May 12, 2021
d2f1e77
Better matching of bookTicker stream messages
jargote May 12, 2021
9e9e15d
Overriding _onConnected for binance client to limit to maximum 5 subs…
jargote May 23, 2021
3c8d2f6
Generalised throttled subscriptions
jargote May 23, 2021
c72adf6
Bug fix
jargote May 23, 2021
b1c4b35
Not clearing subscription map on closing
jargote May 23, 2021
ccbbeea
Fixes to binance _onConnected handler
jargote May 23, 2021
f862669
Batching subscriptions for ticker and orderbook. [WIP] Adding support…
jargote Aug 2, 2021
94bf23d
Fixed @bookTicker and !bookTicker streams
jargote Aug 3, 2021
53bf940
Connect client after initialization
jargote Apr 15, 2022
0f32581
Bumping version
jargote Apr 15, 2022
5f12ae8
Added yarn lock
jargote Apr 15, 2022
0171094
Merge branch 'master' of https://github.com/altangent/ccxws into develop
jargote Apr 18, 2022
0157a1e
Added BookTicker to TS ccxws version
jargote Apr 18, 2022
81b3e41
fixes
jargote Apr 18, 2022
ae32aa6
ts fixes
jargote Apr 18, 2022
58d962f
Batching Binance subscriptions/unsubscriptions
jargote Apr 19, 2022
a012a26
Removing left-over .js files
jargote Apr 19, 2022
293724f
Removing .js files
jargote Apr 19, 2022
f24fdee
Do not output declarations
jargote Jun 23, 2022
3ef7408
Added ping - pong envents to SmartWSS to avoid disconnections
jargote Jul 3, 2022
aa37287
Adding timestamp to ws messages. Using timestamp on BookTicker
jargote Oct 3, 2022
760872c
Fixing syntax error
jargote Oct 3, 2022
c05f8c1
Checking for null message
jargote Oct 3, 2022
4e5a017
Replaced timestamp for hrtime
jargote Nov 5, 2022
123f508
Added hrtime to BookTicker. Removed timestamp
jargote Nov 5, 2022
a455d43
Updated BookTicker definition
jargote Nov 5, 2022
46d35b2
Error fix
jargote Nov 5, 2022
1c447fa
Added uId to BookTicker
jargote Dec 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed @bookTicker and !bookTicker streams
  • Loading branch information
jargote committed Aug 3, 2021
commit 94bf23da4438e50210534ebd159e16e8a0ca4b44
23 changes: 7 additions & 16 deletions src/basic-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BasicTradeClient extends EventEmitter {
this._name = name;
this._tickerSubs = new Map();
this._bookTickerSubs = new Map();
this._allBookTickerSubs = false;
this._allBookTickerSubs = new Map();
this._tradeSubs = new Map();
this._candleSubs = new Map();
this._level2SnapshotSubs = new Map();
Expand Down Expand Up @@ -81,23 +81,14 @@ class BasicTradeClient extends EventEmitter {
this._unsubscribe(market, this._bookTickerSubs, this._sendUnsubBookTicker.bind(this));
}

subscribeAllBookTicker() {
subscribeAllBookTicker(market) {
if (!this.hasAllBookTicker) return;
this._allBookTickerSubs = true

this._connect()
if (this._wss && this._wss.isConnected) {
return this._sendSubAllBookTicker();
}
return this._subscribe(market, this._allBookTickerSubs, this._sendSubAllBookTicker.bind(this));
}

unsubscribeAllBookTicker() {
unsubscribeAllBookTicker(market) {
if (!this.hasAllBookTicker) return;
this._allBookTickerSubs = false

if (this._wss && this._wss.isConnected) {
this._sendUnsubAllBookTicker();
}
return this._unsubscribe(market, this._allBookTickerSubs, this._sendUnsubAllBookTicker.bind(this));
}

subscribeCandles(market) {
Expand Down Expand Up @@ -261,8 +252,8 @@ class BasicTradeClient extends EventEmitter {
for (let [marketSymbol, market] of this._bookTickerSubs) {
this._sendSubBookTicker(marketSymbol, market);
}
if (this._allBookTickerSubs) {
this._sendSubAllBookTicker()
for (let [marketSymbol, market] of this._allBookTickerSubs) {
this._sendSubAllBookTicker(marketSymbol, market);
}
for (let [marketSymbol, market] of this._candleSubs) {
this._sendSubCandles(marketSymbol, market);
Expand Down
8 changes: 4 additions & 4 deletions src/exchanges/binance-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BinanceBase extends BasicClient {

subscribe(this._sendSubTicker.bind(this), this._tickerSubs)
subscribe(this._sendSubBookTicker.bind(this), this._bookTickerSubs)
this._allBookTickerSubs && this._sendSubAllBookTicker()
subscribe(this._sendSubAllBookTicker.bind(this), this._allBookTickerSubs)
subscribe(this._sendSubCandles.bind(this), this._candleSubs)
subscribe(this._sendSubTrades.bind(this), this._tradeSubs)
subscribe(this._sendSubLevel2Snapshots.bind(this), this._level2SnapshotSubs)
Expand Down Expand Up @@ -253,18 +253,18 @@ class BinanceBase extends BasicClient {
let market = this._bookTickerSubs.get(remote_id);
if (!market) return;

let bookTicker = this._constructBookTicker(msg.data, market);
const bookTicker = this._constructBookTicker(msg.data, market);
this.emit("bookTicker", bookTicker, market);
return;
}

// all orderbook ticker
if (msg.stream.endsWith("!bookTicker")) {
let remote_id = msg.data.s;
let market = this._bookTickerSubs.get(remote_id);
let market = this._allBookTickerSubs.get(remote_id);
if (!market) return;
const bookTicker = this._constructBookTicker(msg.data, market);

let bookTicker = this._constructBookTicker(msg.data, remote_id);
this.emit("allBookTicker", bookTicker, market);
return;
}
Expand Down