@barchart/portfolio-api-common 1.0.105 → 1.0.109

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.
@@ -35,6 +35,8 @@ module.exports = (() => {
35
35
  this._dataFormat.key = this._key;
36
36
  this._dataFormat.description = this._description;
37
37
 
38
+ this._dataFormat.quantity = null;
39
+
38
40
  if (this._single) {
39
41
  this._dataFormat.instrument = items[0].position.instrument;
40
42
  } else {
@@ -92,7 +94,7 @@ module.exports = (() => {
92
94
  this._dataFormat.quoteHigh = formatNumber(quote.highPrice, precision);
93
95
  this._dataFormat.quoteLow = formatNumber(quote.lowPrice, precision);
94
96
  this._dataFormat.quoteChange = formatNumber(quote.priceChange, precision);
95
- this._dataFormat.quoteChangePercent = formatPercent(quote.percentChange, 2);
97
+ this._dataFormat.quoteChangePercent = formatPercent(new Decimal(quote.percentChange), 2);
96
98
  this._dataFormat.quoteTime = quote.timeDisplay;
97
99
  this._dataFormat.quoteVolume = formatNumber(quote.volume, 0);
98
100
  } else {
@@ -251,6 +253,10 @@ module.exports = (() => {
251
253
  format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
252
254
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
253
255
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
256
+
257
+ if (group.single) {
258
+ format.quantity = formatDecimal(group._items[0].position.snapshot.open, 2);
259
+ }
254
260
  }
255
261
 
256
262
  function calculatePriceData(group, item, forceRefresh) {
@@ -84,7 +84,7 @@ module.exports = (() => {
84
84
  setQuote(quote) {
85
85
  assert.argumentIsRequired(quote, 'quote', Object);
86
86
 
87
- if (this._data.price !== price) {
87
+ if (this._previousQuote === null || this._previousQuote.lastPrice !== quote.lastPrice) {
88
88
  this._previousQuote = this._currentQuote;
89
89
  this._currentQuote = quote;
90
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.105",
3
+ "version": "1.0.109",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1038,6 +1038,8 @@ module.exports = (() => {
1038
1038
  this._dataFormat.key = this._key;
1039
1039
  this._dataFormat.description = this._description;
1040
1040
 
1041
+ this._dataFormat.quantity = null;
1042
+
1041
1043
  if (this._single) {
1042
1044
  this._dataFormat.instrument = items[0].position.instrument;
1043
1045
  } else {
@@ -1095,7 +1097,7 @@ module.exports = (() => {
1095
1097
  this._dataFormat.quoteHigh = formatNumber(quote.highPrice, precision);
1096
1098
  this._dataFormat.quoteLow = formatNumber(quote.lowPrice, precision);
1097
1099
  this._dataFormat.quoteChange = formatNumber(quote.priceChange, precision);
1098
- this._dataFormat.quoteChangePercent = formatPercent(quote.percentChange, 2);
1100
+ this._dataFormat.quoteChangePercent = formatPercent(new Decimal(quote.percentChange), 2);
1099
1101
  this._dataFormat.quoteTime = quote.timeDisplay;
1100
1102
  this._dataFormat.quoteVolume = formatNumber(quote.volume, 0);
1101
1103
  } else {
@@ -1254,6 +1256,10 @@ module.exports = (() => {
1254
1256
  format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
1255
1257
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
1256
1258
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
1259
+
1260
+ if (group.single) {
1261
+ format.quantity = formatDecimal(group._items[0].position.snapshot.open, 2);
1262
+ }
1257
1263
  }
1258
1264
 
1259
1265
  function calculatePriceData(group, item, forceRefresh) {
@@ -1458,7 +1464,7 @@ module.exports = (() => {
1458
1464
  setQuote(quote) {
1459
1465
  assert.argumentIsRequired(quote, 'quote', Object);
1460
1466
 
1461
- if (this._data.price !== price) {
1467
+ if (this._previousQuote === null || this._previousQuote.lastPrice !== quote.lastPrice) {
1462
1468
  this._previousQuote = this._currentQuote;
1463
1469
  this._currentQuote = quote;
1464
1470