From ed731afc6678550648dd4869384cb00d5dcba756 Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Thu, 29 Jul 2021 22:11:27 +0200 Subject: [PATCH] fix market price fetch in case symbols are missing --- apps/api/src/app/core/portfolio-calculator.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/api/src/app/core/portfolio-calculator.ts b/apps/api/src/app/core/portfolio-calculator.ts index f51e0b3c5..e5319f231 100644 --- a/apps/api/src/app/core/portfolio-calculator.ts +++ b/apps/api/src/app/core/portfolio-calculator.ts @@ -172,9 +172,11 @@ export class PortfolioCalculator { if (!marketSymbolMap[date]) { marketSymbolMap[date] = {}; } - marketSymbolMap[date][marketSymbol.symbol] = new Big( - marketSymbol.marketPrice - ); + if (marketSymbol.marketPrice) { + marketSymbolMap[date][marketSymbol.symbol] = new Big( + marketSymbol.marketPrice + ); + } } let hasErrors = false; @@ -377,9 +379,11 @@ export class PortfolioCalculator { if (!marketSymbolMap[date]) { marketSymbolMap[date] = {}; } - marketSymbolMap[date][marketSymbol.symbol] = new Big( - marketSymbol.marketPrice - ); + if (marketSymbol.marketPrice) { + marketSymbolMap[date][marketSymbol.symbol] = new Big( + marketSymbol.marketPrice + ); + } } }