@barchart/portfolio-api-common 1.0.132 → 1.0.136

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.
@@ -333,7 +333,12 @@ module.exports = (() => {
333
333
  * @param {Object} data
334
334
  */
335
335
  setPositionFundamentalData(symbol, data) {
336
- return;
336
+ assert.argumentIsRequired(symbol, 'symbol', String);
337
+ assert.argumentIsRequired(data, 'data', Object);
338
+
339
+ if (this._symbols.hasOwnProperty(symbol)) {
340
+ this._symbols[symbol].forEach(item => item.setPositionFundamentalData(data));
341
+ }
337
342
  }
338
343
 
339
344
  /**
@@ -352,9 +357,9 @@ module.exports = (() => {
352
357
  let map;
353
358
 
354
359
  if (display) {
355
- map = this._symbols;
356
- } else {
357
360
  map = this._symbolsDisplay;
361
+ } else {
362
+ map = this._symbols;
358
363
  }
359
364
 
360
365
  if (map.hasOwnProperty(symbol)) {
@@ -38,15 +38,18 @@ module.exports = (() => {
38
38
 
39
39
  this._excluded = false;
40
40
  this._suspended = false;
41
+ this._showClosedPositions = false;
41
42
 
42
43
  this._marketPercentChangeEvent = new Event(this);
43
44
  this._excludedChangeEvent = new Event(this);
45
+ this._showClosedPositionsChangeEvent = new Event(this);
44
46
 
45
47
  this._dataFormat = { };
46
48
  this._dataActual = { };
47
49
 
48
50
  this._dataFormat.key = this._key;
49
51
  this._dataFormat.description = this._description;
52
+ this._dataFormat.hide = false;
50
53
  this._dataFormat.newsExists = false;
51
54
  this._dataFormat.quantity = null;
52
55
  this._dataFormat.basisPrice = null;
@@ -63,10 +66,12 @@ module.exports = (() => {
63
66
  this._dataFormat.portfolio = item.portfolio.portfolio;
64
67
  this._dataFormat.position = item.position.position;
65
68
  this._dataFormat.instrument = item.position.instrument;
69
+ this._dataFormat.fundamental = item.fundamental || { };
66
70
  } else {
67
71
  this._dataFormat.portfolio = null;
68
72
  this._dataFormat.position = null;
69
73
  this._dataFormat.instrument = null;
74
+ this._dataFormat.fundamental = { };
70
75
  }
71
76
 
72
77
  this._dataFormat.quoteLast = null;
@@ -137,8 +142,12 @@ module.exports = (() => {
137
142
 
138
143
  if (this._single) {
139
144
  item.registerNewsExistsChangeHandler((exists, sender) => {
145
+ this._dataActual.newsExists = exists;
140
146
  this._dataFormat.newsExists = exists;
141
- this._dataFormat.newsExists = exists;
147
+ });
148
+
149
+ item._fundamentalDataChangeEvent((data, sender) => {
150
+ this._dataFormat.fundamental = data;
142
151
  });
143
152
  }
144
153
  });
@@ -251,6 +260,14 @@ module.exports = (() => {
251
260
  }
252
261
  }
253
262
 
263
+ setShowClosedPositions(value) {
264
+ assert.argumentIsRequired(value, 'value', Boolean);
265
+
266
+ if (this._showClosedPositions !== value) {
267
+ this._showClosedPositionsChangeEvent(this._showClosedPositions = value);
268
+ }
269
+ }
270
+
254
271
  setSuspended(value) {
255
272
  assert.argumentIsRequired(value, 'value', Boolean);
256
273
 
@@ -50,7 +50,7 @@ module.exports = (() => {
50
50
 
51
51
  this._data.unrealized = null;
52
52
  this._data.unrealizedChange = null;
53
-
53
+
54
54
  this._data.summaryTotalCurrent = null;
55
55
  this._data.summaryTotalCurrentChange = null;
56
56
 
@@ -61,12 +61,14 @@ module.exports = (() => {
61
61
  this._data.basisPrice = null;
62
62
 
63
63
  this._data.newsExists = false;
64
+ this._data.fundamental = { };
64
65
 
65
66
  calculateStaticData(this);
66
67
  calculatePriceData(this, null);
67
68
 
68
69
  this._quoteChangedEvent = new Event(this);
69
70
  this._newsExistsChangedEvent = new Event(this);
71
+ this._fundamentalDataChangeEvent = new Event(this);
70
72
  }
71
73
 
72
74
  /**
@@ -161,6 +163,18 @@ module.exports = (() => {
161
163
  }
162
164
  }
163
165
 
166
+ /**
167
+ * Sets fundamental data for the position.
168
+ *
169
+ * @public
170
+ * @param {Object} data
171
+ */
172
+ setPositionFundamentalData(data) {
173
+ assert.argumentIsRequired(data, 'data', Object);
174
+
175
+ this._fundamentalDataChangeEvent(this._data.fundamental = data);
176
+ }
177
+
164
178
  /**
165
179
  * Sets a flag which indicates if news article(s) exist for the encapsulated position's
166
180
  * symbol.
@@ -187,6 +201,16 @@ module.exports = (() => {
187
201
  this._quoteChangedEvent.register(handler);
188
202
  }
189
203
 
204
+ /**
205
+ * Registers an observer for fundamental data changes.
206
+ *
207
+ * @public
208
+ * @param {Function} handler
209
+ */
210
+ registerFundamentalDataChangeHandler(handler) {
211
+ this._fundamentalDataChangeEvent.register(handler);
212
+ }
213
+
190
214
  /**
191
215
  * Registers an observer changes to the status of news existence.
192
216
  *
@@ -321,10 +345,10 @@ module.exports = (() => {
321
345
  data.unrealizedChange = Decimal.ZERO;
322
346
  }
323
347
  }
324
-
348
+
325
349
  function calculateSummaryTotal(summary) {
326
350
  let returnRef;
327
-
351
+
328
352
  if (summary) {
329
353
  const period = summary.period;
330
354
 
@@ -332,7 +356,7 @@ module.exports = (() => {
332
356
  } else {
333
357
  returnRef = Decimal.ZERO;
334
358
  }
335
-
359
+
336
360
  return returnRef;
337
361
  }
338
362
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.132",
3
+ "version": "1.0.136",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1049,7 +1049,12 @@ module.exports = (() => {
1049
1049
  * @param {Object} data
1050
1050
  */
1051
1051
  setPositionFundamentalData(symbol, data) {
1052
- return;
1052
+ assert.argumentIsRequired(symbol, 'symbol', String);
1053
+ assert.argumentIsRequired(data, 'data', Object);
1054
+
1055
+ if (this._symbols.hasOwnProperty(symbol)) {
1056
+ this._symbols[symbol].forEach(item => item.setPositionFundamentalData(data));
1057
+ }
1053
1058
  }
1054
1059
 
1055
1060
  /**
@@ -1068,9 +1073,9 @@ module.exports = (() => {
1068
1073
  let map;
1069
1074
 
1070
1075
  if (display) {
1071
- map = this._symbols;
1072
- } else {
1073
1076
  map = this._symbolsDisplay;
1077
+ } else {
1078
+ map = this._symbols;
1074
1079
  }
1075
1080
 
1076
1081
  if (map.hasOwnProperty(symbol)) {
@@ -1192,15 +1197,18 @@ module.exports = (() => {
1192
1197
 
1193
1198
  this._excluded = false;
1194
1199
  this._suspended = false;
1200
+ this._showClosedPositions = false;
1195
1201
 
1196
1202
  this._marketPercentChangeEvent = new Event(this);
1197
1203
  this._excludedChangeEvent = new Event(this);
1204
+ this._showClosedPositionsChangeEvent = new Event(this);
1198
1205
 
1199
1206
  this._dataFormat = { };
1200
1207
  this._dataActual = { };
1201
1208
 
1202
1209
  this._dataFormat.key = this._key;
1203
1210
  this._dataFormat.description = this._description;
1211
+ this._dataFormat.hide = false;
1204
1212
  this._dataFormat.newsExists = false;
1205
1213
  this._dataFormat.quantity = null;
1206
1214
  this._dataFormat.basisPrice = null;
@@ -1217,10 +1225,12 @@ module.exports = (() => {
1217
1225
  this._dataFormat.portfolio = item.portfolio.portfolio;
1218
1226
  this._dataFormat.position = item.position.position;
1219
1227
  this._dataFormat.instrument = item.position.instrument;
1228
+ this._dataFormat.fundamental = item.fundamental || { };
1220
1229
  } else {
1221
1230
  this._dataFormat.portfolio = null;
1222
1231
  this._dataFormat.position = null;
1223
1232
  this._dataFormat.instrument = null;
1233
+ this._dataFormat.fundamental = { };
1224
1234
  }
1225
1235
 
1226
1236
  this._dataFormat.quoteLast = null;
@@ -1291,9 +1301,13 @@ module.exports = (() => {
1291
1301
 
1292
1302
  if (this._single) {
1293
1303
  item.registerNewsExistsChangeHandler((exists, sender) => {
1294
- this._dataFormat.newsExists = exists;
1304
+ this._dataActual.newsExists = exists;
1295
1305
  this._dataFormat.newsExists = exists;
1296
1306
  });
1307
+
1308
+ item._fundamentalDataChangeEvent((data, sender) => {
1309
+ this._dataFormat.fundamental = data;
1310
+ });
1297
1311
  }
1298
1312
  });
1299
1313
 
@@ -1405,6 +1419,14 @@ module.exports = (() => {
1405
1419
  }
1406
1420
  }
1407
1421
 
1422
+ setShowClosedPositions(value) {
1423
+ assert.argumentIsRequired(value, 'value', Boolean);
1424
+
1425
+ if (this._showClosedPositions !== value) {
1426
+ this._showClosedPositionsChangeEvent(this._showClosedPositions = value);
1427
+ }
1428
+ }
1429
+
1408
1430
  setSuspended(value) {
1409
1431
  assert.argumentIsRequired(value, 'value', Boolean);
1410
1432
 
@@ -1755,7 +1777,7 @@ module.exports = (() => {
1755
1777
 
1756
1778
  this._data.unrealized = null;
1757
1779
  this._data.unrealizedChange = null;
1758
-
1780
+
1759
1781
  this._data.summaryTotalCurrent = null;
1760
1782
  this._data.summaryTotalCurrentChange = null;
1761
1783
 
@@ -1766,12 +1788,14 @@ module.exports = (() => {
1766
1788
  this._data.basisPrice = null;
1767
1789
 
1768
1790
  this._data.newsExists = false;
1791
+ this._data.fundamental = { };
1769
1792
 
1770
1793
  calculateStaticData(this);
1771
1794
  calculatePriceData(this, null);
1772
1795
 
1773
1796
  this._quoteChangedEvent = new Event(this);
1774
1797
  this._newsExistsChangedEvent = new Event(this);
1798
+ this._fundamentalDataChangeEvent = new Event(this);
1775
1799
  }
1776
1800
 
1777
1801
  /**
@@ -1866,6 +1890,18 @@ module.exports = (() => {
1866
1890
  }
1867
1891
  }
1868
1892
 
1893
+ /**
1894
+ * Sets fundamental data for the position.
1895
+ *
1896
+ * @public
1897
+ * @param {Object} data
1898
+ */
1899
+ setPositionFundamentalData(data) {
1900
+ assert.argumentIsRequired(data, 'data', Object);
1901
+
1902
+ this._fundamentalDataChangeEvent(this._data.fundamental = data);
1903
+ }
1904
+
1869
1905
  /**
1870
1906
  * Sets a flag which indicates if news article(s) exist for the encapsulated position's
1871
1907
  * symbol.
@@ -1892,6 +1928,16 @@ module.exports = (() => {
1892
1928
  this._quoteChangedEvent.register(handler);
1893
1929
  }
1894
1930
 
1931
+ /**
1932
+ * Registers an observer for fundamental data changes.
1933
+ *
1934
+ * @public
1935
+ * @param {Function} handler
1936
+ */
1937
+ registerFundamentalDataChangeHandler(handler) {
1938
+ this._fundamentalDataChangeEvent.register(handler);
1939
+ }
1940
+
1895
1941
  /**
1896
1942
  * Registers an observer changes to the status of news existence.
1897
1943
  *
@@ -2026,10 +2072,10 @@ module.exports = (() => {
2026
2072
  data.unrealizedChange = Decimal.ZERO;
2027
2073
  }
2028
2074
  }
2029
-
2075
+
2030
2076
  function calculateSummaryTotal(summary) {
2031
2077
  let returnRef;
2032
-
2078
+
2033
2079
  if (summary) {
2034
2080
  const period = summary.period;
2035
2081
 
@@ -2037,7 +2083,7 @@ module.exports = (() => {
2037
2083
  } else {
2038
2084
  returnRef = Decimal.ZERO;
2039
2085
  }
2040
-
2086
+
2041
2087
  return returnRef;
2042
2088
  }
2043
2089