MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / sortAsks

Method sortAsks

src/node-binance-api.ts:3669–3685  ·  view source on GitHub ↗

* Sorts asks * @param {string} symbol - the object * @param {int} max - the max number of bids * @param {string} baseValue - the object * @return {object} - the object

(symbol: string, max = Infinity, baseValue?: string)

Source from the content-addressed store, hash-verified

3667 * @return {object} - the object
3668 */
3669 sortAsks(symbol: string, max = Infinity, baseValue?: string) {
3670 let count = 0, cache;
3671 const object = {};
3672 if (typeof symbol === 'object') cache = symbol;
3673 else cache = this.getDepthCache(symbol).asks;
3674 const sorted = Object.keys(cache).sort((a, b) => parseFloat(a) - parseFloat(b));
3675 let cumulative = 0;
3676 for (const price of sorted) {
3677 if (!baseValue) object[price] = cache[price];
3678 else if (baseValue === 'cumulative') {
3679 cumulative += cache[price];
3680 object[price] = cumulative;
3681 } else object[price] = parseFloat((cache[price] * parseFloat(price)).toFixed(8));
3682 if (++count >= max) break;
3683 }
3684 return object;
3685 }
3686
3687 /**
3688 * Returns the first property of an object

Callers 2

example.jsFile · 0.80

Calls 1

getDepthCacheMethod · 0.95

Tested by

no test coverage detected