@barchart/portfolio-api-common 1.2.106 → 1.2.107
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.
- package/lib/processing/PositionContainer.js +8 -4
- package/package.json +1 -1
- package/test/SpecRunner.js +107 -13
|
@@ -104,7 +104,7 @@ module.exports = (() => {
|
|
|
104
104
|
}, { });
|
|
105
105
|
|
|
106
106
|
this._items = positions.reduce((items, position) => {
|
|
107
|
-
const item = createPositionItem.call(this, position);
|
|
107
|
+
const item = createPositionItem.call(this, position, reportFrame ? true : false);
|
|
108
108
|
|
|
109
109
|
if (item) {
|
|
110
110
|
items.push(item);
|
|
@@ -313,7 +313,7 @@ module.exports = (() => {
|
|
|
313
313
|
addSummaryPrevious(this._summariesPrevious, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
314
314
|
});
|
|
315
315
|
|
|
316
|
-
const item = createPositionItem.call(this, position);
|
|
316
|
+
const item = createPositionItem.call(this, position, false);
|
|
317
317
|
|
|
318
318
|
addBarchartSymbol(this._symbols, item);
|
|
319
319
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
@@ -959,7 +959,7 @@ module.exports = (() => {
|
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
961
|
|
|
962
|
-
function createPositionItem(position,
|
|
962
|
+
function createPositionItem(position, requireCurrentSummary) {
|
|
963
963
|
const portfolio = this._portfolios[position.portfolio];
|
|
964
964
|
|
|
965
965
|
let returnRef;
|
|
@@ -968,7 +968,11 @@ module.exports = (() => {
|
|
|
968
968
|
const currentSummary = this._summariesCurrent[ position.position ] || null;
|
|
969
969
|
const previousSummaries = this._summariesPrevious[ position.position ] || getSummaryArray(this._previousSummaryRanges);
|
|
970
970
|
|
|
971
|
-
|
|
971
|
+
if (!requireCurrentSummary || currentSummary !== null) {
|
|
972
|
+
returnRef = new PositionItem(portfolio, position, currentSummary, previousSummaries, this._reporting);
|
|
973
|
+
} else {
|
|
974
|
+
returnRef = null;
|
|
975
|
+
}
|
|
972
976
|
} else {
|
|
973
977
|
returnRef = null;
|
|
974
978
|
}
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1528,7 +1528,7 @@ module.exports = (() => {
|
|
|
1528
1528
|
}, { });
|
|
1529
1529
|
|
|
1530
1530
|
this._items = positions.reduce((items, position) => {
|
|
1531
|
-
const item = createPositionItem.call(this, position);
|
|
1531
|
+
const item = createPositionItem.call(this, position, reportFrame ? true : false);
|
|
1532
1532
|
|
|
1533
1533
|
if (item) {
|
|
1534
1534
|
items.push(item);
|
|
@@ -1737,7 +1737,7 @@ module.exports = (() => {
|
|
|
1737
1737
|
addSummaryPrevious(this._summariesPrevious, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
1738
1738
|
});
|
|
1739
1739
|
|
|
1740
|
-
const item = createPositionItem.call(this, position);
|
|
1740
|
+
const item = createPositionItem.call(this, position, false);
|
|
1741
1741
|
|
|
1742
1742
|
addBarchartSymbol(this._symbols, item);
|
|
1743
1743
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
@@ -2383,7 +2383,7 @@ module.exports = (() => {
|
|
|
2383
2383
|
}
|
|
2384
2384
|
}
|
|
2385
2385
|
|
|
2386
|
-
function createPositionItem(position,
|
|
2386
|
+
function createPositionItem(position, requireCurrentSummary) {
|
|
2387
2387
|
const portfolio = this._portfolios[position.portfolio];
|
|
2388
2388
|
|
|
2389
2389
|
let returnRef;
|
|
@@ -2392,7 +2392,11 @@ module.exports = (() => {
|
|
|
2392
2392
|
const currentSummary = this._summariesCurrent[ position.position ] || null;
|
|
2393
2393
|
const previousSummaries = this._summariesPrevious[ position.position ] || getSummaryArray(this._previousSummaryRanges);
|
|
2394
2394
|
|
|
2395
|
-
|
|
2395
|
+
if (!requireCurrentSummary || currentSummary !== null) {
|
|
2396
|
+
returnRef = new PositionItem(portfolio, position, currentSummary, previousSummaries, this._reporting);
|
|
2397
|
+
} else {
|
|
2398
|
+
returnRef = null;
|
|
2399
|
+
}
|
|
2396
2400
|
} else {
|
|
2397
2401
|
returnRef = null;
|
|
2398
2402
|
}
|
|
@@ -6295,12 +6299,11 @@ module.exports = function () {
|
|
|
6295
6299
|
}
|
|
6296
6300
|
|
|
6297
6301
|
/**
|
|
6298
|
-
*
|
|
6299
|
-
* a {@link Day} instance.
|
|
6302
|
+
* Clones a {@link Day} instance.
|
|
6300
6303
|
*
|
|
6301
6304
|
* @public
|
|
6302
6305
|
* @static
|
|
6303
|
-
* @param {
|
|
6306
|
+
* @param {Day} value
|
|
6304
6307
|
* @returns {Day}
|
|
6305
6308
|
*/
|
|
6306
6309
|
|
|
@@ -6341,6 +6344,24 @@ module.exports = function () {
|
|
|
6341
6344
|
return this._day;
|
|
6342
6345
|
}
|
|
6343
6346
|
}], [{
|
|
6347
|
+
key: 'clone',
|
|
6348
|
+
value: function clone(value) {
|
|
6349
|
+
assert.argumentIsRequired(value, 'value', Day, 'Day');
|
|
6350
|
+
|
|
6351
|
+
return new Day(value.year, value.month, value.day);
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6354
|
+
/**
|
|
6355
|
+
* Converts a string (which matches the output of {@link Day#format} into
|
|
6356
|
+
* a {@link Day} instance.
|
|
6357
|
+
*
|
|
6358
|
+
* @public
|
|
6359
|
+
* @static
|
|
6360
|
+
* @param {String} value
|
|
6361
|
+
* @returns {Day}
|
|
6362
|
+
*/
|
|
6363
|
+
|
|
6364
|
+
}, {
|
|
6344
6365
|
key: 'parse',
|
|
6345
6366
|
value: function parse(value) {
|
|
6346
6367
|
assert.argumentIsRequired(value, 'value', String);
|
|
@@ -6657,15 +6678,17 @@ module.exports = function () {
|
|
|
6657
6678
|
*
|
|
6658
6679
|
* @public
|
|
6659
6680
|
* @param {Boolean=} approximate
|
|
6681
|
+
* @param {Number=} places
|
|
6660
6682
|
* @returns {Boolean}
|
|
6661
6683
|
*/
|
|
6662
6684
|
|
|
6663
6685
|
}, {
|
|
6664
6686
|
key: 'getIsZero',
|
|
6665
|
-
value: function getIsZero(approximate) {
|
|
6687
|
+
value: function getIsZero(approximate, places) {
|
|
6666
6688
|
assert.argumentIsOptional(approximate, 'approximate', Boolean);
|
|
6689
|
+
assert.argumentIsOptional(places, 'places', Number);
|
|
6667
6690
|
|
|
6668
|
-
return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(
|
|
6691
|
+
return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(places || Big.DP, RoundingMode.NORMAL).getIsZero();
|
|
6669
6692
|
}
|
|
6670
6693
|
|
|
6671
6694
|
/**
|
|
@@ -6764,6 +6787,43 @@ module.exports = function () {
|
|
|
6764
6787
|
return this._big.eq(getBig(other));
|
|
6765
6788
|
}
|
|
6766
6789
|
|
|
6790
|
+
/**
|
|
6791
|
+
* Returns true if the current instance is an integer (i.e. has no decimal
|
|
6792
|
+
* component).
|
|
6793
|
+
*
|
|
6794
|
+
* @public
|
|
6795
|
+
* @return {Boolean}
|
|
6796
|
+
*/
|
|
6797
|
+
|
|
6798
|
+
}, {
|
|
6799
|
+
key: 'getIsInteger',
|
|
6800
|
+
value: function getIsInteger() {
|
|
6801
|
+
return this.getIsEqual(this.round(0));
|
|
6802
|
+
}
|
|
6803
|
+
|
|
6804
|
+
/**
|
|
6805
|
+
* Returns the number of decimal places used.
|
|
6806
|
+
*
|
|
6807
|
+
* @public
|
|
6808
|
+
* @returns {Number}
|
|
6809
|
+
*/
|
|
6810
|
+
|
|
6811
|
+
}, {
|
|
6812
|
+
key: 'getDecimalPlaces',
|
|
6813
|
+
value: function getDecimalPlaces() {
|
|
6814
|
+
var matches = this.toFixed().match(/-?\d*\.(\d*)/);
|
|
6815
|
+
|
|
6816
|
+
var returnVal = void 0;
|
|
6817
|
+
|
|
6818
|
+
if (matches === null) {
|
|
6819
|
+
returnVal = 0;
|
|
6820
|
+
} else {
|
|
6821
|
+
returnVal = matches[1].length;
|
|
6822
|
+
}
|
|
6823
|
+
|
|
6824
|
+
return returnVal;
|
|
6825
|
+
}
|
|
6826
|
+
|
|
6767
6827
|
/**
|
|
6768
6828
|
* Emits a floating point value that approximates the value of the current
|
|
6769
6829
|
* instance.
|
|
@@ -6812,10 +6872,11 @@ module.exports = function () {
|
|
|
6812
6872
|
}
|
|
6813
6873
|
|
|
6814
6874
|
/**
|
|
6815
|
-
*
|
|
6875
|
+
* Clones a {@link Decimal} instance.
|
|
6816
6876
|
*
|
|
6817
6877
|
* @public
|
|
6818
|
-
* @
|
|
6878
|
+
* @static
|
|
6879
|
+
* @param {Decimal} value
|
|
6819
6880
|
* @returns {Decimal}
|
|
6820
6881
|
*/
|
|
6821
6882
|
|
|
@@ -6825,6 +6886,22 @@ module.exports = function () {
|
|
|
6825
6886
|
return '[Decimal]';
|
|
6826
6887
|
}
|
|
6827
6888
|
}], [{
|
|
6889
|
+
key: 'clone',
|
|
6890
|
+
value: function clone(value) {
|
|
6891
|
+
assert.argumentIsRequired(value, 'value', Decimal, 'Decimal');
|
|
6892
|
+
|
|
6893
|
+
return new Decimal(value._big);
|
|
6894
|
+
}
|
|
6895
|
+
|
|
6896
|
+
/**
|
|
6897
|
+
* Parses the value emitted by {@link Decimal#toJSON}.
|
|
6898
|
+
*
|
|
6899
|
+
* @public
|
|
6900
|
+
* @param {String} value
|
|
6901
|
+
* @returns {Decimal}
|
|
6902
|
+
*/
|
|
6903
|
+
|
|
6904
|
+
}, {
|
|
6828
6905
|
key: 'parse',
|
|
6829
6906
|
value: function parse(value) {
|
|
6830
6907
|
return new Decimal(value);
|
|
@@ -7846,10 +7923,11 @@ module.exports = function () {
|
|
|
7846
7923
|
}
|
|
7847
7924
|
|
|
7848
7925
|
/**
|
|
7849
|
-
*
|
|
7926
|
+
* Clones a {@link Timestamp} instance.
|
|
7850
7927
|
*
|
|
7851
7928
|
* @public
|
|
7852
|
-
* @
|
|
7929
|
+
* @static
|
|
7930
|
+
* @param {Timestamp} value
|
|
7853
7931
|
* @returns {Timestamp}
|
|
7854
7932
|
*/
|
|
7855
7933
|
|
|
@@ -7885,6 +7963,22 @@ module.exports = function () {
|
|
|
7885
7963
|
return this._moment;
|
|
7886
7964
|
}
|
|
7887
7965
|
}], [{
|
|
7966
|
+
key: 'clone',
|
|
7967
|
+
value: function clone(value) {
|
|
7968
|
+
assert.argumentIsRequired(value, 'value', Timestamp, 'Timestamp');
|
|
7969
|
+
|
|
7970
|
+
return new Timestamp(value._timestamp, value._timezone);
|
|
7971
|
+
}
|
|
7972
|
+
|
|
7973
|
+
/**
|
|
7974
|
+
* Parses the value emitted by {@link Timestamp#toJSON}.
|
|
7975
|
+
*
|
|
7976
|
+
* @public
|
|
7977
|
+
* @param {Number} value
|
|
7978
|
+
* @returns {Timestamp}
|
|
7979
|
+
*/
|
|
7980
|
+
|
|
7981
|
+
}, {
|
|
7888
7982
|
key: 'parse',
|
|
7889
7983
|
value: function parse(value) {
|
|
7890
7984
|
return new Timestamp(value);
|