@barchart/portfolio-api-common 1.0.242 → 1.0.246
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.
|
@@ -522,7 +522,7 @@ module.exports = (() => {
|
|
|
522
522
|
getParentGroup(group) {
|
|
523
523
|
assert.argumentIsRequired(group, 'group', PositionGroup, 'PositionGroup');
|
|
524
524
|
|
|
525
|
-
return findParentGroup.call(this, candidate => true);
|
|
525
|
+
return findParentGroup.call(this, group, candidate => true);
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
/**
|
|
@@ -535,7 +535,7 @@ module.exports = (() => {
|
|
|
535
535
|
getParentGroupForPortfolio(group) {
|
|
536
536
|
assert.argumentIsRequired(group, 'group', PositionGroup, 'PositionGroup');
|
|
537
537
|
|
|
538
|
-
return findParentGroup.call(this, candidate => candidate.definition.type === PositionLevelType.PORTFOLIO);
|
|
538
|
+
return findParentGroup.call(this, group, candidate => candidate.definition.type === PositionLevelType.PORTFOLIO);
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
/**
|
|
@@ -564,6 +564,20 @@ module.exports = (() => {
|
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
+
/**
|
|
568
|
+
* Returns a single position for a portfolio.
|
|
569
|
+
*
|
|
570
|
+
* @public
|
|
571
|
+
* @param {String} portfolio
|
|
572
|
+
* @param {String} position
|
|
573
|
+
* @return {Object|null}
|
|
574
|
+
*/
|
|
575
|
+
getPosition(portfolio, position) {
|
|
576
|
+
assert.argumentIsRequired(position, 'position', String);
|
|
577
|
+
|
|
578
|
+
return this.getPositions(portfolio).find(p => p.position === position) || null;
|
|
579
|
+
}
|
|
580
|
+
|
|
567
581
|
/**
|
|
568
582
|
* Pauses aggregation calculations during the processing of an action.
|
|
569
583
|
*
|
|
@@ -637,7 +651,7 @@ module.exports = (() => {
|
|
|
637
651
|
let returnRef = null;
|
|
638
652
|
|
|
639
653
|
if (groupNode) {
|
|
640
|
-
const resultNode = groupNode.findParent(
|
|
654
|
+
const resultNode = groupNode.findParent((candidateGroup, candidateNode) => !candidateNode.getIsRoot() && predicate(candidateGroup));
|
|
641
655
|
|
|
642
656
|
if (resultNode) {
|
|
643
657
|
returnRef = resultNode.getValue();
|
|
@@ -58,6 +58,17 @@ module.exports = (() => {
|
|
|
58
58
|
return client;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Data required to update a position.
|
|
63
|
+
*
|
|
64
|
+
* @static
|
|
65
|
+
* @public
|
|
66
|
+
* @returns {PositionSchema}
|
|
67
|
+
*/
|
|
68
|
+
static get UPDATE() {
|
|
69
|
+
return update;
|
|
70
|
+
}
|
|
71
|
+
|
|
61
72
|
toString() {
|
|
62
73
|
return '[PositionSchema]';
|
|
63
74
|
}
|
|
@@ -123,5 +134,11 @@ module.exports = (() => {
|
|
|
123
134
|
.schema
|
|
124
135
|
);
|
|
125
136
|
|
|
137
|
+
const update = new PositionSchema(SchemaBuilder.withName('update')
|
|
138
|
+
.withField('portfolio', DataType.STRING)
|
|
139
|
+
.withField('reinvest', DataType.BOOLEAN, true)
|
|
140
|
+
.schema
|
|
141
|
+
);
|
|
142
|
+
|
|
126
143
|
return PositionSchema;
|
|
127
144
|
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1321,7 +1321,7 @@ module.exports = (() => {
|
|
|
1321
1321
|
getParentGroup(group) {
|
|
1322
1322
|
assert.argumentIsRequired(group, 'group', PositionGroup, 'PositionGroup');
|
|
1323
1323
|
|
|
1324
|
-
return findParentGroup.call(this, candidate => true);
|
|
1324
|
+
return findParentGroup.call(this, group, candidate => true);
|
|
1325
1325
|
}
|
|
1326
1326
|
|
|
1327
1327
|
/**
|
|
@@ -1334,7 +1334,7 @@ module.exports = (() => {
|
|
|
1334
1334
|
getParentGroupForPortfolio(group) {
|
|
1335
1335
|
assert.argumentIsRequired(group, 'group', PositionGroup, 'PositionGroup');
|
|
1336
1336
|
|
|
1337
|
-
return findParentGroup.call(this, candidate => candidate.definition.type === PositionLevelType.PORTFOLIO);
|
|
1337
|
+
return findParentGroup.call(this, group, candidate => candidate.definition.type === PositionLevelType.PORTFOLIO);
|
|
1338
1338
|
}
|
|
1339
1339
|
|
|
1340
1340
|
/**
|
|
@@ -1363,6 +1363,20 @@ module.exports = (() => {
|
|
|
1363
1363
|
});
|
|
1364
1364
|
}
|
|
1365
1365
|
|
|
1366
|
+
/**
|
|
1367
|
+
* Returns a single position for a portfolio.
|
|
1368
|
+
*
|
|
1369
|
+
* @public
|
|
1370
|
+
* @param {String} portfolio
|
|
1371
|
+
* @param {String} position
|
|
1372
|
+
* @return {Object|null}
|
|
1373
|
+
*/
|
|
1374
|
+
getPosition(portfolio, position) {
|
|
1375
|
+
assert.argumentIsRequired(position, 'position', String);
|
|
1376
|
+
|
|
1377
|
+
return this.getPositions(portfolio).find(p => p.position === position) || null;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1366
1380
|
/**
|
|
1367
1381
|
* Pauses aggregation calculations during the processing of an action.
|
|
1368
1382
|
*
|
|
@@ -1436,7 +1450,7 @@ module.exports = (() => {
|
|
|
1436
1450
|
let returnRef = null;
|
|
1437
1451
|
|
|
1438
1452
|
if (groupNode) {
|
|
1439
|
-
const resultNode = groupNode.findParent(
|
|
1453
|
+
const resultNode = groupNode.findParent((candidateGroup, candidateNode) => !candidateNode.getIsRoot() && predicate(candidateGroup));
|
|
1440
1454
|
|
|
1441
1455
|
if (resultNode) {
|
|
1442
1456
|
returnRef = resultNode.getValue();
|