From aba562cb35e16fb3c5295adb4e822ea5e70c916f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 16 Jun 2022 16:49:29 +0200 Subject: [PATCH] Bugfix/fix error handling for missing market prices (#1023) * Add fallback for missing market price * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/portfolio/portfolio.service.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a38143e79..e68007297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgraded `Nx` from version `14.1.4` to `14.3.5` - Upgraded `storybook` from version `6.4.22` to `6.5.9` +### Fixed + +- Improved the error handling of missing market prices + ## 1.160.0 - 15.06.2022 ### Fixed diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index da08f8e52..652887453 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -394,7 +394,7 @@ export class PortfolioService { continue; } - const value = item.quantity.mul(item.marketPrice); + const value = item.quantity.mul(item.marketPrice ?? 0); const symbolProfile = symbolProfileMap[item.symbol]; const dataProviderResponse = dataProviderResponses[item.symbol]; @@ -658,7 +658,7 @@ export class PortfolioService { netPerformancePercent: position.netPerformancePercentage?.toNumber(), quantity: quantity.toNumber(), value: this.exchangeRateDataService.toCurrency( - quantity.mul(marketPrice).toNumber(), + quantity.mul(marketPrice ?? 0).toNumber(), currency, userCurrency )