Skip to content

Commit

Permalink
Handle missing symbols for exchange gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
adg-flare committed Sep 6, 2024
1 parent 392f36c commit df8c34c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/data-feeds/ccxt-provider-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit df8c34c

Please sign in to comment.