@barchart/portfolio-api-common 1.2.144 → 1.2.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -978,28 +978,32 @@ module.exports = (() => {
978
978
  const openBasis = actual.basis;
979
979
  const totalBasis = actual.totalDivisor;
980
980
 
981
- const closedBasis = totalBasis.subtract(openBasis);
981
+ const numerator = actual.realized;
982
+ const denominator = totalBasis.subtract(openBasis);
982
983
 
983
- if (closedBasis.getIsZero()) {
984
- actual.realizedPercent = null;
985
- format.realizedPercent = '—';
984
+ if (denominator.getIsZero()) {
985
+ actual.realizedPercent = Decimal.ZERO;
986
986
  } else {
987
- actual.realizedPercent = actual.realized.divide(closedBasis);
988
- format.realizedPercent = formatPercent(actual.realizedPercent, 2);
987
+ actual.realizedPercent = numerator.divide(denominator);
989
988
  }
989
+
990
+ format.realizedPercent = formatPercent(actual.realizedPercent, 2);
990
991
  }
991
992
 
992
993
  function calculateUnrealizedPercent(group) {
993
994
  const actual = group._dataActual;
994
995
  const format = group._dataFormat;
995
996
 
996
- if (actual.basis.getIsZero()) {
997
- actual.unrealizedPercent = null;
998
- format.unrealizedPercent = '—';
997
+ const numerator = actual.unrealized;
998
+ const denominator = actual.basis;
999
+
1000
+ if (denominator.getIsZero()) {
1001
+ actual.unrealizedPercent = Decimal.ZERO;
999
1002
  } else {
1000
- actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
1001
- format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
1003
+ actual.unrealizedPercent = numerator.divide(denominator);
1002
1004
  }
1005
+
1006
+ format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
1003
1007
  }
1004
1008
 
1005
1009
  function calculateGainPercent(gain, basis) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.144",
3
+ "version": "1.2.145",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -3500,28 +3500,32 @@ module.exports = (() => {
3500
3500
  const openBasis = actual.basis;
3501
3501
  const totalBasis = actual.totalDivisor;
3502
3502
 
3503
- const closedBasis = totalBasis.subtract(openBasis);
3503
+ const numerator = actual.realized;
3504
+ const denominator = totalBasis.subtract(openBasis);
3504
3505
 
3505
- if (closedBasis.getIsZero()) {
3506
- actual.realizedPercent = null;
3507
- format.realizedPercent = '—';
3506
+ if (denominator.getIsZero()) {
3507
+ actual.realizedPercent = Decimal.ZERO;
3508
3508
  } else {
3509
- actual.realizedPercent = actual.realized.divide(closedBasis);
3510
- format.realizedPercent = formatPercent(actual.realizedPercent, 2);
3509
+ actual.realizedPercent = numerator.divide(denominator);
3511
3510
  }
3511
+
3512
+ format.realizedPercent = formatPercent(actual.realizedPercent, 2);
3512
3513
  }
3513
3514
 
3514
3515
  function calculateUnrealizedPercent(group) {
3515
3516
  const actual = group._dataActual;
3516
3517
  const format = group._dataFormat;
3517
3518
 
3518
- if (actual.basis.getIsZero()) {
3519
- actual.unrealizedPercent = null;
3520
- format.unrealizedPercent = '—';
3519
+ const numerator = actual.unrealized;
3520
+ const denominator = actual.basis;
3521
+
3522
+ if (denominator.getIsZero()) {
3523
+ actual.unrealizedPercent = Decimal.ZERO;
3521
3524
  } else {
3522
- actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
3523
- format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
3525
+ actual.unrealizedPercent = numerator.divide(denominator);
3524
3526
  }
3527
+
3528
+ format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
3525
3529
  }
3526
3530
 
3527
3531
  function calculateGainPercent(gain, basis) {