@barchart/portfolio-api-common 1.0.149 → 1.0.153

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.
@@ -243,8 +243,6 @@ module.exports = (() => {
243
243
  }
244
244
  }, false);
245
245
 
246
- const treeName = treeDefinition.name;
247
-
248
246
  if (treeDefinition.exclusionDependencies.length > 0) {
249
247
  const dependantTrees = treeDefinition.exclusionDependencies.reduce((trees, name) => {
250
248
  if (this._trees.hasOwnProperty(name)) {
@@ -257,7 +255,7 @@ module.exports = (() => {
257
255
  if (dependantTrees.length > 0) {
258
256
  let excludedItems = [ ];
259
257
 
260
- groupTree.walk((childGroup) => {
258
+ tree.walk((childGroup) => {
261
259
  if (childGroup.excluded) {
262
260
  excludedItems = excludedItems.concat(childGroup.items);
263
261
  }
@@ -102,6 +102,8 @@ module.exports = (() => {
102
102
  this._dataFormat.quoteChangePercent = null;
103
103
  this._dataFormat.quoteTime = null;
104
104
  this._dataFormat.quoteVolume = null;
105
+ this._dataFormat.quoteChangeDirection = unchanged;
106
+ this._dataFormat.quoteChangeNegative = false;
105
107
 
106
108
  this._dataActual.currentPrice = null;
107
109
  this._dataActual.previousPrice = null;
@@ -161,6 +163,9 @@ module.exports = (() => {
161
163
  this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
162
164
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
163
165
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
166
+
167
+ setTimeout(() => this._dataFormat.quoteChangeDirection = { up: this._dataActual.quoteChange.getIsPositive(), down: this._dataActual.quoteChange.getIsNegative() }, 0);
168
+ this._dataFormat.quoteChangeNegative = this._dataActual.quoteChange.getIsNegative();
164
169
  } else {
165
170
  this._dataActual.currentPrice = null;
166
171
  this._dataFormat.currentPrice = null;
@@ -185,7 +190,7 @@ module.exports = (() => {
185
190
  }
186
191
 
187
192
  /**
188
- * A unique (and otherwise meaningless) idenfitifer for the group.
193
+ * A unique (and otherwise meaningless) identifier for the group.
189
194
  *
190
195
  * @public
191
196
  * @returns {Number}
@@ -545,18 +550,6 @@ module.exports = (() => {
545
550
  summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrentChange))
546
551
  };
547
552
  }
548
-
549
- if (parent !== null) {
550
- const parentData = parent._dataActual;
551
-
552
- if (parentData.market !== null && !parentData.market.getIsZero()) {
553
- updates.marketPercent = updates.market.divide(parentData.market);
554
- } else {
555
- updates.marketPercent = null;
556
- }
557
- } else {
558
- updates.marketPercent = null;
559
- }
560
553
 
561
554
  actual.market = updates.market;
562
555
  actual.unrealized = updates.unrealized;
@@ -593,13 +586,14 @@ module.exports = (() => {
593
586
  }
594
587
 
595
588
  const parent = group._parent;
589
+ const excluded = group._excluded;
596
590
 
597
591
  const actual = group._dataActual;
598
592
  const format = group._dataFormat;
599
593
 
600
594
  let marketPercent;
601
595
 
602
- if (parent !== null) {
596
+ if (parent !== null && !excluded) {
603
597
  const parentData = parent._dataActual;
604
598
 
605
599
  if (parentData.market !== null && !parentData.market.getIsZero()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.149",
3
+ "version": "1.0.153",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -959,8 +959,6 @@ module.exports = (() => {
959
959
  }
960
960
  }, false);
961
961
 
962
- const treeName = treeDefinition.name;
963
-
964
962
  if (treeDefinition.exclusionDependencies.length > 0) {
965
963
  const dependantTrees = treeDefinition.exclusionDependencies.reduce((trees, name) => {
966
964
  if (this._trees.hasOwnProperty(name)) {
@@ -973,7 +971,7 @@ module.exports = (() => {
973
971
  if (dependantTrees.length > 0) {
974
972
  let excludedItems = [ ];
975
973
 
976
- groupTree.walk((childGroup) => {
974
+ tree.walk((childGroup) => {
977
975
  if (childGroup.excluded) {
978
976
  excludedItems = excludedItems.concat(childGroup.items);
979
977
  }
@@ -1350,6 +1348,8 @@ module.exports = (() => {
1350
1348
  this._dataFormat.quoteChangePercent = null;
1351
1349
  this._dataFormat.quoteTime = null;
1352
1350
  this._dataFormat.quoteVolume = null;
1351
+ this._dataFormat.quoteChangeDirection = unchanged;
1352
+ this._dataFormat.quoteChangeNegative = false;
1353
1353
 
1354
1354
  this._dataActual.currentPrice = null;
1355
1355
  this._dataActual.previousPrice = null;
@@ -1409,6 +1409,9 @@ module.exports = (() => {
1409
1409
  this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
1410
1410
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
1411
1411
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
1412
+
1413
+ setTimeout(() => this._dataFormat.quoteChangeDirection = { up: this._dataActual.quoteChange.getIsPositive(), down: this._dataActual.quoteChange.getIsNegative() }, 0);
1414
+ this._dataFormat.quoteChangeNegative = this._dataActual.quoteChange.getIsNegative();
1412
1415
  } else {
1413
1416
  this._dataActual.currentPrice = null;
1414
1417
  this._dataFormat.currentPrice = null;
@@ -1433,7 +1436,7 @@ module.exports = (() => {
1433
1436
  }
1434
1437
 
1435
1438
  /**
1436
- * A unique (and otherwise meaningless) idenfitifer for the group.
1439
+ * A unique (and otherwise meaningless) identifier for the group.
1437
1440
  *
1438
1441
  * @public
1439
1442
  * @returns {Number}
@@ -1793,18 +1796,6 @@ module.exports = (() => {
1793
1796
  summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrentChange))
1794
1797
  };
1795
1798
  }
1796
-
1797
- if (parent !== null) {
1798
- const parentData = parent._dataActual;
1799
-
1800
- if (parentData.market !== null && !parentData.market.getIsZero()) {
1801
- updates.marketPercent = updates.market.divide(parentData.market);
1802
- } else {
1803
- updates.marketPercent = null;
1804
- }
1805
- } else {
1806
- updates.marketPercent = null;
1807
- }
1808
1799
 
1809
1800
  actual.market = updates.market;
1810
1801
  actual.unrealized = updates.unrealized;
@@ -1841,13 +1832,14 @@ module.exports = (() => {
1841
1832
  }
1842
1833
 
1843
1834
  const parent = group._parent;
1835
+ const excluded = group._excluded;
1844
1836
 
1845
1837
  const actual = group._dataActual;
1846
1838
  const format = group._dataFormat;
1847
1839
 
1848
1840
  let marketPercent;
1849
1841
 
1850
- if (parent !== null) {
1842
+ if (parent !== null && !excluded) {
1851
1843
  const parentData = parent._dataActual;
1852
1844
 
1853
1845
  if (parentData.market !== null && !parentData.market.getIsZero()) {