@barchart/portfolio-api-common 1.0.116 → 1.0.120
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.
|
@@ -38,8 +38,14 @@ module.exports = (() => {
|
|
|
38
38
|
this._dataFormat.quantity = null;
|
|
39
39
|
|
|
40
40
|
if (this._single) {
|
|
41
|
-
|
|
41
|
+
const item = items[0];
|
|
42
|
+
|
|
43
|
+
this._dataFormat.portfolio = item.portfolio.portfolio;
|
|
44
|
+
this._dataFormat.position = item.position.position;
|
|
45
|
+
this._dataFormat.instrument = item.position.instrument;
|
|
42
46
|
} else {
|
|
47
|
+
this._dataFormat.portfolio = null;
|
|
48
|
+
this._dataFormat.position = null;
|
|
43
49
|
this._dataFormat.instrument = null;
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -268,7 +274,7 @@ module.exports = (() => {
|
|
|
268
274
|
const item = group._items[0];
|
|
269
275
|
|
|
270
276
|
format.quantity = formatDecimal(item.position.snapshot.open, 2);
|
|
271
|
-
format.basisPrice = formatCurrency(item.basisPrice, currency);
|
|
277
|
+
format.basisPrice = formatCurrency(item.data.basisPrice, currency);
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
280
|
|
|
@@ -394,8 +400,13 @@ module.exports = (() => {
|
|
|
394
400
|
const actual = group._dataActual;
|
|
395
401
|
const format = group._dataFormat;
|
|
396
402
|
|
|
397
|
-
|
|
398
|
-
|
|
403
|
+
if (actual.basis.getIsZero()) {
|
|
404
|
+
actual.unrealizedPercent = null;
|
|
405
|
+
format.unrealizedPercent = '—';
|
|
406
|
+
} else {
|
|
407
|
+
actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
|
|
408
|
+
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
409
|
+
}
|
|
399
410
|
}
|
|
400
411
|
|
|
401
412
|
const unchanged = { up: false, down: false };
|
|
@@ -149,7 +149,11 @@ module.exports = (() => {
|
|
|
149
149
|
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
|
|
150
150
|
data.summaryTotalPrevious = calculateSummaryTotal(array.last(previousSummaries));
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
if (snapshot.open.getIsZero()) {
|
|
153
|
+
data.basisPrice = Decimal.ZERO;
|
|
154
|
+
} else {
|
|
155
|
+
data.basisPrice = basis.divide(snapshot.open);
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
function calculatePriceData(item, price) {
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1043,8 +1043,14 @@ module.exports = (() => {
|
|
|
1043
1043
|
this._dataFormat.quantity = null;
|
|
1044
1044
|
|
|
1045
1045
|
if (this._single) {
|
|
1046
|
-
|
|
1046
|
+
const item = items[0];
|
|
1047
|
+
|
|
1048
|
+
this._dataFormat.portfolio = item.portfolio.portfolio;
|
|
1049
|
+
this._dataFormat.position = item.position.position;
|
|
1050
|
+
this._dataFormat.instrument = item.position.instrument;
|
|
1047
1051
|
} else {
|
|
1052
|
+
this._dataFormat.portfolio = null;
|
|
1053
|
+
this._dataFormat.position = null;
|
|
1048
1054
|
this._dataFormat.instrument = null;
|
|
1049
1055
|
}
|
|
1050
1056
|
|
|
@@ -1273,7 +1279,7 @@ module.exports = (() => {
|
|
|
1273
1279
|
const item = group._items[0];
|
|
1274
1280
|
|
|
1275
1281
|
format.quantity = formatDecimal(item.position.snapshot.open, 2);
|
|
1276
|
-
format.basisPrice = formatCurrency(item.basisPrice, currency);
|
|
1282
|
+
format.basisPrice = formatCurrency(item.data.basisPrice, currency);
|
|
1277
1283
|
}
|
|
1278
1284
|
}
|
|
1279
1285
|
|
|
@@ -1399,8 +1405,13 @@ module.exports = (() => {
|
|
|
1399
1405
|
const actual = group._dataActual;
|
|
1400
1406
|
const format = group._dataFormat;
|
|
1401
1407
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1408
|
+
if (actual.basis.getIsZero()) {
|
|
1409
|
+
actual.unrealizedPercent = null;
|
|
1410
|
+
format.unrealizedPercent = '—';
|
|
1411
|
+
} else {
|
|
1412
|
+
actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
|
|
1413
|
+
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
1414
|
+
}
|
|
1404
1415
|
}
|
|
1405
1416
|
|
|
1406
1417
|
const unchanged = { up: false, down: false };
|
|
@@ -1560,7 +1571,11 @@ module.exports = (() => {
|
|
|
1560
1571
|
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
|
|
1561
1572
|
data.summaryTotalPrevious = calculateSummaryTotal(array.last(previousSummaries));
|
|
1562
1573
|
|
|
1563
|
-
|
|
1574
|
+
if (snapshot.open.getIsZero()) {
|
|
1575
|
+
data.basisPrice = Decimal.ZERO;
|
|
1576
|
+
} else {
|
|
1577
|
+
data.basisPrice = basis.divide(snapshot.open);
|
|
1578
|
+
}
|
|
1564
1579
|
}
|
|
1565
1580
|
|
|
1566
1581
|
function calculatePriceData(item, price) {
|