@barchart/portfolio-api-common 1.0.55 → 1.0.59
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
|
|
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,13 +138,13 @@ module.exports = (() => {
|
|
|
137
138
|
|
|
138
139
|
setPrice(symbol, price) {
|
|
139
140
|
if (this._symbols.hasOwnProperty(symbol)) {
|
|
140
|
-
this._symbols.forEach(item.setPrice(price));
|
|
141
|
+
this._symbols[symbol].forEach(item => item.setPrice(price));
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
getGroup(keys) {
|
|
145
146
|
const node = keys.reduce((tree, key) => {
|
|
146
|
-
tree = tree.findChild(
|
|
147
|
+
tree = tree.findChild(group => group.description === key);
|
|
147
148
|
|
|
148
149
|
return tree;
|
|
149
150
|
}, this._tree);
|
|
@@ -153,7 +154,7 @@ module.exports = (() => {
|
|
|
153
154
|
|
|
154
155
|
getGroups(keys) {
|
|
155
156
|
const node = keys.reduce((tree, key) => {
|
|
156
|
-
tree = tree.findChild(
|
|
157
|
+
tree = tree.findChild(group => group.description === key);
|
|
157
158
|
|
|
158
159
|
return tree;
|
|
159
160
|
}, this._tree);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -592,7 +592,8 @@ module.exports = (() => {
|
|
|
592
592
|
const currentDefinition = definitions[0];
|
|
593
593
|
const additionalDefinitions = array.dropLeft(definitions);
|
|
594
594
|
|
|
595
|
-
const
|
|
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,13 +653,13 @@ module.exports = (() => {
|
|
|
652
653
|
|
|
653
654
|
setPrice(symbol, price) {
|
|
654
655
|
if (this._symbols.hasOwnProperty(symbol)) {
|
|
655
|
-
this._symbols.forEach(item.setPrice(price));
|
|
656
|
+
this._symbols[symbol].forEach(item => item.setPrice(price));
|
|
656
657
|
}
|
|
657
658
|
}
|
|
658
659
|
|
|
659
660
|
getGroup(keys) {
|
|
660
661
|
const node = keys.reduce((tree, key) => {
|
|
661
|
-
tree = tree.findChild(
|
|
662
|
+
tree = tree.findChild(group => group.description === key);
|
|
662
663
|
|
|
663
664
|
return tree;
|
|
664
665
|
}, this._tree);
|
|
@@ -668,7 +669,7 @@ module.exports = (() => {
|
|
|
668
669
|
|
|
669
670
|
getGroups(keys) {
|
|
670
671
|
const node = keys.reduce((tree, key) => {
|
|
671
|
-
tree = tree.findChild(
|
|
672
|
+
tree = tree.findChild(group => group.description === key);
|
|
672
673
|
|
|
673
674
|
return tree;
|
|
674
675
|
}, this._tree);
|
|
@@ -786,7 +787,7 @@ module.exports = (() => {
|
|
|
786
787
|
const position = item.position;
|
|
787
788
|
const snapshot = item.position.snapshot;
|
|
788
789
|
|
|
789
|
-
updates.
|
|
790
|
+
updates.basis = updates.basis.add(snapshot.basis);
|
|
790
791
|
|
|
791
792
|
return updates;
|
|
792
793
|
}, {
|