@barchart/portfolio-api-common 1.2.1 → 1.2.5

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.
@@ -71,6 +71,7 @@ module.exports = (() => {
71
71
  this._dataFormat.key = this._key;
72
72
  this._dataFormat.description = this._description;
73
73
  this._dataFormat.hide = false;
74
+ this._dataFormat.invalid = false;
74
75
  this._dataFormat.newsExists = false;
75
76
  this._dataFormat.quantity = null;
76
77
  this._dataFormat.basisPrice = null;
@@ -412,7 +413,7 @@ module.exports = (() => {
412
413
  * @public
413
414
  */
414
415
  refresh() {
415
- calculateStaticData(this, this._rates);
416
+ calculateStaticData(this, this._rates, this._definition);
416
417
  calculatePriceData(this, this._rates, null, true);
417
418
  }
418
419
 
@@ -614,7 +615,7 @@ module.exports = (() => {
614
615
  return formatDecimal(decimal, currency.precision);
615
616
  }
616
617
 
617
- function calculateStaticData(group, rates) {
618
+ function calculateStaticData(group, rates, definition) {
618
619
  const actual = group._dataActual;
619
620
  const format = group._dataFormat;
620
621
 
@@ -691,6 +692,8 @@ module.exports = (() => {
691
692
 
692
693
  format.quantity = formatDecimal(actual.quantity, 2);
693
694
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
695
+
696
+ format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
694
697
  }
695
698
 
696
699
  const groupItems = group._items;
@@ -27,7 +27,11 @@ module.exports = (() => {
27
27
 
28
28
  this._portfolio = portfolio;
29
29
  this._position = position;
30
- this._currency = position.instrument.currency || Currency.CAD;
30
+
31
+ const instrument = position.instrument;
32
+
33
+ this._currency = instrument.currency || Currency.CAD;
34
+ this._invalid = instrument.type.usesSymbols && (!is.object(instrument.symbol) || !is.string(instrument.symbol.barchart));
31
35
 
32
36
  this._currentSummary = currentSummary || null;
33
37
  this._previousSummaries = previousSummaries || [ ];
@@ -107,6 +111,16 @@ module.exports = (() => {
107
111
  return this._currency;
108
112
  }
109
113
 
114
+ /**
115
+ * Indicates if the position's symbol is invalid.
116
+ *
117
+ * @public
118
+ * @returns {Object}
119
+ */
120
+ get invalid() {
121
+ return this._invalid;
122
+ }
123
+
110
124
  /**
111
125
  * The year-to-date position summary of the encapsulated position.
112
126
  *
@@ -103,6 +103,7 @@ module.exports = (() => {
103
103
  .withField('legacy.portfolio', DataType.STRING, true)
104
104
  .withField('legacy.position', DataType.STRING, true)
105
105
  .withField('system.version', DataType.NUMBER, true)
106
+ .withField('root', DataType.STRING, true)
106
107
  .schema
107
108
  );
108
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.1",
3
+ "version": "1.2.5",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -2173,6 +2173,7 @@ module.exports = (() => {
2173
2173
  this._dataFormat.key = this._key;
2174
2174
  this._dataFormat.description = this._description;
2175
2175
  this._dataFormat.hide = false;
2176
+ this._dataFormat.invalid = false;
2176
2177
  this._dataFormat.newsExists = false;
2177
2178
  this._dataFormat.quantity = null;
2178
2179
  this._dataFormat.basisPrice = null;
@@ -2514,7 +2515,7 @@ module.exports = (() => {
2514
2515
  * @public
2515
2516
  */
2516
2517
  refresh() {
2517
- calculateStaticData(this, this._rates);
2518
+ calculateStaticData(this, this._rates, this._definition);
2518
2519
  calculatePriceData(this, this._rates, null, true);
2519
2520
  }
2520
2521
 
@@ -2716,7 +2717,7 @@ module.exports = (() => {
2716
2717
  return formatDecimal(decimal, currency.precision);
2717
2718
  }
2718
2719
 
2719
- function calculateStaticData(group, rates) {
2720
+ function calculateStaticData(group, rates, definition) {
2720
2721
  const actual = group._dataActual;
2721
2722
  const format = group._dataFormat;
2722
2723
 
@@ -2793,6 +2794,8 @@ module.exports = (() => {
2793
2794
 
2794
2795
  format.quantity = formatDecimal(actual.quantity, 2);
2795
2796
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
2797
+
2798
+ format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
2796
2799
  }
2797
2800
 
2798
2801
  const groupItems = group._items;
@@ -2988,7 +2991,11 @@ module.exports = (() => {
2988
2991
 
2989
2992
  this._portfolio = portfolio;
2990
2993
  this._position = position;
2991
- this._currency = position.instrument.currency || Currency.CAD;
2994
+
2995
+ const instrument = position.instrument;
2996
+
2997
+ this._currency = instrument.currency || Currency.CAD;
2998
+ this._invalid = instrument.type.usesSymbols && (!is.object(instrument.symbol) || !is.string(instrument.symbol.barchart));
2992
2999
 
2993
3000
  this._currentSummary = currentSummary || null;
2994
3001
  this._previousSummaries = previousSummaries || [ ];
@@ -3068,6 +3075,16 @@ module.exports = (() => {
3068
3075
  return this._currency;
3069
3076
  }
3070
3077
 
3078
+ /**
3079
+ * Indicates if the position's symbol is invalid.
3080
+ *
3081
+ * @public
3082
+ * @returns {Object}
3083
+ */
3084
+ get invalid() {
3085
+ return this._invalid;
3086
+ }
3087
+
3071
3088
  /**
3072
3089
  * The year-to-date position summary of the encapsulated position.
3073
3090
  *