@barchart/portfolio-api-common 1.0.115 → 1.0.116

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.
@@ -74,6 +74,7 @@ module.exports = (() => {
74
74
  this._dataFormat.marketPercent = null;
75
75
  this._dataFormat.marketDirection = null;
76
76
  this._dataFormat.unrealized = null;
77
+ this._dataFormat.unrealizedPercent = null;
77
78
  this._dataFormat.unrealizedNegative = false;
78
79
  this._dataFormat.unrealizedToday = null;
79
80
  this._dataFormat.unrealizedTodayNegative = false;
@@ -261,6 +262,8 @@ module.exports = (() => {
261
262
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
262
263
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
263
264
 
265
+ calculateUnrealizedPercent(group);
266
+
264
267
  if (group.single) {
265
268
  const item = group._items[0];
266
269
 
@@ -351,6 +354,7 @@ module.exports = (() => {
351
354
  format.totalNegative = actual.total.getIsNegative();
352
355
 
353
356
  calculateMarketPercent(group, false);
357
+ calculateUnrealizedPercent(group);
354
358
  }
355
359
 
356
360
  function calculateMarketPercent(group, silent) {
@@ -386,6 +390,14 @@ module.exports = (() => {
386
390
  }
387
391
  }
388
392
 
393
+ function calculateUnrealizedPercent(group) {
394
+ const actual = group._dataActual;
395
+ const format = group._dataFormat;
396
+
397
+ actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
398
+ format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
399
+ }
400
+
389
401
  const unchanged = { up: false, down: false };
390
402
 
391
403
  return PositionGroup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.115",
3
+ "version": "1.0.116",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1079,6 +1079,7 @@ module.exports = (() => {
1079
1079
  this._dataFormat.marketPercent = null;
1080
1080
  this._dataFormat.marketDirection = null;
1081
1081
  this._dataFormat.unrealized = null;
1082
+ this._dataFormat.unrealizedPercent = null;
1082
1083
  this._dataFormat.unrealizedNegative = false;
1083
1084
  this._dataFormat.unrealizedToday = null;
1084
1085
  this._dataFormat.unrealizedTodayNegative = false;
@@ -1266,6 +1267,8 @@ module.exports = (() => {
1266
1267
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
1267
1268
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
1268
1269
 
1270
+ calculateUnrealizedPercent(group);
1271
+
1269
1272
  if (group.single) {
1270
1273
  const item = group._items[0];
1271
1274
 
@@ -1356,6 +1359,7 @@ module.exports = (() => {
1356
1359
  format.totalNegative = actual.total.getIsNegative();
1357
1360
 
1358
1361
  calculateMarketPercent(group, false);
1362
+ calculateUnrealizedPercent(group);
1359
1363
  }
1360
1364
 
1361
1365
  function calculateMarketPercent(group, silent) {
@@ -1391,6 +1395,14 @@ module.exports = (() => {
1391
1395
  }
1392
1396
  }
1393
1397
 
1398
+ function calculateUnrealizedPercent(group) {
1399
+ const actual = group._dataActual;
1400
+ const format = group._dataFormat;
1401
+
1402
+ actual.unrealizedPercent = actual.unrealized.divide(actual.basis);
1403
+ format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
1404
+ }
1405
+
1394
1406
  const unchanged = { up: false, down: false };
1395
1407
 
1396
1408
  return PositionGroup;