Skip to content

Commit

Permalink
remove markets_by_id from derived classes
Browse files Browse the repository at this point in the history
  • Loading branch information
frosty00 committed Dec 27, 2022
1 parent 7064759 commit 32c2900
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 43 deletions.
43 changes: 17 additions & 26 deletions js/pro/bitvavo.js
Expand Up @@ -386,11 +386,7 @@ module.exports = class bitvavo extends bitvavoRest {
return message;
}
const marketId = this.safeString (response, 'market');
let symbol = undefined;
if (marketId in this.markets_by_id) {
const market = this.markets_by_id[marketId];
symbol = market['symbol'];
}
const symbol = this.safeSymbol (marketId, undefined, '-');
const name = 'book';
const messageHash = name + '@' + marketId;
const orderbook = this.orderbooks[symbol];
Expand Down Expand Up @@ -420,16 +416,13 @@ module.exports = class bitvavo extends bitvavoRest {
const name = 'book';
for (let i = 0; i < marketIds.length; i++) {
const marketId = this.safeString (marketIds, i);
if (marketId in this.markets_by_id) {
const market = this.markets_by_id[marketId];
const symbol = market['symbol'];
const messageHash = name + '@' + marketId;
if (!(symbol in this.orderbooks)) {
const subscription = this.safeValue (client.subscriptions, messageHash);
const method = this.safeValue (subscription, 'method');
if (method !== undefined) {
method.call (this, client, message, subscription);
}
const symbol = this.safeSymbol (marketId, undefined, '-');
const messageHash = name + '@' + marketId;
if (!(symbol in this.orderbooks)) {
const subscription = this.safeValue (client.subscriptions, messageHash);
const method = this.safeValue (subscription, 'method');
if (method !== undefined) {
method.call (this, client, message, subscription);
}
}
}
Expand Down Expand Up @@ -537,19 +530,17 @@ module.exports = class bitvavo extends bitvavoRest {
//
const name = 'account';
const event = this.safeString (message, 'event');
const marketId = this.safeString (message, 'market', '-');
const marketId = this.safeString (message, 'market');
const market = this.safeMarket (marketId, undefined, '-');
const messageHash = name + '@' + marketId + '_' + event;
if (marketId in this.markets_by_id) {
const market = this.markets_by_id[marketId];
const order = this.parseOrder (message, market);
if (this.orders === undefined) {
const limit = this.safeInteger (this.options, 'ordersLimit', 1000);
this.orders = new ArrayCacheBySymbolById (limit);
}
const orders = this.orders;
orders.append (order);
client.resolve (this.orders, messageHash);
const order = this.parseOrder (message, market);
if (this.orders === undefined) {
const limit = this.safeInteger (this.options, 'ordersLimit', 1000);
this.orders = new ArrayCacheBySymbolById (limit);
}
const orders = this.orders;
orders.append (order);
client.resolve (this.orders, messageHash);
}

handleMyTrade (client, message) {
Expand Down
4 changes: 1 addition & 3 deletions js/pro/coinex.js
Expand Up @@ -613,9 +613,7 @@ module.exports = class coinex extends coinexRest {
message['params'] = [ market['id'] ];
messageHash += ':' + symbol;
} else {
// deprecated usage of markets_by_id...
const markets = Object.keys (this.markets_by_id);
message['params'] = markets;
message['params'] = this.ids;
}
const url = this.urls['api']['ws'][type];
const request = this.deepExtend (message, query);
Expand Down
17 changes: 7 additions & 10 deletions js/pro/phemex.js
Expand Up @@ -600,17 +600,14 @@ module.exports = class phemex extends phemexRest {
for (let i = 0; i < message.length; i++) {
const rawTrade = message[i];
const marketId = this.safeString (rawTrade, 'symbol');
// skip delisted markets
if (marketId in this.markets_by_id) {
const parsed = this.parseTrade (rawTrade);
cachedTrades.append (parsed);
const symbol = parsed['symbol'];
const market = this.market (symbol);
if (type === undefined) {
type = market['type'];
}
marketIds[symbol] = true;
const market = this.safeMarket (marketId);
const parsed = this.parseTrade (rawTrade);
cachedTrades.append (parsed);
const symbol = parsed['symbol'];
if (type === undefined) {
type = market['type'];
}
marketIds[symbol] = true;
}
const keys = Object.keys (marketIds);
for (let i = 0; i < keys.length; i++) {
Expand Down
10 changes: 6 additions & 4 deletions js/zb.js
Expand Up @@ -1339,14 +1339,16 @@ module.exports = class zb extends Exchange {
const response = await this.spotV1PublicGetAllTicker (params);
const result = {};
const marketsByIdWithoutUnderscore = {};
const marketIds = Object.keys (this.markets_by_id);
const marketIds = this.ids;
for (let i = 0; i < marketIds.length; i++) {
const tickerId = marketIds[i].replace ('_', '');
marketsByIdWithoutUnderscore[tickerId] = this.markets_by_id[marketIds[i]];
const marketId = marketIds[i];
const tickerId = marketId.replace ('_', '');
marketsByIdWithoutUnderscore[tickerId] = marketId;
}
const ids = Object.keys (response);
for (let i = 0; i < ids.length; i++) {
const market = this.safeValue (marketsByIdWithoutUnderscore, ids[i]);
const marketId = this.safeValue (marketsByIdWithoutUnderscore, ids[i]);
const market = this.safeMarket (marketId, undefined, '_');
if (market !== undefined) {
const symbol = market['symbol'];
const ticker = this.safeValue (response, ids[i]);
Expand Down

0 comments on commit 32c2900

Please sign in to comment.