@barchart/portfolio-api-common 1.0.166 → 1.0.167

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.
@@ -167,6 +167,13 @@ module.exports = (() => {
167
167
  }, { });
168
168
  }
169
169
 
170
+ /**
171
+ * Adds a new portfolio to the container, injecting it into aggregation
172
+ * trees, as necessary.
173
+ *
174
+ * @public
175
+ * @param {Object} portfolio
176
+ */
170
177
  addPortfolio(portfolio) {
171
178
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
172
179
  assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
@@ -222,8 +229,25 @@ module.exports = (() => {
222
229
  }
223
230
  }
224
231
 
232
+ /**
233
+ * Removes an existing portfolio, and all of it's positions, from the container. This
234
+ * also triggers removal of the portfolio and it's positions from any applicable
235
+ * aggregation trees.
236
+ *
237
+ * @public
238
+ * @param {Object} portfolio
239
+ */
225
240
  removePortfolio(portfolio) {
241
+ assert.argumentIsRequired(portfolio, 'portfolio', Object);
242
+ assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
226
243
 
244
+ this.startTransaction(() => {
245
+ const itemsToRemove = getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(i => removePositionItem.call(this, i));
246
+
247
+ itemsToRemove.forEach(item => removePositionItem.call(this, item));
248
+
249
+
250
+ });
227
251
  }
228
252
 
229
253
  mutatePosition(position, summary) {
@@ -231,7 +255,7 @@ module.exports = (() => {
231
255
  }
232
256
 
233
257
  removePosition(position) {
234
-
258
+ removePositionItem.call(this, this._items.find((item) => item.position.position === position));
235
259
  }
236
260
 
237
261
  /**
@@ -409,13 +433,13 @@ module.exports = (() => {
409
433
  }
410
434
 
411
435
  /**
412
- * Returns all portfolios in the container
436
+ * Returns all portfolios in the container.
413
437
  *
414
438
  * @public
415
439
  * @return {Array.<Object>}
416
440
  */
417
441
  getPortfolios() {
418
- return this._portfolios;
442
+ return Object.keys(this._portfolios).map(id => this._portfolios[id]);
419
443
  }
420
444
 
421
445
  /**
@@ -426,24 +450,42 @@ module.exports = (() => {
426
450
  * @return {Array.<Object>}
427
451
  */
428
452
  getPositions(portfolio) {
429
- return this._items.reduce((positions, item) => {
430
- if (item.position.portfolio === portfolio) {
431
- positions.push(item);
432
- }
453
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
433
454
 
434
- return positions;
435
- }, []);
455
+ return getPositionItemsForPortfolio(this._items, portfolio).map(item => item.position);
436
456
  }
437
457
 
438
- startTransaction(name, executor) {
439
- assert.argumentIsRequired(name, 'name', String);
458
+ /**
459
+ * Pauses aggregation calculations during the processing of an action.
460
+ *
461
+ * @public
462
+ * @param {Function} executor
463
+ * @param {String=|Array.<String>=} names
464
+ */
465
+ startTransaction(executor, names) {
466
+ let namesToUse;
467
+
468
+ if (is.array(names)) {
469
+ assert.argumentIsArray(names, 'names', String);
470
+
471
+ namesToUse = names;
472
+ } else {
473
+ assert.argumentIsOptional(names, 'names', String);
474
+
475
+ if (names) {
476
+ namesToUse = [ names ];
477
+ } else {
478
+ namesToUse = Object.keys(this._trees);
479
+ }
480
+ }
481
+
440
482
  assert.argumentIsRequired(executor, 'executor', Function);
441
483
 
442
- this._trees[name].walk(group => group.setSuspended(true), false, false);
484
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(true), false, false));
443
485
 
444
486
  executor(this);
445
487
 
446
- this._trees[name].walk(group => group.setSuspended(false), false, false);
488
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(false), false, false));
447
489
  }
448
490
 
449
491
  toString() {
@@ -604,5 +646,23 @@ module.exports = (() => {
604
646
  });
605
647
  }
606
648
 
649
+ function getPositionItemsForPortfolio(items, portfolio) {
650
+ return items.reduce((positionItems, item) => {
651
+ if (item.position.portfolio === portfolio) {
652
+ positionItems.push(item.position);
653
+ }
654
+
655
+ return positionItems;
656
+ }, [ ]);
657
+ }
658
+
659
+ function removePositionItem(positionItem) {
660
+ if (!positionItem) {
661
+ return;
662
+ }
663
+
664
+ positionItem.dispose();
665
+ }
666
+
607
667
  return PositionContainer;
608
668
  })();
@@ -373,11 +373,19 @@ module.exports = (() => {
373
373
  }
374
374
  }
375
375
 
