@barchart/portfolio-api-common 1.0.170 → 1.0.174
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.
|
@@ -627,6 +627,7 @@ module.exports = (() => {
|
|
|
627
627
|
|
|
628
628
|
updates = items.reduce((updates, item) => {
|
|
629
629
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
630
|
+
updates.marketAbsolute = updates.marketAbsolute.add(translate(item, item.data.marketAbsolute));
|
|
630
631
|
updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
|
|
631
632
|
updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
|
|
632
633
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
@@ -634,6 +635,7 @@ module.exports = (() => {
|
|
|
634
635
|
return updates;
|
|
635
636
|
}, {
|
|
636
637
|
market: Decimal.ZERO,
|
|
638
|
+
marketAbsolute: Decimal.ZERO,
|
|
637
639
|
marketDirection: unchanged,
|
|
638
640
|
unrealized: Decimal.ZERO,
|
|
639
641
|
unrealizedToday: Decimal.ZERO,
|
|
@@ -642,6 +644,7 @@ module.exports = (() => {
|
|
|
642
644
|
} else {
|
|
643
645
|
updates = {
|
|
644
646
|
market: actual.market.add(translate(item, item.data.marketChange)),
|
|
647
|
+
marketAbsolute: actual.marketAbsolute.add(translate(item, item.data.marketAbsoluteChange)),
|
|
645
648
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
646
649
|
unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
|
|
647
650
|
unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
|
|
@@ -650,6 +653,7 @@ module.exports = (() => {
|
|
|
650
653
|
}
|
|
651
654
|
|
|
652
655
|
actual.market = updates.market;
|
|
656
|
+
actual.marketAbsolute = updates.marketAbsolute;
|
|
653
657
|
actual.unrealized = updates.unrealized;
|
|
654
658
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
655
659
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
@@ -694,16 +698,16 @@ module.exports = (() => {
|
|
|
694
698
|
if (parent !== null && !excluded) {
|
|
695
699
|
const parentData = parent._dataActual;
|
|
696
700
|
|
|
697
|
-
if (parentData.
|
|
701
|
+
if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsZero()) {
|
|
698
702
|
let numerator;
|
|
699
703
|
|
|
700
704
|
if (group.currency !== parent.currency) {
|
|
701
|
-
numerator = Rate.convert(actual.
|
|
705
|
+
numerator = Rate.convert(actual.marketAbsolute, group.currency, parent.currency, ...rates);
|
|
702
706
|
} else {
|
|
703
|
-
numerator = actual.
|
|
707
|
+
numerator = actual.marketAbsolute;
|
|
704
708
|
}
|
|
705
709
|
|
|
706
|
-
marketPercent = numerator.divide(parentData.
|
|
710
|
+
marketPercent = numerator.divide(parentData.marketAbsolute);
|
|
707
711
|
} else {
|
|
708
712
|
marketPercent = null;
|
|
709
713
|
}
|
|
@@ -46,6 +46,9 @@ module.exports = (() => {
|
|
|
46
46
|
this._data.market = null;
|
|
47
47
|
this._data.marketChange = null;
|
|
48
48
|
|
|
49
|
+
this._data.marketAbsolute = null;
|
|
50
|
+
this._data.marketAbsoluteChange = null;
|
|
51
|
+
|
|
49
52
|
this._data.unrealizedToday = null;
|
|
50
53
|
this._data.unrealizedTodayChange = null;
|
|
51
54
|
|
|
@@ -329,6 +332,18 @@ module.exports = (() => {
|
|
|
329
332
|
data.market = market;
|
|
330
333
|
data.marketChange = marketChange;
|
|
331
334
|
|
|
335
|
+
let marketAbsolute = market.absolute();
|
|
336
|
+
let marketAbsoluteChange;
|
|
337
|
+
|
|
338
|
+
if (data.marketAbsolute === null) {
|
|
339
|
+
marketAbsoluteChange = marketAbsolute;
|
|
340
|
+
} else {
|
|
341
|
+
marketAbsoluteChange = marketAbsolute.subtract(data.marketAbsolute);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
data.marketAbsolute = market;
|
|
345
|
+
data.marketAbsoluteChange = marketChange;
|
|
346
|
+
|
|
332
347
|
let unrealizedToday;
|
|
333
348
|
let unrealizedTodayChange;
|
|
334
349
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -2050,6 +2050,7 @@ module.exports = (() => {
|
|
|
2050
2050
|
|
|
2051
2051
|
updates = items.reduce((updates, item) => {
|
|
2052
2052
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
2053
|
+
updates.marketAbsolute = updates.marketAbsolute.add(translate(item, item.data.marketAbsolute));
|
|
2053
2054
|
updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
|
|
2054
2055
|
updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
|
|
2055
2056
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
@@ -2057,6 +2058,7 @@ module.exports = (() => {
|
|
|
2057
2058
|
return updates;
|
|
2058
2059
|
}, {
|
|
2059
2060
|
market: Decimal.ZERO,
|
|
2061
|
+
marketAbsolute: Decimal.ZERO,
|
|
2060
2062
|
marketDirection: unchanged,
|
|
2061
2063
|
unrealized: Decimal.ZERO,
|
|
2062
2064
|
unrealizedToday: Decimal.ZERO,
|
|
@@ -2065,6 +2067,7 @@ module.exports = (() => {
|
|
|
2065
2067
|
} else {
|
|
2066
2068
|
updates = {
|
|
2067
2069
|
market: actual.market.add(translate(item, item.data.marketChange)),
|
|
2070
|
+
marketAbsolute: actual.marketAbsolute.add(translate(item, item.data.marketAbsoluteChange)),
|
|
2068
2071
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
2069
2072
|
unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
|
|
2070
2073
|
unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
|
|
@@ -2073,6 +2076,7 @@ module.exports = (() => {
|
|
|
2073
2076
|
}
|
|
2074
2077
|
|
|
2075
2078
|
actual.market = updates.market;
|
|
2079
|
+
actual.marketAbsolute = updates.marketAbsolute;
|
|
2076
2080
|
actual.unrealized = updates.unrealized;
|
|
2077
2081
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
2078
2082
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
@@ -2117,16 +2121,16 @@ module.exports = (() => {
|
|
|
2117
2121
|
if (parent !== null && !excluded) {
|
|
2118
2122
|
const parentData = parent._dataActual;
|
|
2119
2123
|
|
|
2120
|
-
if (parentData.
|
|
2124
|
+
if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsZero()) {
|
|
2121
2125
|
let numerator;
|
|
2122
2126
|
|
|
2123
2127
|
if (group.currency !== parent.currency) {
|
|
2124
|
-
numerator = Rate.convert(actual.
|
|
2128
|
+
numerator = Rate.convert(actual.marketAbsolute, group.currency, parent.currency, ...rates);
|
|
2125
2129
|
} else {
|
|
2126
|
-
numerator = actual.
|
|
2130
|
+
numerator = actual.marketAbsolute;
|
|
2127
2131
|
}
|
|
2128
2132
|
|
|
2129
|
-
marketPercent = numerator.divide(parentData.
|
|
2133
|
+
marketPercent = numerator.divide(parentData.marketAbsolute);
|
|
2130
2134
|
} else {
|
|
2131
2135
|
marketPercent = null;
|
|
2132
2136
|
}
|
|
@@ -2210,6 +2214,9 @@ module.exports = (() => {
|
|
|
2210
2214
|
this._data.market = null;
|
|
2211
2215
|
this._data.marketChange = null;
|
|
2212
2216
|
|
|
2217
|
+
this._data.marketAbsolute = null;
|
|
2218
|
+
this._data.marketAbsoluteChange = null;
|
|
2219
|
+
|
|
2213
2220
|
this._data.unrealizedToday = null;
|
|
2214
2221
|
this._data.unrealizedTodayChange = null;
|
|
2215
2222
|
|
|
@@ -2493,6 +2500,18 @@ module.exports = (() => {
|
|
|
2493
2500
|
data.market = market;
|
|
2494
2501
|
data.marketChange = marketChange;
|
|
2495
2502
|
|
|
2503
|
+
let marketAbsolute = market.absolute();
|
|
2504
|
+
let marketAbsoluteChange;
|
|
2505
|
+
|
|
2506
|
+
if (data.marketAbsolute === null) {
|
|
2507
|
+
marketAbsoluteChange = marketAbsolute;
|
|
2508
|
+
} else {
|
|
2509
|
+
marketAbsoluteChange = marketAbsolute.subtract(data.marketAbsolute);
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
data.marketAbsolute = market;
|
|
2513
|
+
data.marketAbsoluteChange = marketChange;
|
|
2514
|
+
|
|
2496
2515
|
let unrealizedToday;
|
|
2497
2516
|
let unrealizedTodayChange;
|
|
2498
2517
|
|