@barchart/portfolio-api-common 1.2.105 → 1.2.106
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.
|
@@ -166,10 +166,14 @@ module.exports = (() => {
|
|
|
166
166
|
this._dataFormat.cashTotal = null;
|
|
167
167
|
this._dataFormat.portfolioType = null;
|
|
168
168
|
|
|
169
|
+
this._dataActual.periodPrice = null;
|
|
170
|
+
this._dataActual.periodPricePrevious = null;
|
|
169
171
|
this._dataActual.periodRealized = null;
|
|
170
172
|
this._dataActual.periodUnrealized = null;
|
|
171
173
|
this._dataActual.periodIncome = null;
|
|
172
174
|
|
|
175
|
+
this._dataFormat.periodPrice = null;
|
|
176
|
+
this._dataFormat.periodPricePrevious = null;
|
|
173
177
|
this._dataFormat.periodRealized = null;
|
|
174
178
|
this._dataFormat.periodUnrealized = null;
|
|
175
179
|
this._dataFormat.periodIncome = null;
|
|
@@ -735,11 +739,17 @@ module.exports = (() => {
|
|
|
735
739
|
|
|
736
740
|
actual.basisPrice = item.data.basisPrice;
|
|
737
741
|
|
|
742
|
+
actual.periodPrice = item.data.periodPrice;
|
|
743
|
+
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
744
|
+
|
|
738
745
|
format.quantity = formatDecimal(actual.quantity, 2);
|
|
739
746
|
format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
|
|
740
|
-
|
|
747
|
+
|
|
741
748
|
format.basisPrice = formatCurrency(actual.basisPrice, currency);
|
|
742
749
|
|
|
750
|
+
format.periodPrice = formatCurrency(actual.periodPrice, currency);
|
|
751
|
+
format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
|
|
752
|
+
|
|
743
753
|
format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
|
|
744
754
|
format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
|
|
745
755
|
}
|
|
@@ -78,8 +78,12 @@ module.exports = (() => {
|
|
|
78
78
|
this._data.income = null;
|
|
79
79
|
this._data.basisPrice = null;
|
|
80
80
|
|
|
81
|
-
this._data.
|
|
82
|
-
this._data.
|
|
81
|
+
this._data.periodRealized = null;
|
|
82
|
+
this._data.periodUnrealized = null;
|
|
83
|
+
this._data.periodIncome = null;
|
|
84
|
+
|
|
85
|
+
this._data.periodPrice = null;
|
|
86
|
+
this._data.periodPricePrevious = null;
|
|
83
87
|
|
|
84
88
|
this._data.newsExists = false;
|
|
85
89
|
this._data.fundamental = { };
|
|
@@ -370,13 +374,14 @@ module.exports = (() => {
|
|
|
370
374
|
|
|
371
375
|
function calculateStaticData(item) {
|
|
372
376
|
const position = item.position;
|
|
373
|
-
const snapshot = getSnapshot(position, item.currentSummary, item._reporting);
|
|
374
377
|
|
|
375
|
-
const
|
|
378
|
+
const currentSummary = item.currentSummary;
|
|
379
|
+
|
|
380
|
+
const previousSummary1 = getPreviousSummary(item.previousSummaries, 1);
|
|
381
|
+
const previousSummary2 = getPreviousSummary(item.previousSummaries, 2);
|
|
382
|
+
const previousSummary3 = getPreviousSummary(item.previousSummaries, 3);
|
|
376
383
|
|
|
377
|
-
const
|
|
378
|
-
const previousSummary2 = getPreviousSummary(previousSummaries, 2);
|
|
379
|
-
const previousSummary3 = getPreviousSummary(previousSummaries, 3);
|
|
384
|
+
const snapshot = getSnapshot(position, currentSummary, item._reporting);
|
|
380
385
|
|
|
381
386
|
const data = item._data;
|
|
382
387
|
|
|
@@ -414,6 +419,18 @@ module.exports = (() => {
|
|
|
414
419
|
} else {
|
|
415
420
|
data.basisPrice = basis.divide(snapshot.open);
|
|
416
421
|
}
|
|
422
|
+
|
|
423
|
+
if (currentSummary && !currentSummary.end.open.getIsZero()) {
|
|
424
|
+
data.periodPrice = currentSummary.end.value.divide(currentSummary.end.open);
|
|
425
|
+
} else {
|
|
426
|
+
data.periodPrice = null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (previousSummary1 && !previousSummary1.end.open.getIsZero()) {
|
|
430
|
+
data.periodPricePrevious = previousSummary1.end.value.divide(previousSummary1.end.open);
|
|
431
|
+
} else {
|
|
432
|
+
data.periodPricePrevious = null;
|
|
433
|
+
}
|
|
417
434
|
}
|
|
418
435
|
|
|
419
436
|
function calculatePriceData(item, price) {
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -2622,10 +2622,14 @@ module.exports = (() => {
|
|
|
2622
2622
|
this._dataFormat.cashTotal = null;
|
|
2623
2623
|
this._dataFormat.portfolioType = null;
|
|
2624
2624
|
|
|
2625
|
+
this._dataActual.periodPrice = null;
|
|
2626
|
+
this._dataActual.periodPricePrevious = null;
|
|
2625
2627
|
this._dataActual.periodRealized = null;
|
|
2626
2628
|
this._dataActual.periodUnrealized = null;
|
|
2627
2629
|
this._dataActual.periodIncome = null;
|
|
2628
2630
|
|
|
2631
|
+
this._dataFormat.periodPrice = null;
|
|
2632
|
+
this._dataFormat.periodPricePrevious = null;
|
|
2629
2633
|
this._dataFormat.periodRealized = null;
|
|
2630
2634
|
this._dataFormat.periodUnrealized = null;
|
|
2631
2635
|
this._dataFormat.periodIncome = null;
|
|
@@ -3191,11 +3195,17 @@ module.exports = (() => {
|
|
|
3191
3195
|
|
|
3192
3196
|
actual.basisPrice = item.data.basisPrice;
|
|
3193
3197
|
|
|
3198
|
+
actual.periodPrice = item.data.periodPrice;
|
|
3199
|
+
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
3200
|
+
|
|
3194
3201
|
format.quantity = formatDecimal(actual.quantity, 2);
|
|
3195
3202
|
format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
|
|
3196
|
-
|
|
3203
|
+
|
|
3197
3204
|
format.basisPrice = formatCurrency(actual.basisPrice, currency);
|
|
3198
3205
|
|
|
3206
|
+
format.periodPrice = formatCurrency(actual.periodPrice, currency);
|
|
3207
|
+
format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
|
|
3208
|
+
|
|
3199
3209
|
format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
|
|
3200
3210
|
format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
|
|
3201
3211
|
}
|
|
@@ -3465,8 +3475,12 @@ module.exports = (() => {
|
|
|
3465
3475
|
this._data.income = null;
|
|
3466
3476
|
this._data.basisPrice = null;
|
|
3467
3477
|
|
|
3468
|
-
this._data.
|
|
3469
|
-
this._data.
|
|
3478
|
+
this._data.periodRealized = null;
|
|
3479
|
+
this._data.periodUnrealized = null;
|
|
3480
|
+
this._data.periodIncome = null;
|
|
3481
|
+
|
|
3482
|
+
this._data.periodPrice = null;
|
|
3483
|
+
this._data.periodPricePrevious = null;
|
|
3470
3484
|
|
|
3471
3485
|
this._data.newsExists = false;
|
|
3472
3486
|
this._data.fundamental = { };
|
|
@@ -3757,13 +3771,14 @@ module.exports = (() => {
|
|
|
3757
3771
|
|
|
3758
3772
|
function calculateStaticData(item) {
|
|
3759
3773
|
const position = item.position;
|
|
3760
|
-
const snapshot = getSnapshot(position, item.currentSummary, item._reporting);
|
|
3761
3774
|
|
|
3762
|
-
const
|
|
3775
|
+
const currentSummary = item.currentSummary;
|
|
3763
3776
|
|
|
3764
|
-
const previousSummary1 = getPreviousSummary(previousSummaries, 1);
|
|
3765
|
-
const previousSummary2 = getPreviousSummary(previousSummaries, 2);
|
|
3766
|
-
const previousSummary3 = getPreviousSummary(previousSummaries, 3);
|
|
3777
|
+
const previousSummary1 = getPreviousSummary(item.previousSummaries, 1);
|
|
3778
|
+
const previousSummary2 = getPreviousSummary(item.previousSummaries, 2);
|
|
3779
|
+
const previousSummary3 = getPreviousSummary(item.previousSummaries, 3);
|
|
3780
|
+
|
|
3781
|
+
const snapshot = getSnapshot(position, currentSummary, item._reporting);
|
|
3767
3782
|
|
|
3768
3783
|
const data = item._data;
|
|
3769
3784
|
|
|
@@ -3801,6 +3816,18 @@ module.exports = (() => {
|
|
|
3801
3816
|
} else {
|
|
3802
3817
|
data.basisPrice = basis.divide(snapshot.open);
|
|
3803
3818
|
}
|
|
3819
|
+
|
|
3820
|
+
if (currentSummary && !currentSummary.end.open.getIsZero()) {
|
|
3821
|
+
data.periodPrice = currentSummary.end.value.divide(currentSummary.end.open);
|
|
3822
|
+
} else {
|
|
3823
|
+
data.periodPrice = null;
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
if (previousSummary1 && !previousSummary1.end.open.getIsZero()) {
|
|
3827
|
+
data.periodPricePrevious = previousSummary1.end.value.divide(previousSummary1.end.open);
|
|
3828
|
+
} else {
|
|
3829
|
+
data.periodPricePrevious = null;
|
|
3830
|
+
}
|
|
3804
3831
|
}
|
|
3805
3832
|
|
|
3806
3833
|
function calculatePriceData(item, price) {
|