Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/fix error handling for missing market prices (#1023)

Thomas Kaulaba562cb35e1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a38143e796..e680072979 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 da08f8e52b..6528874535 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
)