@barchart/portfolio-api-common 1.0.100 → 1.0.101
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.
|
@@ -274,11 +274,7 @@ module.exports = (() => {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
function findNode(tree, keys) {
|
|
277
|
-
return keys.reduce((tree, key) =>
|
|
278
|
-
tree = tree.findChild(group => group.description === key);
|
|
279
|
-
|
|
280
|
-
return tree;
|
|
281
|
-
}, tree);
|
|
277
|
+
return keys.reduce((tree, key) => tree.findChild(group => group.key === key), tree);
|
|
282
278
|
}
|
|
283
279
|
|
|
284
280
|
function getSummaryArray(ranges) {
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -990,11 +990,7 @@ module.exports = (() => {
|
|
|
990
990
|
}
|
|
991
991
|
|
|
992
992
|
function findNode(tree, keys) {
|
|
993
|
-
return keys.reduce((tree, key) =>
|
|
994
|
-
tree = tree.findChild(group => group.description === key);
|
|
995
|
-
|
|
996
|
-
return tree;
|
|
997
|
-
}, tree);
|
|
993
|
+
return keys.reduce((tree, key) => tree.findChild(group => group.key === key), tree);
|
|
998
994
|
}
|
|
999
995
|
|
|
1000
996
|
function getSummaryArray(ranges) {
|
|
@@ -6201,18 +6197,18 @@ describe('When a position container data is gathered', () => {
|
|
|
6201
6197
|
beforeEach(() => {
|
|
6202
6198
|
portfolios = [
|
|
6203
6199
|
{
|
|
6204
|
-
portfolio: '
|
|
6200
|
+
portfolio: 'My First Portfolio',
|
|
6205
6201
|
name: 'a'
|
|
6206
6202
|
}, {
|
|
6207
|
-
portfolio: '
|
|
6203
|
+
portfolio: 'My Second Portfolio',
|
|
6208
6204
|
name: 'b'
|
|
6209
6205
|
}
|
|
6210
6206
|
];
|
|
6211
6207
|
|
|
6212
6208
|
positions = [
|
|
6213
|
-
getPosition('
|
|
6214
|
-
getPosition('
|
|
6215
|
-
getPosition('
|
|
6209
|
+
getPosition('My First Portfolio', 'AAPL'),
|
|
6210
|
+
getPosition('My Second Portfolio', 'AAPL'),
|
|
6211
|
+
getPosition('My Second Portfolio', 'TSLA')
|
|
6216
6212
|
];
|
|
6217
6213
|
|
|
6218
6214
|
summaries = [ ];
|
|
@@ -6226,7 +6222,7 @@ describe('When a position container data is gathered', () => {
|
|
|
6226
6222
|
beforeEach(() => {
|
|
6227
6223
|
definitions = [
|
|
6228
6224
|
new PositionTreeDefinition(name = 'the only tree', [
|
|
6229
|
-
new PositionLevelDefinition('Total', x =>
|
|
6225
|
+
new PositionLevelDefinition('Total', x => 'totals', x => 'Total', x => Currency.CAD),
|
|
6230
6226
|
new PositionLevelDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
|
|
6231
6227
|
new PositionLevelDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
|
|
6232
6228
|
])
|
|
@@ -6240,27 +6236,27 @@ describe('When a position container data is gathered', () => {
|
|
|
6240
6236
|
});
|
|
6241
6237
|
|
|
6242
6238
|
it('the "Total" group should have two children groups', () => {
|
|
6243
|
-
expect(container.getGroups(name, [ '
|
|
6239
|
+
expect(container.getGroups(name, [ 'totals' ]).length).toEqual(2);
|
|
6244
6240
|
});
|
|
6245
6241
|
|
|
6246
6242
|
it('the "Total" group should have three items', () => {
|
|
6247
|
-
expect(container.getGroup(name, [ '
|
|
6243
|
+
expect(container.getGroup(name, [ 'totals' ]).items.length).toEqual(3);
|
|
6248
6244
|
});
|
|
6249
6245
|
|
|
6250
6246
|
it('The "a" portfolio group should have one child group', () => {
|
|
6251
|
-
expect(container.getGroups(name, [ '
|
|
6247
|
+
expect(container.getGroups(name, [ 'totals', 'My First Portfolio' ]).length).toEqual(1);
|
|
6252
6248
|
});
|
|
6253
6249
|
|
|
6254
6250
|
it('the "a" portfolio group should have one item', () => {
|
|
6255
|
-
expect(container.getGroup(name, [ '
|
|
6251
|
+
expect(container.getGroup(name, [ 'totals', 'My First Portfolio' ]).items.length).toEqual(1);
|
|
6256
6252
|
});
|
|
6257
6253
|
|
|
6258
6254
|
it('The "b" portfolio group should have two child groups', () => {
|
|
6259
|
-
expect(container.getGroups(name, [ '
|
|
6255
|
+
expect(container.getGroups(name, [ 'totals', 'My Second Portfolio' ]).length).toEqual(2);
|
|
6260
6256
|
});
|
|
6261
6257
|
|
|
6262
6258
|
it('the "b" portfolio group should have two items', () => {
|
|
6263
|
-
expect(container.getGroup(name, [ '
|
|
6259
|
+
expect(container.getGroup(name, [ 'totals', 'My Second Portfolio' ]).items.length).toEqual(2);
|
|
6264
6260
|
});
|
|
6265
6261
|
});
|
|
6266
6262
|
});
|
|
@@ -41,18 +41,18 @@ describe('When a position container data is gathered', () => {
|
|
|
41
41
|
beforeEach(() => {
|
|
42
42
|
portfolios = [
|
|
43
43
|
{
|
|
44
|
-
portfolio: '
|
|
44
|
+
portfolio: 'My First Portfolio',
|
|
45
45
|
name: 'a'
|
|
46
46
|
}, {
|
|
47
|
-
portfolio: '
|
|
47
|
+
portfolio: 'My Second Portfolio',
|
|
48
48
|
name: 'b'
|
|
49
49
|
}
|
|
50
50
|
];
|
|
51
51
|
|
|
52
52
|
positions = [
|
|
53
|
-
getPosition('
|
|
54
|
-
getPosition('
|
|
55
|
-
getPosition('
|
|
53
|
+
getPosition('My First Portfolio', 'AAPL'),
|
|
54
|
+
getPosition('My Second Portfolio', 'AAPL'),
|
|
55
|
+
getPosition('My Second Portfolio', 'TSLA')
|
|
56
56
|
];
|
|
57
57
|
|
|
58
58
|
summaries = [ ];
|
|
@@ -66,7 +66,7 @@ describe('When a position container data is gathered', () => {
|
|
|
66
66
|
beforeEach(() => {
|
|
67
67
|
definitions = [
|
|
68
68
|
new PositionTreeDefinition(name = 'the only tree', [
|
|
69
|
-
new PositionLevelDefinition('Total', x =>
|
|
69
|
+
new PositionLevelDefinition('Total', x => 'totals', x => 'Total', x => Currency.CAD),
|
|
70
70
|
new PositionLevelDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
|
|
71
71
|
new PositionLevelDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
|
|
72
72
|
])
|
|
@@ -80,27 +80,27 @@ describe('When a position container data is gathered', () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('the "Total" group should have two children groups', () => {
|
|
83
|
-
expect(container.getGroups(name, [ '
|
|
83
|
+
expect(container.getGroups(name, [ 'totals' ]).length).toEqual(2);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('the "Total" group should have three items', () => {
|
|
87
|
-
expect(container.getGroup(name, [ '
|
|
87
|
+
expect(container.getGroup(name, [ 'totals' ]).items.length).toEqual(3);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it('The "a" portfolio group should have one child group', () => {
|
|
91
|
-
expect(container.getGroups(name, [ '
|
|
91
|
+
expect(container.getGroups(name, [ 'totals', 'My First Portfolio' ]).length).toEqual(1);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
it('the "a" portfolio group should have one item', () => {
|
|
95
|
-
expect(container.getGroup(name, [ '
|
|
95
|
+
expect(container.getGroup(name, [ 'totals', 'My First Portfolio' ]).items.length).toEqual(1);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
it('The "b" portfolio group should have two child groups', () => {
|
|
99
|
-
expect(container.getGroups(name, [ '
|
|
99
|
+
expect(container.getGroups(name, [ 'totals', 'My Second Portfolio' ]).length).toEqual(2);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it('the "b" portfolio group should have two items', () => {
|
|
103
|
-
expect(container.getGroup(name, [ '
|
|
103
|
+
expect(container.getGroup(name, [ 'totals', 'My Second Portfolio' ]).items.length).toEqual(2);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
});
|