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

Commit

Permalink
Defined BookTicker class for representing an orderbook ticker event
Browse files Browse the repository at this point in the history
  • Loading branch information
jargote committed May 11, 2021
1 parent 15afe1f commit 83e2727
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/bookTicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* {
* "u":400900217, // order book updateId
* "s":"BNBUSDT", // symbol
* "b":"25.35190000", // best bid price
* "B":"31.21000000", // best bid qty
* "a":"25.36520000", // best ask price
* "A":"40.66000000" // best ask qty
* }
*
* @class BookTicker
*/
class BookTicker {
constructor({
exchange,
base,
quote,
bid,
bidVolume,
ask,
askVolume,
}) {
this.exchange = exchange;
this.base = base;
this.quote = quote;
this.timestamp = timestamp;
this.bid = bid;
this.bidVolume = bidVolume;
this.ask = ask;
this.askVolume = askVolume;
}

/**
* @deprecated use Market object (second argument to each event) to determine exchange and trade pair
*/
get fullId() {
return `${this.exchange}:${this.base}/${this.quote}`;
}
}

module.exports = BookTicker;

0 comments on commit 83e2727

Please sign in to comment.