@barchart/portfolio-api-common 1.2.87 → 1.2.91

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.
@@ -86,6 +86,19 @@ module.exports = (() => {
86
86
  return this._rangeCalculator(getFilteredTransactions(transactions));
87
87
  }
88
88
 
89
+ /**
90
+ * Returns the range which contains a given date and all subsequent ranges.
91
+ *
92
+ * @public
93
+ * @param {Day} date
94
+ * @return {Array.<PositionSummaryRange>}
95
+ */
96
+ getRangesFromDate(date) {
97
+ const transaction = { date: date, snapshot: { open: Decimal.ONE } };
98
+
99
+ return this.getRanges([ transaction ]);
100
+ }
101
+
89
102
  /**
90
103
  * Returns the start date for a frame, a given number of periods ago.
91
104
  *
@@ -42,7 +42,7 @@ module.exports = (() => {
42
42
  * @param {Array.<Object>} portfolios - The portfolios.
43
43
  * @param {Array.<Object>} positions - The positions (for all of the portfolios).
44
44
  * @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
45
- * @param {PositionSummaryFrame} - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
45
+ * @param {PositionSummaryFrame=} - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
46
46
  */
47
47
  class PositionContainer {
48
48
  constructor(definitions, portfolios, positions, summaries, frame) {
@@ -283,17 +283,16 @@ module.exports = (() => {
283
283
  }
284
284
 
285
285
  const existingBarchartSymbols = this.getPositionSymbols(false);
286
- const existingPositionItem = this._items.find(item => item.position.position === position.position);
287
286
 
288
- let currentQuote = null;
289
- let previousQuote = null;
287
+ let similarPositionItem;
290
288
 
291
- if (existingPositionItem) {
292
- currentQuote = existingPositionItem.quote || null;
293
- previousQuote = existingPositionItem.previousQuote || null;
289
+ if (extractSymbolForBarchart(position)) {
290
+ similarPositionItem = this._items.find(item => extractSymbolForBarchart(item.position) === extractSymbolForBarchart(position)) || null;
291
+ } else {
292
+ similarPositionItem = null;
294
293
  }
295
294
 
296
- removePositionItem.call(this, existingPositionItem);
295
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
297
296
 
298
297
  summaries.forEach((summary) => {
299
298
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -305,14 +304,6 @@ module.exports = (() => {
305
304
  addBarchartSymbol(this._symbols, item);
306
305
  addDisplaySymbol(this._symbolsDisplay, item);
307
306
 
308
- if (previousQuote !== null) {
309
- item.setQuote(previousQuote);
310
- }
311
-
312
- if (currentQuote !== null) {
313
- item.setQuote(currentQuote);
314
- }
315
-
316
307
  this._items.push(item);
317
308
 
318
309
  const createGroupOrInjectItem = (parentTree, treeDefinition, levelDefinitions) => {
@@ -348,6 +339,16 @@ module.exports = (() => {
348
339
  this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
349
340
  }
350
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
+
351
352
  recalculatePercentages.call(this);
352
353
  }
353
354
 
@@ -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
 
@@ -65,6 +65,9 @@ module.exports = (() => {
65
65
  this._data.summaryTotalPrevious = null;
66
66
  this._data.summaryTotalPrevious2 = null;
67
67
 
68
+ this._data.endingPrevious = null;
69
+ this._data.endingPrevious2 = null;
70
+
68
71
  this._data.realized = null;
69
72
  this._data.income = null;
70
73
  this._data.basisPrice = null;
@@ -380,9 +383,16 @@ module.exports = (() => {
380
383
 
381
384
  data.income = snapshot.income;
382
385
 
383
- data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary, getPreviousSummary(previousSummaries, 1));
384
- data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1), getPreviousSummary(previousSummaries, 2));
385
- data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2), getPreviousSummary(previousSummaries, 3));
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;
386
396
 
387
397
  if (snapshot.open.getIsZero()) {
388
398
  data.basisPrice = Decimal.ZERO;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.87",
3
+ "version": "1.2.91",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -477,6 +477,19 @@ module.exports = (() => {
477
477
  return this._rangeCalculator(getFilteredTransactions(transactions));
478
478
  }
479
479
 
480
+ /**
481
+ * Returns the range which contains a given date and all subsequent ranges.
482
+ *
483
+ * @public
484
+ * @param {Day} date
485
+ * @return {Array.<PositionSummaryRange>}
486
+ */
487
+ getRangesFromDate(date) {
488
+ const transaction = { date: date, snapshot: { open: Decimal.ONE } };
489
+
490
+ return this.getRanges([ transaction ]);
491
+ }
492
+
480
493
  /**
481
494
  * Returns the start date for a frame, a given number of periods ago.
482
495
  *
@@ -1421,7 +1434,7 @@ module.exports = (() => {
1421
1434
  * @param {Array.<Object>} portfolios - The portfolios.
1422
1435
  * @param {Array.<Object>} positions - The positions (for all of the portfolios).
1423
1436
  * @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
1424
- * @param {PositionSummaryFrame} - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
1437
+ * @param {PositionSummaryFrame=} - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
1425
1438
  */
1426
1439
  class PositionContainer {
1427
1440
  constructor(definitions, portfolios, positions, summaries, frame) {
@@ -1662,17 +1675,16 @@ module.exports = (() => {
1662
1675
  }
1663
1676
 
1664
1677
  const existingBarchartSymbols = this.getPositionSymbols(false);
1665
- const existingPositionItem = this._items.find(item => item.position.position === position.position);
1666
1678
 
1667
- let currentQuote = null;
1668
- let previousQuote = null;
1679
+ let similarPositionItem;
1669
1680
 
1670
- if (existingPositionItem) {
1671
- currentQuote = existingPositionItem.quote || null;
1672
- previousQuote = existingPositionItem.previousQuote || null;
1681
+ if (extractSymbolForBarchart(position)) {
1682
+ similarPositionItem = this._items.find(item => extractSymbolForBarchart(item.position) === extractSymbolForBarchart(position)) || null;
1683
+ } else {
1684
+ similarPositionItem = null;
1673
1685
  }
1674
1686
 
1675
- removePositionItem.call(this, existingPositionItem);
1687
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
1676
1688
 
1677
1689
  summaries.forEach((summary) => {
1678
1690
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -1684,14 +1696,6 @@ module.exports = (() => {
1684
1696
  addBarchartSymbol(this._symbols, item);
1685
1697
  addDisplaySymbol(this._symbolsDisplay, item);
1686
1698
 
1687
- if (previousQuote !== null) {
1688
- item.setQuote(previousQuote);
1689
- }
1690
-
1691
- if (currentQuote !== null) {
1692
- item.setQuote(currentQuote);
1693
- }
1694
-
1695
1699
  this._items.push(item);
1696
1700
 
1697
1701
  const createGroupOrInjectItem = (parentTree, treeDefinition, levelDefinitions) => {
@@ -1727,6 +1731,16 @@ module.exports = (() => {
1727
1731
  this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
1728
1732
  }
1729
1733
 
1734
+ if (similarPositionItem !== null) {
1735
+ if (similarPositionItem.previousQuote) {
1736
+ item.setQuote(similarPositionItem.previousQuote);
1737
+ }
1738
+
1739
+ if (similarPositionItem.quote) {
1740
+ item.setQuote(similarPositionItem.quote);
1741
+ }
1742
+ }
1743
+
1730
1744
  recalculatePercentages.call(this);
1731
1745
  }
1732
1746
 
@@ -2514,6 +2528,10 @@ module.exports = (() => {
2514
2528
  this._dataActual.summaryTotalCurrent = null;
2515
2529
  this._dataActual.summaryTotalPrevious = null;
2516
2530
  this._dataActual.summaryTotalPrevious2 = null;
2531
+ this._dataActual.endingPrevious = null;
2532
+ this._dataActual.endingPrevious2 = null;
2533
+ this._dataActual.endingChange = null;
2534
+ this._dataActual.endingChangePercent = null;
2517
2535
  this._dataActual.cashTotal = null;
2518
2536
 
2519
2537
  this._dataFormat.currentPrice = null;
@@ -2537,6 +2555,10 @@ module.exports = (() => {
2537
2555
  this._dataFormat.summaryTotalPreviousNegative = false;
2538
2556
  this._dataFormat.summaryTotalPrevious2 = null;
2539
2557
  this._dataFormat.summaryTotalPrevious2Negative = false;
2558
+ this._dataFormat.endingPrevious = null;
2559
+ this._dataFormat.endingPrevious2 = null;
2560
+ this._dataFormat.endingChange = null;
2561
+ this._dataFormat.endingChangePercent = null;
2540
2562
  this._dataFormat.cashTotal = null;
2541
2563
  this._dataFormat.portfolioType = null;
2542
2564
 
@@ -2772,8 +2794,6 @@ module.exports = (() => {
2772
2794
  return;
2773
2795
  }
2774
2796
 
2775
- const descriptionSelector = this._definition.descriptionSelector;
2776
-
2777
2797
  this._description = PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio);
2778
2798
 
2779
2799
  this._dataActual.description = this._description;
@@ -3018,7 +3038,7 @@ module.exports = (() => {
3018
3038
  const translate = (item, value) => {
3019
3039
  let translated;
3020
3040
 
3021
- if (item.currency !== currency) {
3041
+ if (item.currency !== currency && !value.getIsZero()) {
3022
3042
  translated = Rate.convert(value, item.currency, currency, ...rates);
3023
3043
  } else {
3024
3044
  translated = value;
@@ -3035,6 +3055,8 @@ module.exports = (() => {
3035
3055
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
3036
3056
  updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
3037
3057
  updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
3058
+ updates.endingPrevious = updates.endingPrevious.add(translate(item, item.data.endingPrevious));
3059
+ updates.endingPrevious2 = updates.endingPrevious2.add(translate(item, item.data.endingPrevious2));
3038
3060
 
3039
3061
  if (item.position.instrument.type === InstrumentType.CASH) {
3040
3062
  updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
@@ -3049,6 +3071,8 @@ module.exports = (() => {
3049
3071
  summaryTotalCurrent: Decimal.ZERO,
3050
3072
  summaryTotalPrevious: Decimal.ZERO,
3051
3073
  summaryTotalPrevious2: Decimal.ZERO,
3074
+ endingPrevious: Decimal.ZERO,
3075
+ endingPrevious2: Decimal.ZERO,
3052
3076
  cashTotal: Decimal.ZERO
3053
3077
  });
3054
3078
 
@@ -3059,6 +3083,8 @@ module.exports = (() => {
3059
3083
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
3060
3084
  actual.summaryTotalPrevious = updates.summaryTotalPrevious;
3061
3085
  actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
3086
+ actual.endingPrevious = updates.endingPrevious;
3087
+ actual.endingPrevious2 = updates.endingPrevious2;
3062
3088
  actual.cashTotal = updates.cashTotal;
3063
3089
 
3064
3090
  format.basis = formatCurrency(actual.basis, currency);
@@ -3070,6 +3096,8 @@ module.exports = (() => {
3070
3096
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
3071
3097
  format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
3072
3098
  format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
3099
+ format.endingPrevious = formatCurrency(updates.endingPrevious, currency);
3100
+ format.endingPrevious2 = formatCurrency(updates.endingPrevious2, currency);
3073
3101
  format.cashTotal = formatCurrency(updates.cashTotal, currency);
3074
3102
 
3075
3103
  calculateUnrealizedPercent(group);
@@ -3119,7 +3147,7 @@ module.exports = (() => {
3119
3147
  const translate = (item, value) => {
3120
3148
  let translated;
3121
3149
 
3122
- if (item.currency !== currency) {
3150
+ if (item.currency !== currency && !value.getIsZero()) {
3123
3151
  translated = Rate.convert(value, item.currency, currency, ...rates);
3124
3152
  } else {
3125
3153
  translated = value;
@@ -3166,7 +3194,25 @@ module.exports = (() => {
3166
3194
  actual.unrealizedToday = updates.unrealizedToday;
3167
3195
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
3168
3196
  actual.total = updates.unrealized.add(actual.realized).add(actual.income);
3169
-
3197
+
3198
+ let endingChange = updates.market.subtract(actual.endingPrevious);
3199
+ let endingChangePercent;
3200
+
3201
+ if (actual.endingPrevious.getIsZero()) {
3202
+ if (endingChange.getIsPositive()) {
3203
+ endingChangePercent = Decimal.ONE;
3204
+ } else if (endingChange.getIsNegative()) {
3205
+ endingChangePercent = Decimal.NEGATIVE_ONE;
3206
+ } else {
3207
+ endingChangePercent = Decimal.ZERO;
3208
+ }
3209
+ } else {
3210
+ endingChangePercent = endingChange.divide(actual.endingPrevious);
3211
+ }
3212
+
3213
+ actual.endingChange = endingChange;
3214
+ actual.endingChangePercent = endingChangePercent;
3215
+
3170
3216
  format.market = formatCurrency(actual.market, currency);
3171
3217
 
3172
3218
  if (updates.marketDirection.up || updates.marketDirection.down) {
@@ -3186,6 +3232,9 @@ module.exports = (() => {
3186
3232
  format.total = formatCurrency(actual.total, currency);
3187
3233
  format.totalNegative = actual.total.getIsNegative();
3188
3234
 
3235
+ format.endingChange = formatCurrency(actual.endingChange, currency);
3236
+ format.endingChangePercent = formatPercent(actual.endingChangePercent, 2);
3237
+
3189
3238
  calculateUnrealizedPercent(group);
3190
3239
  }
3191
3240
 
@@ -3318,6 +3367,9 @@ module.exports = (() => {
3318
3367
  this._data.summaryTotalPrevious = null;
3319
3368
  this._data.summaryTotalPrevious2 = null;
3320
3369
 
3370
+ this._data.endingPrevious = null;
3371
+ this._data.endingPrevious2 = null;
3372
+
3321
3373
  this._data.realized = null;
3322
3374
  this._data.income = null;
3323
3375
  this._data.basisPrice = null;
@@ -3633,9 +3685,16 @@ module.exports = (() => {
3633
3685
 
3634
3686
  data.income = snapshot.income;
3635
3687
 
3636
- data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary, getPreviousSummary(previousSummaries, 1));
3637
- data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1), getPreviousSummary(previousSummaries, 2));
3638
- data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2), getPreviousSummary(previousSummaries, 3));
3688
+ const previousSummary1 = getPreviousSummary(previousSummaries, 1);
3689
+ const previousSummary2 = getPreviousSummary(previousSummaries, 2);
3690
+ const previousSummary3 = getPreviousSummary(previousSummaries, 3);
3691
+
3692
+ data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary, previousSummary1);
3693
+ data.summaryTotalPrevious = calculateSummaryTotal(previousSummary1, previousSummary2);
3694
+ data.summaryTotalPrevious2 = calculateSummaryTotal(previousSummary2, previousSummary3);
3695
+
3696
+ data.endingPrevious = previousSummary1 === null ? Decimal.ZERO : previousSummary1.end.value;
3697
+ data.endingPrevious2 = previousSummary2 === null ? Decimal.ZERO : previousSummary2.end.value;
3639
3698
 
3640
3699
  if (snapshot.open.getIsZero()) {
3641
3700
  data.basisPrice = Decimal.ZERO;