diff --git a/package.json b/package.json index 49e5555..158ad19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@barchart/portfolio-api-common", - "version": "1.11.2", + "version": "1.11.3", "description": "Common code used by the Portfolio system", "author": { "name": "Bryan Ingle", diff --git a/test/SpecRunner.js b/test/SpecRunner.js index aa6a79c..ba8b2b1 100644 --- a/test/SpecRunner.js +++ b/test/SpecRunner.js @@ -3689,7 +3689,7 @@ module.exports = (() => { let marketChange = updates.market.subtract(actual.marketPrevious); let marketChangePercent; - if (actual.marketPrevious.getIsZero()) { + if (actual.marketPrevious.getIsApproximate(Decimal.ZERO, 4)) { if (marketChange.getIsPositive()) { marketChangePercent = Decimal.ONE; } else if (marketChange.getIsNegative()) { @@ -3747,7 +3747,7 @@ module.exports = (() => { if (parent && !excluded) { const parentData = parent._dataActual; - if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsZero()) { + if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsApproximate(Decimal.ZERO, 4)) { let numerator; if (group.currency !== parent.currency) { @@ -3789,7 +3789,7 @@ module.exports = (() => { const numerator = actual.realized; const denominator = totalBasis.subtract(openBasis); - if (denominator.getIsZero()) { + if (denominator.getIsApproximate(Decimal.ZERO, 4)) { actual.realizedPercent = Decimal.ZERO; } else { actual.realizedPercent = numerator.divide(denominator); @@ -3805,7 +3805,7 @@ module.exports = (() => { const numerator = actual.unrealized; const denominator = actual.basis.absolute(); - if (denominator.getIsZero()) { + if (denominator.getIsApproximate(Decimal.ZERO, 4)) { actual.unrealizedPercent = Decimal.ZERO; } else { actual.unrealizedPercent = numerator.divide(denominator); @@ -3815,7 +3815,7 @@ module.exports = (() => { } function calculateGainPercent(gain, basis) { - return basis.getIsZero() ? Decimal.ZERO : gain.divide(basis); + return basis.getIsApproximate(Decimal.ZERO, 4) ? Decimal.ZERO : gain.divide(basis); } const unchanged = { up: false, down: false };