@barchart/portfolio-api-common 1.0.56 → 1.0.60

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.
@@ -77,7 +77,8 @@ module.exports = (() => {
77
77
  const currentDefinition = definitions[0];
78
78
  const additionalDefinitions = array.dropLeft(definitions);
79
79
 
80
- const populatedGroups = array.batchBy(items, currentDefinition.keySelector).map((items) => {
80
+ const populatedObjects = array.groupBy(items, currentDefinition.keySelector);
81
+ const populatedGroups = Object.keys(populatedObjects).map(key => populatedObjects[key]).map((items) => {
81
82
  const first = items[0];
82
83
 
83
84
  return new PositionGroup(items, currentDefinition.currencySelector(first), currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
@@ -137,7 +138,7 @@ module.exports = (() => {
137
138
 
138
139
  setPrice(symbol, price) {
139
140
  if (this._symbols.hasOwnProperty(symbol)) {
140
- this._symbols.forEach(item => item.setPrice(price));
141
+ this._symbols[symbol].forEach(item => item.setPrice(price));
141
142
  }
142
143
  }
143
144
 
@@ -99,7 +99,7 @@ module.exports = (() => {
99
99
  const position = item.position;
100
100
  const snapshot = item.position.snapshot;
101
101
 
102
- updates.value = updates.basis.add(snapshot.basis);
102
+ updates.basis = updates.basis.add(snapshot.basis);
103
103
 
104
104
  return updates;
105
105
  }, {
@@ -108,7 +108,7 @@ module.exports = (() => {
108
108
  }
109
109
 
110
110
  raw.basis = updates.basis;
111
- formatted.basis = format(updates.basis, Currency.USD);
111
+ formatted.basis = format(updates.basis.opposite(), Currency.USD);
112
112
  }
113
113
 
114
114
  function calculateVariablePriceData(group, item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.56",
3
+ "version": "1.0.60",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -592,7 +592,8 @@ module.exports = (() => {
592
592
  const currentDefinition = definitions[0];
593
593
  const additionalDefinitions = array.dropLeft(definitions);
594
594
 
595
- const populatedGroups = array.batchBy(items, currentDefinition.keySelector).map((items) => {
595
+ const populatedObjects = array.groupBy(items, currentDefinition.keySelector);
596
+ const populatedGroups = Object.keys(populatedObjects).map(key => populatedObjects[key]).map((items) => {
596
597
  const first = items[0];
597
598
 
598
599
  return new PositionGroup(items, currentDefinition.currencySelector(first), currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
@@ -652,7 +653,7 @@ module.exports = (() => {
652
653
 
653
654
  setPrice(symbol, price) {
654
655
  if (this._symbols.hasOwnProperty(symbol)) {
655
- this._symbols.forEach(item => item.setPrice(price));
656
+ this._symbols[symbol].forEach(item => item.setPrice(price));
656
657
  }
657
658
  }
658
659
 
@@ -786,7 +787,7 @@ module.exports = (() => {
786
787
  const position = item.position;
787
788
  const snapshot = item.position.snapshot;
788
789
 
789
- updates.value = updates.basis.add(snapshot.basis);
790
+ updates.basis = updates.basis.add(snapshot.basis);
790
791
 
791
792
  return updates;
792
793
  }, {
@@ -795,7 +796,7 @@ module.exports = (() => {
795
796
  }
796
797
 
797
798
  raw.basis = updates.basis;
798
- formatted.basis = format(updates.basis, Currency.USD);
799
+ formatted.basis = format(updates.basis.opposite(), Currency.USD);
799
800
  }
800
801
 
801
802
  function calculateVariablePriceData(group, item) {