@barchart/portfolio-api-common 1.2.86 → 1.2.90
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.
|
@@ -284,6 +284,14 @@ module.exports = (() => {
|
|
|
284
284
|
|
|
285
285
|
const existingBarchartSymbols = this.getPositionSymbols(false);
|
|
286
286
|
|
|
287
|
+
let similarPositionItem;
|
|
288
|
+
|
|
289
|
+
if (extractSymbolForBarchart(position)) {
|
|
290
|
+
similarPositionItem = this._items.find(item => extractSymbolForBarchart(item.position) === extractSymbolForBarchart(position)) || null;
|
|
291
|
+
} else {
|
|
292
|
+
similarPositionItem = null;
|
|
293
|
+
}
|
|
294
|
+
|
|
287
295
|
removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
|
|
288
296
|
|
|
289
297
|
summaries.forEach((summary) => {
|
|
@@ -331,6 +339,16 @@ module.exports = (() => {
|
|
|
331
339
|
this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
|
|
332
340
|
}
|
|
333
341
|
|
|
342
|
+
if (similarPositionItem !== null) {
|
|
343
|
+
if (similarPositionItem.previousQuote) {
|
|
344
|
+
item.setQuote(similarPositionItem.previousQuote);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (similarPositionItem.quote) {
|
|
348
|
+
item.setQuote(similarPositionItem.quote);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
334
352
|
recalculatePercentages.call(this);
|
|
335
353
|
}
|
|
336
354
|
|
|
@@ -915,7 +933,7 @@ module.exports = (() => {
|
|
|
915
933
|
}
|
|
916
934
|
}
|
|
917
935
|
|
|
918
|
-
function createPositionItem(position) {
|
|
936
|
+
function createPositionItem(position, currentQuote, previousQuote) {
|
|
919
937
|
const portfolio = this._portfolios[position.portfolio];
|
|
920
938
|
|
|
921
939
|
let returnRef;
|
|
@@ -130,6 +130,10 @@ module.exports = (() => {
|
|
|
130
130
|
this._dataActual.summaryTotalCurrent = null;
|
|
131
131
|
this._dataActual.summaryTotalPrevious = null;
|
|
132
132
|
this._dataActual.summaryTotalPrevious2 = null;
|
|
133
|
+
this._dataActual.endingPrevious = null;
|
|
134
|
+
this._dataActual.endingPrevious2 = null;
|
|
135
|
+
this._dataActual.endingChange = null;
|
|
136
|
+
this._dataActual.endingChangePercent = null;
|
|
133
137
|
this._dataActual.cashTotal = null;
|
|
134
138
|
|
|
135
139
|
this._dataFormat.currentPrice = null;
|
|
@@ -153,6 +157,10 @@ module.exports = (() => {
|
|
|
153
157
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
154
158
|
this._dataFormat.summaryTotalPrevious2 = null;
|
|
155
159
|
this._dataFormat.summaryTotalPrevious2Negative = false;
|
|
160
|
+
this._dataFormat.endingPrevious = null;
|
|
161
|
+
this._dataFormat.endingPrevious2 = null;
|
|
162
|
+
this._dataFormat.endingChange = null;
|
|
163
|
+
this._dataFormat.endingChangePercent = null;
|
|
156
164
|
this._dataFormat.cashTotal = null;
|
|
157
165
|
this._dataFormat.portfolioType = null;
|
|
158
166
|
|
|
@@ -388,8 +396,6 @@ module.exports = (() => {
|
|
|
388
396
|
return;
|
|
389
397
|
}
|
|
390
398
|
|
|
391
|
-
const descriptionSelector = this._definition.descriptionSelector;
|
|
392
|
-
|
|
393
399
|
this._description = PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio);
|
|
394
400
|
|
|
395
401
|
this._dataActual.description = this._description;
|
|
@@ -634,7 +640,7 @@ module.exports = (() => {
|
|
|
634
640
|
const translate = (item, value) => {
|
|
635
641
|
let translated;
|
|
636
642
|
|
|
637
|
-
if (item.currency !== currency) {
|
|
643
|
+
if (item.currency !== currency && !value.getIsZero()) {
|
|
638
644
|
translated = Rate.convert(value, item.currency, currency, ...rates);
|
|
639
645
|
} else {
|
|
640
646
|
translated = value;
|
|
@@ -651,6 +657,8 @@ module.exports = (() => {
|
|
|
651
657
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
652
658
|
updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
|
|
653
659
|
updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
|
|
660
|
+
updates.endingPrevious = updates.endingPrevious.add(translate(item, item.data.endingPrevious));
|
|
661
|
+
updates.endingPrevious2 = updates.endingPrevious2.add(translate(item, item.data.endingPrevious2));
|
|
654
662
|
|
|
655
663
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
656
664
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -665,6 +673,8 @@ module.exports = (() => {
|
|
|
665
673
|
summaryTotalCurrent: Decimal.ZERO,
|
|
666
674
|
summaryTotalPrevious: Decimal.ZERO,
|
|
667
675
|
summaryTotalPrevious2: Decimal.ZERO,
|
|
676
|
+
endingPrevious: Decimal.ZERO,
|
|
677
|
+
endingPrevious2: Decimal.ZERO,
|
|
668
678
|
cashTotal: Decimal.ZERO
|
|
669
679
|
});
|
|
670
680
|
|
|
@@ -675,6 +685,8 @@ module.exports = (() => {
|
|
|
675
685
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
676
686
|
actual.summaryTotalPrevious = updates.summaryTotalPrevious;
|
|
677
687
|
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
688
|
+
actual.endingPrevious = updates.endingPrevious;
|
|
689
|
+
actual.endingPrevious2 = updates.endingPrevious2;
|
|
678
690
|
actual.cashTotal = updates.cashTotal;
|
|
679
691
|
|
|
680
692
|
format.basis = formatCurrency(actual.basis, currency);
|
|
@@ -686,6 +698,8 @@ module.exports = (() => {
|
|
|
686
698
|
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
687
699
|
format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
|
|
688
700
|
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
701
|
+
format.endingPrevious = formatCurrency(updates.endingPrevious, currency);
|
|
702
|
+
format.endingPrevious2 = formatCurrency(updates.endingPrevious2, currency);
|
|
689
703
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
690
704
|
|
|
691
705
|
calculateUnrealizedPercent(group);
|
|
@@ -735,7 +749,7 @@ module.exports = (() => {
|
|
|
735
749
|
const translate = (item, value) => {
|
|
736
750
|
let translated;
|
|
737
751
|
|
|
738
|
-
if (item.currency !== currency) {
|
|
752
|
+
if (item.currency !== currency && !value.getIsZero()) {
|
|
739
753
|
translated = Rate.convert(value, item.currency, currency, ...rates);
|
|
740
754
|
} else {
|
|
741
755
|
translated = value;
|
|
@@ -782,7 +796,25 @@ module.exports = (() => {
|
|
|
782
796
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
783
797
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
784
798
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
785
|
-
|
|
799
|
+
|
|
800
|
+
let endingChange = updates.market.subtract(actual.endingPrevious);
|
|
801
|
+
let endingChangePercent;
|
|
802
|
+
|
|
803
|
+
if (actual.endingPrevious.getIsZero()) {
|
|
804
|
+
if (endingChange.getIsPositive()) {
|
|
805
|
+
endingChangePercent = Decimal.ONE;
|
|
806
|
+
} else if (endingChange.getIsNegative()) {
|
|
807
|
+
endingChangePercent = Decimal.NEGATIVE_ONE;
|
|
808
|
+
} else {
|
|
809
|
+
endingChangePercent = Decimal.ZERO;
|
|
810
|
+
}
|
|
811
|
+
} else {
|
|
812
|
+
endingChangePercent = endingChange.divide(actual.endingPrevious);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
actual.endingChange = endingChange;
|
|
816
|
+
actual.endingChangePercent = endingChangePercent;
|
|
817
|
+
|
|
786
818
|
format.market = formatCurrency(actual.market, currency);
|
|
787
819
|
|
|
788
820
|
if (updates.marketDirection.up || updates.marketDirection.down) {
|
|
@@ -802,6 +834,9 @@ module.exports = (() => {
|
|
|
802
834
|
format.total = formatCurrency(actual.total, currency);
|
|
803
835
|
format.totalNegative = actual.total.getIsNegative();
|
|
804
836
|
|
|
837
|
+
format.endingChange = formatCurrency(actual.endingChange, currency);
|
|
838
|
+
format.endingChangePercent = formatPercent(actual.endingChangePercent, 2);
|
|
839
|
+
|
|
805
840
|
calculateUnrealizedPercent(group);
|
|
806
841
|
}
|
|
807
842
|
|
|
@@ -41,6 +41,7 @@ module.exports = (() => {
|
|
|
41
41
|
this._data.basis = null;
|
|
42
42
|
|
|
43
43
|
this._currentQuote = null;
|
|
44
|
+
this._previousQuote = null;
|
|
44
45
|
this._currentPrice = null;
|
|
45
46
|
|
|
46
47
|
this._data.currentPrice = null;
|
|
@@ -64,6 +65,9 @@ module.exports = (() => {
|
|
|
64
65
|
this._data.summaryTotalPrevious = null;
|
|
65
66
|
this._data.summaryTotalPrevious2 = null;
|
|
66
67
|
|
|
68
|
+
this._data.endingPrevious = null;
|
|
69
|
+
this._data.endingPrevious2 = null;
|
|
70
|
+
|
|
67
71
|
this._data.realized = null;
|
|
68
72
|
this._data.income = null;
|
|
69
73
|
this._data.basisPrice = null;
|
|
@@ -154,7 +158,7 @@ module.exports = (() => {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
/**
|
|
157
|
-
* The
|
|
161
|
+
* The most recent quote for the symbol of the encapsulated position.
|
|
158
162
|
*
|
|
159
163
|
* @public
|
|
160
164
|
* @returns {null|Object}
|
|
@@ -163,6 +167,16 @@ module.exports = (() => {
|
|
|
163
167
|
return this._currentQuote;
|
|
164
168
|
}
|
|
165
169
|
|
|
170
|
+
/**
|
|
171
|
+
* The second most recent quote for the symbol of the encapsulated position.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @returns {null|Object}
|
|
175
|
+
*/
|
|
176
|
+
get previousQuote() {
|
|
177
|
+
return this._previousQuote;
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
updatePortfolio(portfolio) {
|
|
167
181
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
168
182
|
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
@@ -200,6 +214,7 @@ module.exports = (() => {
|
|
|
200
214
|
this._currentPricePrevious = this._currentPrice;
|
|
201
215
|
this._currentPrice = quote.lastPrice;
|
|
202
216
|
|
|
217
|
+
this._previousQuote = this._currentQuote;
|
|
203
218
|
this._currentQuote = quote;
|
|
204
219
|
|
|
205
220
|
this._quoteChangedEvent.fire(this._currentQuote);
|
|
@@ -368,9 +383,16 @@ module.exports = (() => {
|
|
|
368
383
|
|
|
369
384
|
data.income = snapshot.income;
|
|
370
385
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
386
|
+
const previousSummary1 = getPreviousSummary(previousSummaries, 1);
|
|
387
|
+
const previousSummary2 = getPreviousSummary(previousSummaries, 2);
|
|
388
|
+
const previousSummary3 = getPreviousSummary(previousSummaries, 3);
|
|
389
|
+
|
|
390
|
+
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary, previousSummary1);
|
|
391
|
+
data.summaryTotalPrevious = calculateSummaryTotal(previousSummary1, previousSummary2);
|
|
392
|
+
data.summaryTotalPrevious2 = calculateSummaryTotal(previousSummary2, previousSummary3);
|
|
393
|
+
|
|
394
|
+
data.endingPrevious = previousSummary1 === null ? Decimal.ZERO : previousSummary1.end.value;
|
|
395
|
+
data.endingPrevious2 = previousSummary2 === null ? Decimal.ZERO : previousSummary2.end.value;
|
|
374
396
|
|
|
375
397
|
if (snapshot.open.getIsZero()) {
|
|
376
398
|
data.basisPrice = Decimal.ZERO;
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1663,6 +1663,14 @@ module.exports = (() => {
|
|
|
1663
1663
|
|
|
1664
1664
|
const existingBarchartSymbols = this.getPositionSymbols(false);
|
|
1665
1665
|
|
|
1666
|
+
let similarPositionItem;
|
|
1667
|
+
|
|
1668
|
+
if (extractSymbolForBarchart(position)) {
|
|
1669
|
+
similarPositionItem = this._items.find(item => extractSymbolForBarchart(item.position) === extractSymbolForBarchart(position)) || null;
|
|
1670
|
+
} else {
|
|
1671
|
+
similarPositionItem = null;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1666
1674
|
removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
|
|
1667
1675
|
|
|
1668
1676
|
summaries.forEach((summary) => {
|
|
@@ -1710,6 +1718,16 @@ module.exports = (() => {
|
|
|
1710
1718
|
this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
|
|
1711
1719
|
}
|
|
1712
1720
|
|
|
1721
|
+
if (similarPositionItem !== null) {
|
|
1722
|
+
if (similarPositionItem.previousQuote) {
|
|
1723
|
+
item.setQuote(similarPositionItem.previousQuote);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
if (similarPositionItem.quote) {
|
|
1727
|
+
item.setQuote(similarPositionItem.quote);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1713
1731
|
recalculatePercentages.call(this);
|
|
1714
1732
|
}
|
|
1715
1733
|
|
|
@@ -2294,7 +2312,7 @@ module.exports = (() => {
|
|
|
2294
2312
|
}
|
|
2295
2313
|
}
|
|
2296
2314
|
|
|
2297
|
-
function createPositionItem(position) {
|
|
2315
|
+
function createPositionItem(position, currentQuote, previousQuote) {
|
|
2298
2316
|
const portfolio = this._portfolios[position.portfolio];
|
|
2299
2317
|
|
|
2300
2318
|
let returnRef;
|
|
@@ -2497,6 +2515,10 @@ module.exports = (() => {
|
|
|
2497
2515
|
this._dataActual.summaryTotalCurrent = null;
|
|
2498
2516
|
this._dataActual.summaryTotalPrevious = null;
|
|
2499
2517
|
this._dataActual.summaryTotalPrevious2 = null;
|
|
2518
|
+
this._dataActual.endingPrevious = null;
|
|
2519
|
+
this._dataActual.endingPrevious2 = null;
|
|
2520
|
+
this._dataActual.endingChange = null;
|
|
2521
|
+
this._dataActual.endingChangePercent = null;
|
|
2500
2522
|
this._dataActual.cashTotal = null;
|
|
2501
2523
|
|
|
2502
2524
|
this._dataFormat.currentPrice = null;
|
|
@@ -2520,6 +2542,10 @@ module.exports = (() => {
|
|
|
2520
2542
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
2521
2543
|
this._dataFormat.summaryTotalPrevious2 = null;
|
|
2522
2544
|
this._dataFormat.summaryTotalPrevious2Negative = false;
|
|
2545
|
+
this._dataFormat.endingPrevious = null;
|
|
2546
|
+
this._dataFormat.endingPrevious2 = null;
|
|
2547
|
+
this._dataFormat.endingChange = null;
|
|
2548
|
+
this._dataFormat.endingChangePercent = null;
|
|
2523
2549
|
this._dataFormat.cashTotal = null;
|
|
2524
2550
|
this._dataFormat.portfolioType = null;
|
|
2525
2551
|
|
|
@@ -2755,8 +2781,6 @@ module.exports = (() => {
|
|
|
2755
2781
|
return;
|
|
2756
2782
|
}
|
|
2757
2783
|
|
|
2758
|
-
const descriptionSelector = this._definition.descriptionSelector;
|
|
2759
|
-
|
|
2760
2784
|
this._description = PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio);
|
|
2761
2785
|
|
|
2762
2786
|
this._dataActual.description = this._description;
|
|
@@ -3001,7 +3025,7 @@ module.exports = (() => {
|
|
|
3001
3025
|
const translate = (item, value) => {
|
|
3002
3026
|
let translated;
|
|
3003
3027
|
|
|
3004
|
-
if (item.currency !== currency) {
|
|
3028
|
+
if (item.currency !== currency && !value.getIsZero()) {
|
|
3005
3029
|
translated = Rate.convert(value, item.currency, currency, ...rates);
|
|
3006
3030
|
} else {
|
|
3007
3031
|
translated = value;
|
|
@@ -3018,6 +3042,8 @@ module.exports = (() => {
|
|
|
3018
3042
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
3019
3043
|
updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
|
|
3020
3044
|
updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
|
|
3045
|
+
updates.endingPrevious = updates.endingPrevious.add(translate(item, item.data.endingPrevious));
|
|
3046
|
+
updates.endingPrevious2 = updates.endingPrevious2.add(translate(item, item.data.endingPrevious2));
|
|
3021
3047
|
|
|
3022
3048
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
3023
3049
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -3032,6 +3058,8 @@ module.exports = (() => {
|
|
|
3032
3058
|
summaryTotalCurrent: Decimal.ZERO,
|
|
3033
3059
|
summaryTotalPrevious: Decimal.ZERO,
|
|
3034
3060
|
summaryTotalPrevious2: Decimal.ZERO,
|
|
3061
|
+
endingPrevious: Decimal.ZERO,
|
|
3062
|
+
endingPrevious2: Decimal.ZERO,
|
|
3035
3063
|
cashTotal: Decimal.ZERO
|
|
3036
3064
|
});
|
|
3037
3065
|
|
|
@@ -3042,6 +3070,8 @@ module.exports = (() => {
|
|
|
3042
3070
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
3043
3071
|
actual.summaryTotalPrevious = updates.summaryTotalPrevious;
|
|
3044
3072
|
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
3073
|
+
actual.endingPrevious = updates.endingPrevious;
|
|
3074
|
+
actual.endingPrevious2 = updates.endingPrevious2;
|
|
3045
3075
|
actual.cashTotal = updates.cashTotal;
|
|
3046
3076
|
|
|
3047
3077
|
format.basis = formatCurrency(actual.basis, currency);
|
|
@@ -3053,6 +3083,8 @@ module.exports = (() => {
|
|
|
3053
3083
|
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
3054
3084
|
format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
|
|
3055
3085
|
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
3086
|
+
format.endingPrevious = formatCurrency(updates.endingPrevious, currency);
|
|
3087
|
+
format.endingPrevious2 = formatCurrency(updates.endingPrevious2, currency);
|
|
3056
3088
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
3057
3089
|
|
|
3058
3090
|
calculateUnrealizedPercent(group);
|
|
@@ -3102,7 +3134,7 @@ module.exports = (() => {
|
|
|
3102
3134
|
const translate = (item, value) => {
|
|
3103
3135
|
let translated;
|
|
3104
3136
|
|
|
3105
|
-
if (item.currency !== currency) {
|
|
3137
|
+
if (item.currency !== currency && !value.getIsZero()) {
|
|
3106
3138
|
translated = Rate.convert(value, item.currency, currency, ...rates);
|
|
3107
3139
|
} else {
|
|
3108
3140
|
translated = value;
|
|
@@ -3149,7 +3181,25 @@ module.exports = (() => {
|
|
|
3149
3181
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
3150
3182
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
3151
3183
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
3152
|
-
|
|
3184
|
+
|
|
3185
|
+
let endingChange = updates.market.subtract(actual.endingPrevious);
|
|
3186
|
+
let endingChangePercent;
|
|
3187
|
+
|
|
3188
|
+
if (actual.endingPrevious.getIsZero()) {
|
|
3189
|
+
if (endingChange.getIsPositive()) {
|
|
3190
|
+
endingChangePercent = Decimal.ONE;
|
|
3191
|
+
} else if (endingChange.getIsNegative()) {
|
|
3192
|
+
endingChangePercent = Decimal.NEGATIVE_ONE;
|
|
3193
|
+
} else {
|
|
3194
|
+
endingChangePercent = Decimal.ZERO;
|
|
3195
|
+
}
|
|
3196
|
+
} else {
|
|
3197
|
+
endingChangePercent = endingChange.divide(actual.endingPrevious);
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
actual.endingChange = endingChange;
|
|
3201
|
+
actual.endingChangePercent = endingChangePercent;
|
|
3202
|
+
|
|
3153
3203
|
format.market = formatCurrency(actual.market, currency);
|
|
3154
3204
|
|
|
3155
3205
|
if (updates.marketDirection.up || updates.marketDirection.down) {
|
|
@@ -3169,6 +3219,9 @@ module.exports = (() => {
|
|
|
3169
3219
|
format.total = formatCurrency(actual.total, currency);
|
|
3170
3220
|
format.totalNegative = actual.total.getIsNegative();
|
|
3171
3221
|
|
|
3222
|
+
format.endingChange = formatCurrency(actual.endingChange, currency);
|
|
3223
|
+
format.endingChangePercent = formatPercent(actual.endingChangePercent, 2);
|
|
3224
|
+
|
|
3172
3225
|
calculateUnrealizedPercent(group);
|
|
3173
3226
|
}
|
|
3174
3227
|
|
|
@@ -3277,6 +3330,7 @@ module.exports = (() => {
|
|
|
3277
3330
|
this._data.basis = null;
|
|
3278
3331
|
|
|
3279
3332
|
this._currentQuote = null;
|
|
3333
|
+
this._previousQuote = null;
|
|
3280
3334
|
this._currentPrice = null;
|
|
3281
3335
|
|
|
3282
3336
|
this._data.currentPrice = null;
|
|
@@ -3300,6 +3354,9 @@ module.exports = (() => {
|
|
|
3300
3354
|
this._data.summaryTotalPrevious = null;
|
|
3301
3355
|
this._data.summaryTotalPrevious2 = null;
|
|
3302
3356
|
|
|
3357
|
+
this._data.endingPrevious = null;
|
|
3358
|
+
this._data.endingPrevious2 = null;
|
|
3359
|
+
|
|
3303
3360
|
this._data.realized = null;
|
|
3304
3361
|
this._data.income = null;
|
|
3305
3362
|
this._data.basisPrice = null;
|
|
@@ -3390,7 +3447,7 @@ module.exports = (() => {
|
|
|
3390
3447
|
}
|
|
3391
3448
|
|
|
3392
3449
|
/**
|
|
3393
|
-
* The
|
|
3450
|
+
* The most recent quote for the symbol of the encapsulated position.
|
|
3394
3451
|
*
|
|
3395
3452
|
* @public
|
|
3396
3453
|
* @returns {null|Object}
|
|
@@ -3399,6 +3456,16 @@ module.exports = (() => {
|
|
|
3399
3456
|
return this._currentQuote;
|
|
3400
3457
|
}
|
|
3401
3458
|
|
|
3459
|
+
/**
|
|
3460
|
+
* The second most recent quote for the symbol of the encapsulated position.
|
|
3461
|
+
*
|
|
3462
|
+
* @public
|
|
3463
|
+
* @returns {null|Object}
|
|
3464
|
+
*/
|
|
3465
|
+
get previousQuote() {
|
|
3466
|
+
return this._previousQuote;
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3402
3469
|
updatePortfolio(portfolio) {
|
|
3403
3470
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
3404
3471
|
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
@@ -3436,6 +3503,7 @@ module.exports = (() => {
|
|
|
3436
3503
|
this._currentPricePrevious = this._currentPrice;
|
|
3437
3504
|
this._currentPrice = quote.lastPrice;
|
|
3438
3505
|
|
|
3506
|
+
this._previousQuote = this._currentQuote;
|
|
3439
3507
|
this._currentQuote = quote;
|
|
3440
3508
|
|
|
3441
3509
|
this._quoteChangedEvent.fire(this._currentQuote);
|
|
@@ -3604,9 +3672,16 @@ module.exports = (() => {
|
|
|
3604
3672
|
|
|
3605
3673
|
data.income = snapshot.income;
|
|
3606
3674
|
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3675
|
+
const previousSummary1 = getPreviousSummary(previousSummaries, 1);
|
|
3676
|
+
const previousSummary2 = getPreviousSummary(previousSummaries, 2);
|
|
3677
|
+
const previousSummary3 = getPreviousSummary(previousSummaries, 3);
|
|
3678
|
+
|
|
3679
|
+
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary, previousSummary1);
|
|
3680
|
+
data.summaryTotalPrevious = calculateSummaryTotal(previousSummary1, previousSummary2);
|
|
3681
|
+
data.summaryTotalPrevious2 = calculateSummaryTotal(previousSummary2, previousSummary3);
|
|
3682
|
+
|
|
3683
|
+
data.endingPrevious = previousSummary1 === null ? Decimal.ZERO : previousSummary1.end.value;
|
|
3684
|
+
data.endingPrevious2 = previousSummary2 === null ? Decimal.ZERO : previousSummary2.end.value;
|
|
3610
3685
|
|
|
3611
3686
|
if (snapshot.open.getIsZero()) {
|
|
3612
3687
|
data.basisPrice = Decimal.ZERO;
|