From df8c34c0e93482dc995947d2c842b8f1415f3cdf Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Fri, 6 Sep 2024 14:55:32 +0300 Subject: [PATCH] Handle missing symbols for exchange gracefully --- src/data-feeds/ccxt-provider-service.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/data-feeds/ccxt-provider-service.ts b/src/data-feeds/ccxt-provider-service.ts index 948af71..9be1979 100644 --- a/src/data-feeds/ccxt-provider-service.ts +++ b/src/data-feeds/ccxt-provider-service.ts @@ -102,13 +102,16 @@ export class CcxtFeed implements BaseDataFeed { const exchange = this.exchangeByName.get(exchangeName); if (exchange === undefined) continue; - try { - const symbolArray = Array.from(symbols); - const marketIds = symbolArray.map(symbol => exchange.markets[symbol].id); - void this.watch(exchange, marketIds, exchangeName); - } catch (e) { - this.logger.error(`Failed to watch trades for ${exchangeName}: ${e}`); + const marketIds: string[] = []; + for (const symbol of symbols) { + const market = exchange.markets[symbol]; + if (market === undefined) { + this.logger.warn(`Market not found for ${symbol} on ${exchangeName}`); + continue; + } + marketIds.push(market.id); } + void this.watch(exchange, marketIds, exchangeName); } }