Browse Source

Bugfix/fix division by zero in benchmarks calculation (#1177)

* Fix division by zero error

* Update changelog
pull/1179/head
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
df0e9ad03b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 10
      apps/api/src/app/benchmark/benchmark.service.ts

4
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 anymore

10
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(

Loading…
Cancel
Save