376
+ /**
377
+ * Stops (or starts) group-level aggregation calculations.
378
+ *
379
+ * @public
380
+ * @param {Boolean} value
381
+ */
376
382
  setSuspended(value) {
377
383
  assert.argumentIsRequired(value, 'value', Boolean);
378
384
 
379
385
  if (this._suspended !== value) {
380
- if (this._suspended = value) {
386
+ this._suspended = value;
387
+
388
+ if (!this._suspended) {
381
389
  this.refresh();
382
390
  }
383
391
  }
@@ -2,6 +2,7 @@ const array = require('@barchart/common-js/lang/array'),
2
2
  assert = require('@barchart/common-js/lang/assert'),
3
3
  Currency = require('@barchart/common-js/lang/Currency'),
4
4
  Decimal = require('@barchart/common-js/lang/Decimal'),
5
+ Disposable = require('@barchart/common-js/lang/Disposable'),
5
6
  Event = require('@barchart/common-js/messaging/Event'),
6
7
  is = require('@barchart/common-js/lang/is');
7
8
 
@@ -21,8 +22,10 @@ module.exports = (() => {
21
22
  * @param {Object} currentSummary
22
23
  * @param {Array.<Object>} previousSummaries
23
24
  */
24
- class PositionItem {
25
+ class PositionItem extends Disposable {
25
26
  constructor(portfolio, position, currentSummary, previousSummaries) {
27
+ super();
28
+
26
29
  this._portfolio = portfolio;
27
30
  this._position = position;
28
31
  this._currency = position.instrument.currency || Currency.CAD;
@@ -67,6 +70,7 @@ module.exports = (() => {
67
70
  this._quoteChangedEvent = new Event(this);
68
71
  this._newsExistsChangedEvent = new Event(this);
69
72
  this._fundamentalDataChangeEvent = new Event(this);
73
+ this._positionItemDisposeEvent = new Event(this);
70
74
  }
71
75
 
72
76
  /**
@@ -149,6 +153,10 @@ module.exports = (() => {
149
153
  setQuote(quote) {
150
154
  assert.argumentIsRequired(quote, 'quote', Object);
151
155
 
156
+ if (this.getIsDisposed()) {
157
+ return;
158
+ }
159
+
152
160
  if (this._currentPricePrevious !== quote.lastPrice) {
153
161
  calculatePriceData(this, quote.lastPrice);
154
162
 
@@ -170,6 +178,10 @@ module.exports = (() => {
170
178
  setPositionFundamentalData(data) {
171
179
  assert.argumentIsRequired(data, 'data', Object);
172
180
 
181
+ if (this.getIsDisposed()) {
182
+ return;
183
+ }
184
+
173
185
  this._fundamentalDataChangeEvent.fire(this._data.fundamental = data);
174
186
  }
175
187
 
@@ -183,6 +195,10 @@ module.exports = (() => {
183
195
  setNewsArticleExists(value) {
184
196
  assert.argumentIsRequired(value, 'value', Boolean);
185
197
 
198
+ if (this.getIsDisposed()) {
199
+ return;
200
+ }
201
+
186
202
  if (this._data.newsExists !== value) {
187
203
  this._newsExistsChangedEvent.fire(this._data.newsExists = value);
188
204
  }
@@ -222,6 +238,26 @@ module.exports = (() => {
222
238
  return this._newsExistsChangedEvent.register(handler);
223
239
  }
224
240
 
241
+ /**
242
+ * Registers an observer for object disposal.
243
+ *
244
+ * @public
245
+ * @param {Function} handler
246
+ * @returns {Disposable}
247
+ */
248
+ registerPositionItemDisposeHandler(handler) {
249
+ return this._positionItemDisposeEvent.register(handler);
250
+ }
251
+
252
+ _onDispose() {
253
+ this._positionItemDisposeEvent.fire(this);
254
+
255
+ this._quoteChangedEvent.clear();
256
+ this._newsExistsChangedEvent.clear();
257
+ this._fundamentalDataChangeEvent.clear();
258
+ this._positionItemDisposeEvent.clear();
259
+ }
260
+
225
261
  toString() {
226
262
  return '[PositionItem]';
227
263
  }
@@ -4,6 +4,8 @@ const assert = require('@barchart/common-js/lang/assert'),
4
4
 
5
5
  const InstrumentType = require('./../../data/InstrumentType');
6
6
 
7
+ const PositionLevelType = require('./PositionLevelType');
8
+
7
9
  module.exports = (() => {
8
10
  'use strict';
9
11
 
@@ -23,8 +25,9 @@ module.exports = (() => {
23
25
  * @param {Function=} requiredGroupGenerator
24
26
  */
25
27
  class PositionLevelDefinition {
26
- constructor(name, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
28
+ constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
27
29
  assert.argumentIsRequired(name, 'name', String);
30
+ assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
28
31
  assert.argumentIsRequired(keySelector, 'keySelector', Function);
29
32
  assert.argumentIsRequired(descriptionSelector, 'descriptionSelector', Function);
30
33
  assert.argumentIsRequired(currencySelector, 'currencySelector', Function);
@@ -38,6 +41,7 @@ module.exports = (() => {
38
41
  assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
39
42
 
40
43
  this._name = name;
44
+ this._type = type;
41
45
 
42
46
  this._keySelector = keySelector;
43
47
  this._descriptionSelector = descriptionSelector;
@@ -61,6 +65,16 @@ module.exports = (() => {
61
65
  return this._name;
62
66
  }
63
67
 
68
+ /**
69
+ * A general description of the type of items grouped together.
70
+ *
71
+ * @public
72
+ * @return {PositionLevelType}
73
+ */
74
+ get type() {
75
+ return this._type;
76
+ }
77
+
64
78
  /**
65
79
  * A function, when given a {@link PositionItem} returns a string that is used
66
80
  * to group {@link PositionItem} instances into different groups.
@@ -0,0 +1,29 @@
1
+ const Enum = require('@barchart/common-js/lang/Enum');
2
+
3
+ module.exports = (() => {
4
+ 'use strict';
5
+
6
+ class PositionLevelType extends Enum {
7
+ constructor(code) {
8
+ super(code, code);
9
+ }
10
+
11
+ static get PORTFOLIO() {
12
+ return portfolio;
13
+ }
14
+
15
+ static get POSITION() {
16
+ return position;
17
+ }
18
+
19
+ static get OTHER() {
20
+ return other;
21
+ }
22
+ }
23
+
24
+ const portfolio = new PositionLevelType('PORTFOLIO');
25
+ const position = new PositionLevelType('POSITION');
26
+ const other = new PositionLevelType('OTHER');
27
+
28
+ return PositionLevelType;
29
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.166",
3
+ "version": "1.0.167",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -116,7 +116,7 @@ module.exports = (() => {
116
116
  return InstrumentType;
117
117
  })();
118
118
 
119
- },{"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/assert":21}],2:[function(require,module,exports){
119
+ },{"@barchart/common-js/lang/Enum":19,"@barchart/common-js/lang/assert":22}],2:[function(require,module,exports){
120
120
  const array = require('@barchart/common-js/lang/array'),
121
121
  assert = require('@barchart/common-js/lang/assert'),
122
122
  Day = require('@barchart/common-js/lang/Day'),
@@ -373,7 +373,7 @@ module.exports = (() => {
373
373
  return PositionSummaryFrame;
374
374
  })();
375
375
 
376
- },{"@barchart/common-js/lang/Day":15,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],3:[function(require,module,exports){
376
+ },{"@barchart/common-js/lang/Day":16,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Enum":19,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24}],3:[function(require,module,exports){
377
377
  const assert = require('@barchart/common-js/lang/assert'),
378
378
  Enum = require('@barchart/common-js/lang/Enum');
379
379
 
@@ -713,7 +713,7 @@ module.exports = (() => {
713
713
  return TransactionType;
714
714
  })();
715
715
 
716
- },{"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/assert":21}],4:[function(require,module,exports){
716
+ },{"@barchart/common-js/lang/Enum":19,"@barchart/common-js/lang/assert":22}],4:[function(require,module,exports){
717
717
  const array = require('@barchart/common-js/lang/array'),
718
718
  assert = require('@barchart/common-js/lang/assert'),
719
719
  ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
@@ -883,6 +883,13 @@ module.exports = (() => {
883
883
  }, { });
884
884
  }
885
885
 
886
+ /**
887
+ * Adds a new portfolio to the container, injecting it into aggregation
888
+ * trees, as necessary.
889
+ *
890
+ * @public
891
+ * @param {Object} portfolio
892
+ */
886
893
  addPortfolio(portfolio) {
887
894
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
888
895
  assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
@@ -938,8 +945,25 @@ module.exports = (() => {
938
945
  }
939
946
  }
940
947
 
948
+ /**
949
+ * Removes an existing portfolio, and all of it's positions, from the container. This
950
+ * also triggers removal of the portfolio and it's positions from any applicable
951
+ * aggregation trees.
952
+ *
953
+ * @public
954
+ * @param {Object} portfolio
955
+ */
941
956
  removePortfolio(portfolio) {
957
+ assert.argumentIsRequired(portfolio, 'portfolio', Object);
958
+ assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
942
959
 
960
+ this.startTransaction(() => {
961
+ const itemsToRemove = getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(i => removePositionItem.call(this, i));
962
+
963
+ itemsToRemove.forEach(item => removePositionItem.call(this, item));
964
+
965
+
966
+ });
943
967
  }
944
968
 
945
969
  mutatePosition(position, summary) {
@@ -947,7 +971,7 @@ module.exports = (() => {
947
971
  }
948
972
 
949
973
  removePosition(position) {
950
-
974
+ removePositionItem.call(this, this._items.find((item) => item.position.position === position));
951
975
  }
952
976
 
953
977
  /**
@@ -1125,13 +1149,13 @@ module.exports = (() => {
1125
1149
  }
1126
1150
 
1127
1151
  /**
1128
- * Returns all portfolios in the container
1152
+ * Returns all portfolios in the container.
1129
1153
  *
1130
1154
  * @public
1131
1155
  * @return {Array.<Object>}
1132
1156
  */
1133
1157
  getPortfolios() {
1134
- return this._portfolios;
1158
+ return Object.keys(this._portfolios).map(id => this._portfolios[id]);
1135
1159
  }
1136
1160
 
1137
1161
  /**
@@ -1142,24 +1166,42 @@ module.exports = (() => {
1142
1166
  * @return {Array.<Object>}
1143
1167
  */
1144
1168
  getPositions(portfolio) {
1145
- return this._items.reduce((positions, item) => {
1146
- if (item.position.portfolio === portfolio) {
1147
- positions.push(item);
1148
- }
1169
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
1149
1170
 
1150
- return positions;
1151
- }, []);
1171
+ return getPositionItemsForPortfolio(this._items, portfolio).map(item => item.position);
1152
1172
  }
1153
1173
 
1154
- startTransaction(name, executor) {
1155
- assert.argumentIsRequired(name, 'name', String);
1174
+ /**
1175
+ * Pauses aggregation calculations during the processing of an action.
1176
+ *
1177
+ * @public
1178
+ * @param {Function} executor
1179
+ * @param {String=|Array.<String>=} names
1180
+ */
1181
+ startTransaction(executor, names) {
1182
+ let namesToUse;
1183
+
1184
+ if (is.array(names)) {
1185
+ assert.argumentIsArray(names, 'names', String);
1186
+
1187
+ namesToUse = names;
1188
+ } else {
1189
+ assert.argumentIsOptional(names, 'names', String);
1190
+
1191
+ if (names) {
1192
+ namesToUse = [ names ];
1193
+ } else {
1194
+ namesToUse = Object.keys(this._trees);
1195
+ }
1196
+ }
1197
+
1156
1198
  assert.argumentIsRequired(executor, 'executor', Function);
1157
1199
 
1158
- this._trees[name].walk(group => group.setSuspended(true), false, false);
1200
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(true), false, false));
1159
1201
 
1160
1202
  executor(this);
1161
1203
 
1162
- this._trees[name].walk(group => group.setSuspended(false), false, false);
1204
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(false), false, false));
1163
1205
  }
1164
1206
 
1165
1207
  toString() {
@@ -1320,10 +1362,28 @@ module.exports = (() => {
1320
1362
  });
1321
1363
  }
1322
1364
 
1365
+ function getPositionItemsForPortfolio(items, portfolio) {
1366
+ return items.reduce((positionItems, item) => {
1367
+ if (item.position.portfolio === portfolio) {
1368
+ positionItems.push(item.position);
1369
+ }
1370
+
1371
+ return positionItems;
1372
+ }, [ ]);
1373
+ }
1374
+
1375
+ function removePositionItem(positionItem) {
1376
+ if (!positionItem) {
1377
+ return;
1378
+ }
1379
+
1380
+ positionItem.dispose();
1381
+ }
1382
+
1323
1383
  return PositionContainer;
1324
1384
  })();
1325
1385
 
1326
- },{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionTreeDefinition":8,"@barchart/common-js/collections/Tree":10,"@barchart/common-js/collections/sorting/ComparatorBuilder":11,"@barchart/common-js/collections/sorting/comparators":12,"@barchart/common-js/collections/specialized/DisposableStack":13,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Rate":19,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],5:[function(require,module,exports){
1386
+ },{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionTreeDefinition":9,"@barchart/common-js/collections/Tree":11,"@barchart/common-js/collections/sorting/ComparatorBuilder":12,"@barchart/common-js/collections/sorting/comparators":13,"@barchart/common-js/collections/specialized/DisposableStack":14,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Rate":20,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24}],5:[function(require,module,exports){
1327
1387
  const array = require('@barchart/common-js/lang/array'),
1328
1388
  assert = require('@barchart/common-js/lang/assert'),
1329
1389
  Currency = require('@barchart/common-js/lang/Currency'),
@@ -1699,11 +1759,19 @@ module.exports = (() => {
1699
1759
  }
1700
1760
  }
1701
1761
 
1762
+ /**
1763
+ * Stops (or starts) group-level aggregation calculations.
1764
+ *
1765
+ * @public
1766
+ * @param {Boolean} value
1767
+ */
1702
1768
  setSuspended(value) {
1703
1769
  assert.argumentIsRequired(value, 'value', Boolean);
1704
1770
 
1705
1771
  if (this._suspended !== value) {
1706
- if (this._suspended = value) {
1772
+ this._suspended = value;
1773
+
1774
+ if (!this._suspended) {
1707
1775
  this.refresh();
1708
1776
  }
1709
1777
  }
@@ -2029,11 +2097,12 @@ module.exports = (() => {
2029
2097
  return PositionGroup;
2030
2098
  })();
2031
2099
 
2032
- },{"./../data/InstrumentType":1,"@barchart/common-js/collections/specialized/DisposableStack":13,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Rate":19,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/formatter":22,"@barchart/common-js/lang/is":23,"@barchart/common-js/messaging/Event":25}],6:[function(require,module,exports){
2100
+ },{"./../data/InstrumentType":1,"@barchart/common-js/collections/specialized/DisposableStack":14,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Rate":20,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/formatter":23,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],6:[function(require,module,exports){
2033
2101
  const array = require('@barchart/common-js/lang/array'),
2034
2102
  assert = require('@barchart/common-js/lang/assert'),
2035
2103
  Currency = require('@barchart/common-js/lang/Currency'),
2036
2104
  Decimal = require('@barchart/common-js/lang/Decimal'),
2105
+ Disposable = require('@barchart/common-js/lang/Disposable'),
2037
2106
  Event = require('@barchart/common-js/messaging/Event'),
2038
2107
  is = require('@barchart/common-js/lang/is');
2039
2108
 
@@ -2053,8 +2122,10 @@ module.exports = (() => {
2053
2122
  * @param {Object} currentSummary
2054
2123
  * @param {Array.<Object>} previousSummaries
2055
2124
  */
2056
- class PositionItem {
2125
+ class PositionItem extends Disposable {
2057
2126
  constructor(portfolio, position, currentSummary, previousSummaries) {
2127
+ super();
2128
+
2058
2129
  this._portfolio = portfolio;
2059
2130
  this._position = position;
2060
2131
  this._currency = position.instrument.currency || Currency.CAD;
@@ -2099,6 +2170,7 @@ module.exports = (() => {
2099
2170
  this._quoteChangedEvent = new Event(this);
2100
2171
  this._newsExistsChangedEvent = new Event(this);
2101
2172
  this._fundamentalDataChangeEvent = new Event(this);
2173
+ this._positionItemDisposeEvent = new Event(this);
2102
2174
  }
2103
2175
 
2104
2176
  /**
@@ -2181,6 +2253,10 @@ module.exports = (() => {
2181
2253
  setQuote(quote) {
2182
2254
  assert.argumentIsRequired(quote, 'quote', Object);
2183
2255
 
2256
+ if (this.getIsDisposed()) {
2257
+ return;
2258
+ }
2259
+
2184
2260
  if (this._currentPricePrevious !== quote.lastPrice) {
2185
2261
  calculatePriceData(this, quote.lastPrice);
2186
2262
 
@@ -2202,6 +2278,10 @@ module.exports = (() => {
2202
2278
  setPositionFundamentalData(data) {
2203
2279
  assert.argumentIsRequired(data, 'data', Object);
2204
2280
 
2281
+ if (this.getIsDisposed()) {
2282
+ return;
2283
+ }
2284
+
2205
2285
  this._fundamentalDataChangeEvent.fire(this._data.fundamental = data);
2206
2286
  }
2207
2287
 
@@ -2215,6 +2295,10 @@ module.exports = (() => {
2215
2295
  setNewsArticleExists(value) {
2216
2296
  assert.argumentIsRequired(value, 'value', Boolean);
2217
2297
 
2298
+ if (this.getIsDisposed()) {
2299
+ return;
2300
+ }
2301
+
2218
2302
  if (this._data.newsExists !== value) {
2219
2303
  this._newsExistsChangedEvent.fire(this._data.newsExists = value);
2220
2304
  }
@@ -2254,6 +2338,26 @@ module.exports = (() => {
2254
2338
  return this._newsExistsChangedEvent.register(handler);
2255
2339
  }
2256
2340
 
2341
+ /**
2342
+ * Registers an observer for object disposal.
2343
+ *
2344
+ * @public
2345
+ * @param {Function} handler
2346
+ * @returns {Disposable}
2347
+ */
2348
+ registerPositionItemDisposeHandler(handler) {
2349
+ return this._positionItemDisposeEvent.register(handler);
2350
+ }
2351
+
2352
+ _onDispose() {
2353
+ this._positionItemDisposeEvent.fire(this);
2354
+
2355
+ this._quoteChangedEvent.clear();
2356
+ this._newsExistsChangedEvent.clear();
2357
+ this._fundamentalDataChangeEvent.clear();
2358
+ this._positionItemDisposeEvent.clear();
2359
+ }
2360
+
2257
2361
  toString() {
2258
2362
  return '[PositionItem]';
2259
2363
  }
@@ -2397,13 +2501,15 @@ module.exports = (() => {
2397
2501
  return PositionItem;
2398
2502
  })();
2399
2503
 
2400
- },{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23,"@barchart/common-js/messaging/Event":25}],7:[function(require,module,exports){
2504
+ },{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],7:[function(require,module,exports){
2401
2505
  const assert = require('@barchart/common-js/lang/assert'),
2402
2506
  Currency = require('@barchart/common-js/lang/Currency'),
2403
2507
  is = require('@barchart/common-js/lang/is');
2404
2508
 
2405
2509
  const InstrumentType = require('./../../data/InstrumentType');
2406
2510
 
2511
+ const PositionLevelType = require('./PositionLevelType');
2512
+
2407
2513
  module.exports = (() => {
2408
2514
  'use strict';
2409
2515
 
@@ -2423,8 +2529,9 @@ module.exports = (() => {
2423
2529
  * @param {Function=} requiredGroupGenerator
2424
2530
  */
2425
2531
  class PositionLevelDefinition {
2426
- constructor(name, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
2532
+ constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
2427
2533
  assert.argumentIsRequired(name, 'name', String);
2534
+ assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
2428
2535
  assert.argumentIsRequired(keySelector, 'keySelector', Function);
2429
2536
  assert.argumentIsRequired(descriptionSelector, 'descriptionSelector', Function);
2430
2537
  assert.argumentIsRequired(currencySelector, 'currencySelector', Function);
@@ -2438,6 +2545,7 @@ module.exports = (() => {
2438
2545
  assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
2439
2546
 
2440
2547
  this._name = name;
2548
+ this._type = type;
2441
2549
 
2442
2550
  this._keySelector = keySelector;
2443
2551
  this._descriptionSelector = descriptionSelector;
@@ -2461,6 +2569,16 @@ module.exports = (() => {
2461
2569
  return this._name;
2462
2570
  }
2463
2571
 
2572
+ /**
2573
+ * A general description of the type of items grouped together.
2574
+ *
2575
+ * @public
2576
+ * @return {PositionLevelType}
2577
+ */
2578
+ get type() {
2579
+ return this._type;
2580
+ }
2581
+
2464
2582
  /**
2465
2583
  * A function, when given a {@link PositionItem} returns a string that is used
2466
2584
  * to group {@link PositionItem} instances into different groups.
@@ -2664,7 +2782,38 @@ module.exports = (() => {
2664
2782
  return PositionLevelDefinition;
2665
2783
  })();
2666
2784
 
2667
- },{"./../../data/InstrumentType":1,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],8:[function(require,module,exports){
2785
+ },{"./../../data/InstrumentType":1,"./PositionLevelType":8,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24}],8:[function(require,module,exports){
2786
+ const Enum = require('@barchart/common-js/lang/Enum');
2787
+
2788
+ module.exports = (() => {
2789
+ 'use strict';
2790
+
2791
+ class PositionLevelType extends Enum {
2792
+ constructor(code) {
2793
+ super(code, code);
2794
+ }
2795
+
2796
+ static get PORTFOLIO() {
2797
+ return portfolio;
2798
+ }
2799
+
2800
+ static get POSITION() {
2801
+ return position;
2802
+ }
2803
+
2804
+ static get OTHER() {
2805
+ return other;
2806
+ }
2807
+ }
2808
+
2809
+ const portfolio = new PositionLevelType('PORTFOLIO');
2810
+ const position = new PositionLevelType('POSITION');
2811
+ const other = new PositionLevelType('OTHER');
2812
+
2813
+ return PositionLevelType;
2814
+ })();
2815
+
2816
+ },{"@barchart/common-js/lang/Enum":19}],9:[function(require,module,exports){
2668
2817
  const assert = require('@barchart/common-js/lang/assert');
2669
2818
 
2670
2819
  const PositionLevelDefinition = require('./PositionLevelDefinition');
@@ -2735,7 +2884,7 @@ module.exports = (() => {
2735
2884
  return PositionTreeDefinitions;
2736
2885
  })();
2737
2886
 
2738
- },{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":21}],9:[function(require,module,exports){
2887
+ },{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":22}],10:[function(require,module,exports){
2739
2888
  'use strict';
2740
2889
 
2741
2890
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -2867,7 +3016,7 @@ module.exports = function () {
2867
3016
  return Stack;
2868
3017
  }();
2869
3018
 
2870
- },{"./../lang/assert":21}],10:[function(require,module,exports){
3019
+ },{"./../lang/assert":22}],11:[function(require,module,exports){
2871
3020
  'use strict';
2872
3021
 
2873
3022
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -3176,7 +3325,7 @@ module.exports = function () {
3176
3325
  return Tree;
3177
3326
  }();
3178
3327
 
3179
- },{"./../lang/is":23}],11:[function(require,module,exports){
3328
+ },{"./../lang/is":24}],12:[function(require,module,exports){
3180
3329
  'use strict';
3181
3330
 
3182
3331
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -3320,7 +3469,7 @@ module.exports = function () {
3320
3469
  return ComparatorBuilder;
3321
3470
  }();
3322
3471
 
3323
- },{"./../../lang/assert":21,"./comparators":12}],12:[function(require,module,exports){
3472
+ },{"./../../lang/assert":22,"./comparators":13}],13:[function(require,module,exports){
3324
3473
  'use strict';
3325
3474
 
3326
3475
  var assert = require('./../../lang/assert');
@@ -3395,7 +3544,7 @@ module.exports = function () {
3395
3544
  };
3396
3545
  }();
3397
3546
 
3398
- },{"./../../lang/assert":21}],13:[function(require,module,exports){
3547
+ },{"./../../lang/assert":22}],14:[function(require,module,exports){
3399
3548
  'use strict';
3400
3549
 
3401
3550
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -3503,7 +3652,7 @@ module.exports = function () {
3503
3652
  return DisposableStack;
3504
3653
  }();
3505
3654
 
3506
- },{"./../../lang/Disposable":17,"./../../lang/assert":21,"./../../lang/is":23,"./../Stack":9}],14:[function(require,module,exports){
3655
+ },{"./../../lang/Disposable":18,"./../../lang/assert":22,"./../../lang/is":24,"./../Stack":10}],15:[function(require,module,exports){
3507
3656
  'use strict';
3508
3657
 
3509
3658
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -3646,7 +3795,7 @@ module.exports = function () {
3646
3795
  return Currency;
3647
3796
  }();
3648
3797
 
3649
- },{"./Enum":18,"./assert":21,"./is":23}],15:[function(require,module,exports){
3798
+ },{"./Enum":19,"./assert":22,"./is":24}],16:[function(require,module,exports){
3650
3799
  'use strict';
3651
3800
 
3652
3801
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -4199,7 +4348,7 @@ module.exports = function () {
4199
4348
  return Day;
4200
4349
  }();
4201
4350
 
4202
- },{"./../collections/sorting/ComparatorBuilder":11,"./../collections/sorting/comparators":12,"./assert":21,"./is":23}],16:[function(require,module,exports){
4351
+ },{"./../collections/sorting/ComparatorBuilder":12,"./../collections/sorting/comparators":13,"./assert":22,"./is":24}],17:[function(require,module,exports){
4203
4352
  'use strict';
4204
4353
 
4205
4354
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -4779,7 +4928,7 @@ module.exports = function () {
4779
4928
  return Decimal;
4780
4929
  }();
4781
4930
 
4782
- },{"./Enum":18,"./assert":21,"./is":23,"big.js":26}],17:[function(require,module,exports){
4931
+ },{"./Enum":19,"./assert":22,"./is":24,"big.js":27}],18:[function(require,module,exports){
4783
4932
  'use strict';
4784
4933
 
4785
4934
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -4928,7 +5077,7 @@ module.exports = function () {
4928
5077
  return Disposable;
4929
5078
  }();
4930
5079
 
4931
- },{"./assert":21}],18:[function(require,module,exports){
5080
+ },{"./assert":22}],19:[function(require,module,exports){
4932
5081
  'use strict';
4933
5082
 
4934
5083
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -5070,7 +5219,7 @@ module.exports = function () {
5070
5219
  return Enum;
5071
5220
  }();
5072
5221
 
5073
- },{"./assert":21}],19:[function(require,module,exports){
5222
+ },{"./assert":22}],20:[function(require,module,exports){
5074
5223
  'use strict';
5075
5224
 
5076
5225
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -5325,7 +5474,7 @@ module.exports = function () {
5325
5474
  return Rate;
5326
5475
  }();
5327
5476
 
5328
- },{"./Currency":14,"./Decimal":16,"./assert":21,"./memoize":24}],20:[function(require,module,exports){
5477
+ },{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
5329
5478
  'use strict';
5330
5479
 
5331
5480
  var assert = require('./assert'),
@@ -5706,7 +5855,7 @@ module.exports = function () {
5706
5855
  };
5707
5856
  }();
5708
5857
 
5709
- },{"./assert":21,"./is":23}],21:[function(require,module,exports){
5858
+ },{"./assert":22,"./is":24}],22:[function(require,module,exports){
5710
5859
  'use strict';
5711
5860
 
5712
5861
  var is = require('./is');
@@ -5854,7 +6003,7 @@ module.exports = function () {
5854
6003
  };
5855
6004
  }();
5856
6005
 
5857
- },{"./is":23}],22:[function(require,module,exports){
6006
+ },{"./is":24}],23:[function(require,module,exports){
5858
6007
  'use strict';
5859
6008
 
5860
6009
  module.exports = function () {
@@ -5919,7 +6068,7 @@ module.exports = function () {
5919
6068
  };
5920
6069
  }();
5921
6070
 
5922
- },{}],23:[function(require,module,exports){
6071
+ },{}],24:[function(require,module,exports){
5923
6072
  'use strict';
5924
6073
 
5925
6074
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@@ -6142,7 +6291,7 @@ module.exports = function () {
6142
6291
  };
6143
6292
  }();
6144
6293
 
6145
- },{}],24:[function(require,module,exports){
6294
+ },{}],25:[function(require,module,exports){
6146
6295
  'use strict';
6147
6296
 
6148
6297
  var assert = require('./assert'),
@@ -6215,7 +6364,7 @@ module.exports = function () {
6215
6364
  };
6216
6365
  }();
6217
6366
 
6218
- },{"./assert":21,"./is":23}],25:[function(require,module,exports){
6367
+ },{"./assert":22,"./is":24}],26:[function(require,module,exports){
6219
6368
  'use strict';
6220
6369
 
6221
6370
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -6387,7 +6536,7 @@ module.exports = function () {
6387
6536
  return Event;
6388
6537
  }();
6389
6538
 
6390
- },{"./../lang/Disposable":17,"./../lang/assert":21}],26:[function(require,module,exports){
6539
+ },{"./../lang/Disposable":18,"./../lang/assert":22}],27:[function(require,module,exports){
6391
6540
  /*
6392
6541
  * big.js v5.0.3
6393
6542
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -7328,7 +7477,7 @@ module.exports = function () {
7328
7477
  }
7329
7478
  })(this);
7330
7479
 
7331
- },{}],27:[function(require,module,exports){
7480
+ },{}],28:[function(require,module,exports){
7332
7481
  const Day = require('@barchart/common-js/lang/Day'),
7333
7482
  Decimal = require('@barchart/common-js/lang/Decimal');
7334
7483
 
@@ -7685,7 +7834,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
7685
7834
  });
7686
7835
  });
7687
7836
 
7688
- },{"./../../../lib/data/PositionSummaryFrame":2,"./../../../lib/data/TransactionType":3,"@barchart/common-js/lang/Day":15,"@barchart/common-js/lang/Decimal":16}],28:[function(require,module,exports){
7837
+ },{"./../../../lib/data/PositionSummaryFrame":2,"./../../../lib/data/TransactionType":3,"@barchart/common-js/lang/Day":16,"@barchart/common-js/lang/Decimal":17}],29:[function(require,module,exports){
7689
7838
  const Currency = require('@barchart/common-js/lang/Currency'),
7690
7839
  Decimal = require('@barchart/common-js/lang/Decimal');
7691
7840
 
@@ -7693,6 +7842,7 @@ const InstrumentType = require('./../../../lib/data/InstrumentType');
7693
7842
 
7694
7843
  const PositionContainer = require('./../../../lib/processing/PositionContainer'),
7695
7844
  PositionLevelDefinition = require('./../../../lib/processing/definitions/PositionLevelDefinition'),
7845
+ PositionLevelType = require('./../../../lib/processing/definitions/PositionLevelType'),
7696
7846
  PositionTreeDefinition = require('./../../../lib/processing/definitions/PositionTreeDefinition');
7697
7847
 
7698
7848
  describe('When a position container data is gathered', () => {
@@ -7754,9 +7904,9 @@ describe('When a position container data is gathered', () => {
7754
7904
  beforeEach(() => {
7755
7905
  definitions = [
7756
7906
  new PositionTreeDefinition(name = 'the only tree', [
7757
- new PositionLevelDefinition('Total', x => 'totals', x => 'Total', x => Currency.CAD),
7758
- new PositionLevelDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
7759
- new PositionLevelDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
7907
+ new PositionLevelDefinition('Total', PositionLevelType.OTHER, x => 'totals', x => 'Total', x => Currency.CAD),
7908
+ new PositionLevelDefinition('Portfolio', PositionLevelType.PORTFOLIO, x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
7909
+ new PositionLevelDefinition('Position', PositionLevelType.POSITION, x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
7760
7910
  ])
7761
7911
  ];
7762
7912
 
@@ -7794,4 +7944,4 @@ describe('When a position container data is gathered', () => {
7794
7944
  });
7795
7945
  });
7796
7946
 
7797
- },{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":4,"./../../../lib/processing/definitions/PositionLevelDefinition":7,"./../../../lib/processing/definitions/PositionTreeDefinition":8,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16}]},{},[27,28]);
7947
+ },{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":4,"./../../../lib/processing/definitions/PositionLevelDefinition":7,"./../../../lib/processing/definitions/PositionLevelType":8,"./../../../lib/processing/definitions/PositionTreeDefinition":9,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17}]},{},[28,29]);
@@ -5,6 +5,7 @@ const InstrumentType = require('./../../../lib/data/InstrumentType');
5
5
 
6
6
  const PositionContainer = require('./../../../lib/processing/PositionContainer'),
7
7
  PositionLevelDefinition = require('./../../../lib/processing/definitions/PositionLevelDefinition'),
8
+ PositionLevelType = require('./../../../lib/processing/definitions/PositionLevelType'),
8
9
  PositionTreeDefinition = require('./../../../lib/processing/definitions/PositionTreeDefinition');
9
10
 
10
11
  describe('When a position container data is gathered', () => {
@@ -66,9 +67,9 @@ describe('When a position container data is gathered', () => {
66
67
  beforeEach(() => {
67
68
  definitions = [
68
69
  new PositionTreeDefinition(name = 'the only tree', [
69
- new PositionLevelDefinition('Total', x => 'totals', x => 'Total', x => Currency.CAD),
70
- new PositionLevelDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
71
- new PositionLevelDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
70
+ new PositionLevelDefinition('Total', PositionLevelType.OTHER, x => 'totals', x => 'Total', x => Currency.CAD),
71
+ new PositionLevelDefinition('Portfolio', PositionLevelType.PORTFOLIO, x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
72
+ new PositionLevelDefinition('Position', PositionLevelType.POSITION, x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
72
73
  ])
73
74
  ];
74
75