Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/fix division by zero in benchmarks calculation (#1177)
Thomas Kauldf0e9ad03beb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 28ed477916..76ec7cffd5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Integrated the commands `database:setup` and `database:migrate` into the container start+### Fixed++- Fixed a division by zero error in the benchmarks calculation+### Todo- Apply manual data migration (`yarn database:migrate`) is not needed anymorediff --git a/apps/api/src/app/benchmark/benchmark.service.ts b/apps/api/src/app/benchmark/benchmark.service.tsindex f7a10d8e51..2e8ee61d44 100644--- a/apps/api/src/app/benchmark/benchmark.service.ts+++ b/apps/api/src/app/benchmark/benchmark.service.ts@@ -48,9 +48,13 @@ export class BenchmarkService {benchmarks = allTimeHighs.map((allTimeHigh, index) => {const { marketPrice } = quotes[benchmarkAssets[index].symbol];- const performancePercentFromAllTimeHigh = new Big(marketPrice)- .div(allTimeHigh)- .minus(1);+ let performancePercentFromAllTimeHigh = new Big(0);++ if (allTimeHigh) {+ performancePercentFromAllTimeHigh = new Big(marketPrice)+ .div(allTimeHigh)+ .minus(1);+ }return {marketCondition: this.getMarketCondition(