@barchart/portfolio-api-common 1.0.155 → 1.0.159

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.
@@ -143,6 +143,7 @@ module.exports = (() => {
143
143
  this._dataFormat.summaryTotalPrevious = null;
144
144
  this._dataFormat.summaryTotalPreviousNegative = false;
145
145
  this._dataFormat.cashTotal = null;
146
+ this._dataFormat.portfolioType = null;
146
147
 
147
148
  this._items.forEach((item) => {
148
149
  this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
@@ -170,8 +171,8 @@ module.exports = (() => {
170
171
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
171
172
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
172
173
 
173
- const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange.getIsPositive() > 0;
174
- const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange.getIsPositive() < 0;
174
+ const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange > 0;
175
+ const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
175
176
 
176
177
  setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
177
178
  this._dataFormat.quoteChangeNegative = quoteChangeNegative;
@@ -514,6 +515,22 @@ module.exports = (() => {
514
515
  format.quantity = formatDecimal(actual.quantity, 2);
515
516
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
516
517
  }
518
+
519
+ const groupItems = group._items;
520
+
521
+ let portfolioType = null;
522
+
523
+ if (groupItems.length > 0) {
524
+ const portfolio = groupItems[0].portfolio;
525
+
526
+ if (groupItems.every(i => i.portfolio.portfolio === portfolio.portfolio)) {
527
+ if (portfolio.miscellany && portfolio.miscellany.data.type && portfolio.miscellany.data.type.value) {
528
+ portfolioType = portfolio.miscellany.data.type.value;
529
+ }
530
+ }
531
+ }
532
+
533
+ format.portfolioType = portfolioType;
517
534
  }
518
535
 
519
536
  function calculatePriceData(group, rates, item, forceRefresh) {
@@ -228,6 +228,7 @@ module.exports = (() => {
228
228
  }
229
229
 
230
230
  function calculateStaticData(item) {
231
+ const portfolio = item.portfolio;
231
232
  const position = item.position;
232
233
  const snapshot = item.position.snapshot;
233
234
  const previousSummaries = item.previousSummaries;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.155",
3
+ "version": "1.0.159",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1388,6 +1388,7 @@ module.exports = (() => {
1388
1388
  this._dataFormat.summaryTotalPrevious = null;
1389
1389
  this._dataFormat.summaryTotalPreviousNegative = false;
1390
1390
  this._dataFormat.cashTotal = null;
1391
+ this._dataFormat.portfolioType = null;
1391
1392
 
1392
1393
  this._items.forEach((item) => {
1393
1394
  this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
@@ -1415,8 +1416,8 @@ module.exports = (() => {
1415
1416
  this._dataFormat.quoteTime = this._dataActual.quoteTime;
1416
1417
  this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
1417
1418
 
1418
- const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange.getIsPositive() > 0;
1419
- const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange.getIsPositive() < 0;
1419
+ const quoteChangePositive = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange > 0;
1420
+ const quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
1420
1421
 
1421
1422
  setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
1422
1423
  this._dataFormat.quoteChangeNegative = quoteChangeNegative;
@@ -1759,6 +1760,22 @@ module.exports = (() => {
1759
1760
  format.quantity = formatDecimal(actual.quantity, 2);
1760
1761
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
1761
1762
  }
1763
+
1764
+ const groupItems = group._items;
1765
+
1766
+ let portfolioType = null;
1767
+
1768
+ if (groupItems.length > 0) {
1769
+ const portfolio = groupItems[0].portfolio;
1770
+
1771
+ if (groupItems.every(i => i.portfolio.portfolio === portfolio.portfolio)) {
1772
+ if (portfolio.miscellany && portfolio.miscellany.data.type && portfolio.miscellany.data.type.value) {
1773
+ portfolioType = portfolio.miscellany.data.type.value;
1774
+ }
1775
+ }
1776
+ }
1777
+
1778
+ format.portfolioType = portfolioType;
1762
1779
  }
1763
1780
 
1764
1781
  function calculatePriceData(group, rates, item, forceRefresh) {
@@ -2139,6 +2156,7 @@ module.exports = (() => {
2139
2156
  }
2140
2157
 
2141
2158
  function calculateStaticData(item) {
2159
+ const portfolio = item.portfolio;
2142
2160
  const position = item.position;
2143
2161
  const snapshot = item.position.snapshot;
2144
2162
  const previousSummaries = item.previousSummaries;