@barchart/portfolio-api-common 1.2.98 → 1.2.102
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.
|
@@ -3,6 +3,7 @@ const array = require('@barchart/common-js/lang/array'),
|
|
|
3
3
|
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
4
4
|
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
5
5
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
6
|
+
Day = require('@barchart/common-js/lang/Day'),
|
|
6
7
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
7
8
|
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
8
9
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
@@ -43,15 +44,20 @@ module.exports = (() => {
|
|
|
43
44
|
* @param {Array.<Object>} positions - The positions (for all of the portfolios).
|
|
44
45
|
* @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
|
|
45
46
|
* @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
|
|
47
|
+
* @param {Day=} reportDate - The end date for the report frame.
|
|
46
48
|
*/
|
|
47
49
|
class PositionContainer {
|
|
48
|
-
constructor(definitions, portfolios, positions, summaries, reportFrame) {
|
|
50
|
+
constructor(definitions, portfolios, positions, summaries, reportFrame, reportDate) {
|
|
49
51
|
assert.argumentIsArray(definitions, 'definitions', PositionTreeDefinition, 'PositionTreeDefinition');
|
|
50
52
|
assert.argumentIsArray(portfolios, 'portfolios');
|
|
51
53
|
assert.argumentIsArray(positions, 'positions');
|
|
52
54
|
assert.argumentIsArray(summaries, 'summaries');
|
|
53
55
|
assert.argumentIsOptional(reportFrame, 'reportFrame', PositionSummaryFrame, 'PositionSummaryFrame');
|
|
54
56
|
|
|
57
|
+
if (reportFrame) {
|
|
58
|
+
assert.argumentIsRequired(reportDate, 'reportDate', Day, 'Day');
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
this._definitions = definitions;
|
|
56
62
|
|
|
57
63
|
this._groupBindings = { };
|
|
@@ -67,15 +73,21 @@ module.exports = (() => {
|
|
|
67
73
|
return map;
|
|
68
74
|
}, { });
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
if (reportFrame) {
|
|
77
|
+
this._currentSummaryFrame = reportFrame;
|
|
78
|
+
this._currentSummaryRange = array.last(this._currentSummaryFrame.getPriorRanges(reportDate, 0));
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
this._previousSummaryFrame = reportFrame;
|
|
81
|
+
this._previousSummaryRanges = this._currentSummaryFrame.getPriorRanges(reportDate, 3);
|
|
75
82
|
|
|
76
|
-
if (this._currentSummaryFrame === this._previousSummaryFrame) {
|
|
77
83
|
this._previousSummaryRanges.pop();
|
|
78
84
|
} else {
|
|
85
|
+
this._currentSummaryFrame = PositionSummaryFrame.YTD;
|
|
86
|
+
this._currentSummaryRange = array.first(this._currentSummaryFrame.getRecentRanges(0));
|
|
87
|
+
|
|
88
|
+
this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
|
|
89
|
+
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(3);
|
|
90
|
+
|
|
79
91
|
this._previousSummaryRanges.shift();
|
|
80
92
|
}
|
|
81
93
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -677,7 +677,7 @@ module.exports = (() => {
|
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
function getYearlyRangeDescription(start, end) {
|
|
680
|
-
return `Year ended ${end.
|
|
680
|
+
return `Year ended ${end.format()}`;
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
function getQuarterlyRangeDescription(start, end) {
|
|
@@ -1427,6 +1427,7 @@ const array = require('@barchart/common-js/lang/array'),
|
|
|
1427
1427
|
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
1428
1428
|
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
1429
1429
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
1430
|
+
Day = require('@barchart/common-js/lang/Day'),
|
|
1430
1431
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
1431
1432
|
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
1432
1433
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
@@ -1467,15 +1468,20 @@ module.exports = (() => {
|
|
|
1467
1468
|
* @param {Array.<Object>} positions - The positions (for all of the portfolios).
|
|
1468
1469
|
* @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
|
|
1469
1470
|
* @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
|
|
1471
|
+
* @param {Day=} reportDate - The end date for the report frame.
|
|
1470
1472
|
*/
|
|
1471
1473
|
class PositionContainer {
|
|
1472
|
-
constructor(definitions, portfolios, positions, summaries, reportFrame) {
|
|
1474
|
+
constructor(definitions, portfolios, positions, summaries, reportFrame, reportDate) {
|
|
1473
1475
|
assert.argumentIsArray(definitions, 'definitions', PositionTreeDefinition, 'PositionTreeDefinition');
|
|
1474
1476
|
assert.argumentIsArray(portfolios, 'portfolios');
|
|
1475
1477
|
assert.argumentIsArray(positions, 'positions');
|
|
1476
1478
|
assert.argumentIsArray(summaries, 'summaries');
|
|
1477
1479
|
assert.argumentIsOptional(reportFrame, 'reportFrame', PositionSummaryFrame, 'PositionSummaryFrame');
|
|
1478
1480
|
|
|
1481
|
+
if (reportFrame) {
|
|
1482
|
+
assert.argumentIsRequired(reportDate, 'reportDate', Day, 'Day');
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1479
1485
|
this._definitions = definitions;
|
|
1480
1486
|
|
|
1481
1487
|
this._groupBindings = { };
|
|
@@ -1491,15 +1497,21 @@ module.exports = (() => {
|
|
|
1491
1497
|
return map;
|
|
1492
1498
|
}, { });
|
|
1493
1499
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1500
|
+
if (reportFrame) {
|
|
1501
|
+
this._currentSummaryFrame = reportFrame;
|
|
1502
|
+
this._currentSummaryRange = array.last(this._currentSummaryFrame.getPriorRanges(reportDate, 0));
|
|
1496
1503
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1504
|
+
this._previousSummaryFrame = reportFrame;
|
|
1505
|
+
this._previousSummaryRanges = this._currentSummaryFrame.getPriorRanges(reportDate, 3);
|
|
1499
1506
|
|
|
1500
|
-
if (this._currentSummaryFrame === this._previousSummaryFrame) {
|
|
1501
1507
|
this._previousSummaryRanges.pop();
|
|
1502
1508
|
} else {
|
|
1509
|
+
this._currentSummaryFrame = PositionSummaryFrame.YTD;
|
|
1510
|
+
this._currentSummaryRange = array.first(this._currentSummaryFrame.getRecentRanges(0));
|
|
1511
|
+
|
|
1512
|
+
this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
|
|
1513
|
+
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(3);
|
|
1514
|
+
|
|
1503
1515
|
this._previousSummaryRanges.shift();
|
|
1504
1516
|
}
|
|
1505
1517
|
|
|
@@ -2429,7 +2441,7 @@ module.exports = (() => {
|
|
|
2429
2441
|
return PositionContainer;
|
|
2430
2442
|
})();
|
|
2431
2443
|
|
|
2432
|
-
},{"./../data/PositionSummaryFrame":3,"./PositionGroup":7,"./PositionItem":8,"./definitions/PositionLevelDefinition":9,"./definitions/PositionLevelType":10,"./definitions/PositionTreeDefinition":11,"@barchart/common-js/collections/Tree":15,"@barchart/common-js/collections/sorting/ComparatorBuilder":16,"@barchart/common-js/collections/sorting/comparators":17,"@barchart/common-js/collections/specialized/DisposableStack":18,"@barchart/common-js/lang/Currency":20,"@barchart/common-js/lang/Decimal":22,"@barchart/common-js/lang/Rate":26,"@barchart/common-js/lang/array":28,"@barchart/common-js/lang/assert":29,"@barchart/common-js/lang/is":33,"@barchart/common-js/messaging/Event":35}],7:[function(require,module,exports){
|
|
2444
|
+
},{"./../data/PositionSummaryFrame":3,"./PositionGroup":7,"./PositionItem":8,"./definitions/PositionLevelDefinition":9,"./definitions/PositionLevelType":10,"./definitions/PositionTreeDefinition":11,"@barchart/common-js/collections/Tree":15,"@barchart/common-js/collections/sorting/ComparatorBuilder":16,"@barchart/common-js/collections/sorting/comparators":17,"@barchart/common-js/collections/specialized/DisposableStack":18,"@barchart/common-js/lang/Currency":20,"@barchart/common-js/lang/Day":21,"@barchart/common-js/lang/Decimal":22,"@barchart/common-js/lang/Rate":26,"@barchart/common-js/lang/array":28,"@barchart/common-js/lang/assert":29,"@barchart/common-js/lang/is":33,"@barchart/common-js/messaging/Event":35}],7:[function(require,module,exports){
|
|
2433
2445
|
const array = require('@barchart/common-js/lang/array'),
|
|
2434
2446
|
assert = require('@barchart/common-js/lang/assert'),
|
|
2435
2447
|
Currency = require('@barchart/common-js/lang/Currency'),
|