@barchart/portfolio-api-common 1.0.154 → 1.0.158

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.
@@ -123,6 +123,7 @@ module.exports = (() => {
123
123
  this._dataActual.summaryTotalPrevious = null;
124
124
  this._dataActual.cashTotal = null;
125
125
 
126
+ this._dataFormat.type = null;
126
127
  this._dataFormat.currentPrice = null;
127
128
  this._dataFormat.previousPrice = null;
128
129
  this._dataFormat.basis = null;
@@ -170,8 +171,11 @@ module.exports = (() => {
170
171
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
171
172
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
172
173
 
173
- setTimeout(() => this._dataFormat.quoteChangeDirection = { up: this._dataActual.quoteChange.getIsPositive(), down: this._dataActual.quoteChange.getIsNegative() }, 0);
174
- this._dataFormat.quoteChangeNegative = this._dataActual.quoteChange.getIsNegative();
174
+ const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange > 0;
175
+ const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
176
+
177
+ setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
178
+ this._dataFormat.quoteChangeNegative = quoteChangeNegative;
175
179
  } else {
176
180
  this._dataActual.currentPrice = null;
177
181
  this._dataFormat.currentPrice = null;
@@ -505,6 +509,8 @@ module.exports = (() => {
505
509
  if (group.single) {
506
510
  const item = group._items[0];
507
511
 
512
+ format.type = item.data.type || null;
513
+
508
514
  actual.quantity = item.position.snapshot.open;
509
515
  actual.basisPrice = item.data.basisPrice;
510
516
 
@@ -61,6 +61,8 @@ module.exports = (() => {
61
61
  this._data.newsExists = false;
62
62
  this._data.fundamental = { };
63
63
 
64
+ this._data.type = null;
65
+
64
66
  calculateStaticData(this);
65
67
  calculatePriceData(this, null);
66
68
 
@@ -228,12 +230,17 @@ module.exports = (() => {
228
230
  }
229
231
 
230
232
  function calculateStaticData(item) {
233
+ const portfolio = item.portfolio;
231
234
  const position = item.position;
232
235
  const snapshot = item.position.snapshot;
233
236
  const previousSummaries = item.previousSummaries;
234
237
 
235
238
  const data = item._data;
236
239
 
240
+ if (portfolio.miscellany && portfolio.miscellany.data.type && portfolio.miscellany.data.type.value) {
241
+ data.type = portfolio.miscellany.data.type.value;
242
+ }
243
+
237
244
  data.previousPrice = position.previous || null;
238
245
 
239
246
  let basis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.154",
3
+ "version": "1.0.158",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1368,6 +1368,7 @@ module.exports = (() => {
1368
1368
  this._dataActual.summaryTotalPrevious = null;
1369
1369
  this._dataActual.cashTotal = null;
1370
1370
 
1371
+ this._dataFormat.type = null;
1371
1372
  this._dataFormat.currentPrice = null;
1372
1373
  this._dataFormat.previousPrice = null;
1373
1374
  this._dataFormat.basis = null;
@@ -1415,8 +1416,11 @@ module.exports = (() => {
1415
1416
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
1416
1417
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
1417
1418
 
1418
- setTimeout(() => this._dataFormat.quoteChangeDirection = { up: this._dataActual.quoteChange.getIsPositive(), down: this._dataActual.quoteChange.getIsNegative() }, 0);
1419
- this._dataFormat.quoteChangeNegative = this._dataActual.quoteChange.getIsNegative();
1419
+ const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange > 0;
1420
+ const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
1421
+
1422
+ setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
1423
+ this._dataFormat.quoteChangeNegative = quoteChangeNegative;
1420
1424
  } else {
1421
1425
  this._dataActual.currentPrice = null;
1422
1426
  this._dataFormat.currentPrice = null;
@@ -1750,6 +1754,8 @@ module.exports = (() => {
1750
1754
  if (group.single) {
1751
1755
  const item = group._items[0];
1752
1756
 
1757
+ format.type = item.data.type || null;
1758
+
1753
1759
  actual.quantity = item.position.snapshot.open;
1754
1760
  actual.basisPrice = item.data.basisPrice;
1755
1761
 
@@ -1969,6 +1975,8 @@ module.exports = (() => {
1969
1975
  this._data.newsExists = false;
1970
1976
  this._data.fundamental = { };
1971
1977
 
1978
+ this._data.type = null;
1979
+
1972
1980
  calculateStaticData(this);
1973
1981
  calculatePriceData(this, null);
1974
1982
 
@@ -2136,12 +2144,17 @@ module.exports = (() => {
2136
2144
  }
2137
2145
 
2138
2146
  function calculateStaticData(item) {
2147
+ const portfolio = item.portfolio;
2139
2148
  const position = item.position;
2140
2149
  const snapshot = item.position.snapshot;
2141
2150
  const previousSummaries = item.previousSummaries;
2142
2151
 
2143
2152
  const data = item._data;
2144
2153
 
2154
+ if (portfolio.miscellany && portfolio.miscellany.data.type && portfolio.miscellany.data.type.value) {
2155
+ data.type = portfolio.miscellany.data.type.value;
2156
+ }
2157
+
2145
2158
  data.previousPrice = position.previous || null;
2146
2159
 
2147
2160
  let basis;