@barchart/portfolio-api-common 1.0.165 → 1.0.169

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.
@@ -1,4 +1,4 @@
1
- (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
1
+ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  const assert = require('@barchart/common-js/lang/assert'),
3
3
  Enum = require('@barchart/common-js/lang/Enum');
4
4
 
@@ -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'),
@@ -727,7 +727,9 @@ const array = require('@barchart/common-js/lang/array'),
727
727
 
728
728
  const PositionSummaryFrame = require('./../data/PositionSummaryFrame');
729
729
 
730
- const PositionTreeDefinition = require('./definitions/PositionTreeDefinition');
730
+ const PositionLevelDefinition = require('./definitions/PositionLevelDefinition'),
731
+ PositionLevelType = require('./definitions/PositionLevelType'),
732
+ PositionTreeDefinition = require('./definitions/PositionTreeDefinition');
731
733
 
732
734
  const PositionGroup = require('./PositionGroup'),
733
735
  PositionItem = require('./PositionItem');
@@ -844,10 +846,9 @@ module.exports = (() => {
844
846
  }, { });
845
847
 
846
848
  this._currencies = this._items.reduce((map, item) => {
847
- const position = item.position;
849
+ const currency = extractCurrency(item.position);
848
850
 
849
- if (position.instrument && position.instrument.currency) {
850
- const currency = position.instrument.currency;
851
+ if (currency) {
851
852
  const code = currency.code;
852
853
 
853
854
  if (!map.hasOwnProperty(code)) {
@@ -883,6 +884,13 @@ module.exports = (() => {
883
884
  }, { });
884
885
  }
885
886
 
887
+ /**
888
+ * Adds a new portfolio to the container, injecting it into aggregation
889
+ * trees, as necessary.
890
+ *
891
+ * @public
892
+ * @param {Object} portfolio
893
+ */
886
894
  addPortfolio(portfolio) {
887
895
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
888
896
  assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
@@ -925,7 +933,7 @@ module.exports = (() => {
925
933
  if (group.definition === parentLevelDefinition) {
926
934
  parentTrees.push(groupTree);
927
935
  }
928
- });
936
+ }, false, false);
929
937
  }
930
938
 
931
939
  const overrideRequiredGroups = [ portfolioRequiredGroup ];
@@ -938,8 +946,33 @@ module.exports = (() => {
938
946
  }
939
947
  }
940
948
 
949
+ /**
950
+ * Removes an existing portfolio, and all of it's positions, from the container. This
951
+ * also triggers removal of the portfolio and it's positions from any applicable
952
+ * aggregation trees.
953
+ *
954
+ * @public
955
+ * @param {Object} portfolio
956
+ */
941
957
  removePortfolio(portfolio) {
958
+ assert.argumentIsRequired(portfolio, 'portfolio', Object);
959
+ assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
960
+
961
+ this.startTransaction(() => {
962
+ getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(item => removePositionItem.call(this, item));
963
+
964
+ delete this._portfolios[portfolio.portfolio];
942
965
 
966
+ Object.keys(this._trees).forEach((key) => {
967
+ const tree = this._tree[key];
968
+
969
+ tree.walk((group, groupNode) => {
970
+ if (group.definition.type === PositionLevelType.PORTFOLIO && group.key === PositionLevelDefinition.getKeyForPortfolioGroup(portfolio)) {
971
+ groupNode.sever();
972
+ }
973
+ }, true, false);
974
+ });
975
+ });
943
976
  }
944
977
 
945
978
  mutatePosition(position, summary) {
@@ -947,7 +980,7 @@ module.exports = (() => {
947
980
  }
948
981
 
949
982
  removePosition(position) {
950
-
983
+ removePositionItem.call(this, this._items.find((item) => item.position.position === position));
951
984
  }
952
985
 
953
986
  /**
@@ -1030,7 +1063,6 @@ module.exports = (() => {
1030
1063
  assert.argumentIsRequired(quote, 'quote', Object);
1031
1064
 
1032
1065
  const rate = Rate.fromPair(quote.lastPrice, symbol);
1033
-
1034
1066
  const index = this._forexQuotes.findIndex(existing => existing.formatPair() === rate.formatPair());
1035
1067
 
1036
1068
  if (index < 0) {
@@ -1125,13 +1157,13 @@ module.exports = (() => {
1125
1157
  }
1126
1158
 
1127
1159
  /**
1128
- * Returns all portfolios in the container
1160
+ * Returns all portfolios in the container.
1129
1161
  *
1130
1162
  * @public
1131
1163
  * @return {Array.<Object>}
1132
1164
  */
1133
1165
  getPortfolios() {
1134
- return this._portfolios;
1166
+ return Object.keys(this._portfolios).map(id => this._portfolios[id]);
1135
1167
  }
1136
1168
 
1137
1169
  /**
@@ -1142,24 +1174,42 @@ module.exports = (() => {
1142
1174
  * @return {Array.<Object>}
1143
1175
  */
1144
1176
  getPositions(portfolio) {
1145
- return this._items.reduce((positions, item) => {
1146
- if (item.position.portfolio === portfolio) {
1147
- positions.push(item);
1148
- }
1177
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
1149
1178
 
1150
- return positions;
1151
- }, []);
1179
+ return getPositionItemsForPortfolio(this._items, portfolio).map(item => item.position);
1152
1180
  }
1153
1181
 
1154
- startTransaction(name, executor) {
1155
- assert.argumentIsRequired(name, 'name', String);
1182
+ /**
1183
+ * Pauses aggregation calculations during the processing of an action.
1184
+ *
1185
+ * @public
1186
+ * @param {Function} executor
1187
+ * @param {String=|Array.<String>=} names
1188
+ */
1189
+ startTransaction(executor, names) {
1190
+ let namesToUse;
1191
+
1192
+ if (is.array(names)) {
1193
+ assert.argumentIsArray(names, 'names', String);
1194
+
1195
+ namesToUse = names;
1196
+ } else {
1197
+ assert.argumentIsOptional(names, 'names', String);
1198
+
1199
+ if (names) {
1200
+ namesToUse = [ names ];
1201
+ } else {
1202
+ namesToUse = Object.keys(this._trees);
1203
+ }
1204
+ }
1205
+
1156
1206
  assert.argumentIsRequired(executor, 'executor', Function);
1157
1207
 
1158
- this._trees[name].walk(group => group.setSuspended(true), false, false);
1208
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(true), false, false));
1159
1209
 
1160
1210
  executor(this);
1161
1211
 
1162
- this._trees[name].walk(group => group.setSuspended(false), false, false);
1212
+ namesToUse.forEach((name) => this._trees[name].walk(group => group.setSuspended(false), false, false));
1163
1213
  }
1164
1214
 
1165
1215
  toString() {
@@ -1191,6 +1241,14 @@ module.exports = (() => {
1191
1241
  }
1192
1242
  }
1193
1243
 
1244
+ function extractCurrency(position) {
1245
+ if (position.instrument && position.instrument.currency) {
1246
+ return position.instrument.currency;
1247
+ } else {
1248
+ return null;
1249
+ }
1250
+ }
1251
+
1194
1252
  function addGroupBinding(group, dispoable) {
1195
1253
  const id = group.id;
1196
1254
 
@@ -1320,14 +1378,56 @@ module.exports = (() => {
1320
1378
  });
1321
1379
  }
1322
1380
 
1381
+ function getPositionItemsForPortfolio(items, portfolio) {
1382
+ return items.reduce((positionItems, item) => {
1383
+ if (item.position.portfolio === portfolio) {
1384
+ positionItems.push(item.position);
1385
+ }
1386
+
1387
+ return positionItems;
1388
+ }, [ ]);
1389
+ }
1390
+
1391
+ function removePositionItem(positionItem) {
1392
+ if (!positionItem) {
1393
+ return;
1394
+ }
1395
+
1396
+ delete this._summariesCurrent[positionItem.position.position];
1397
+ delete this._summariesPrevious[positionItem.position.position];
1398
+
1399
+ array.remove(this._items, i => i === positionItem);
1400
+
1401
+ const barchartSymbol = extractSymbolForBarchart(positionItem.position);
1402
+
1403
+ if (this._symbols.hasOwnProperty(barchartSymbol)) {
1404
+ array.remove(this._symbols[barchartSymbol], i => i === positionItem);
1405
+ }
1406
+
1407
+ const displaySymbol = extractSymbolForDisplay(positionItem.position);
1408
+
1409
+ if (this._symbolsDisplay.hasOwnProperty(displaySymbol)) {
1410
+ array.remove(this._symbols[displaySymbol], i => i === positionItem);
1411
+ }
1412
+
1413
+ const currency = extractCurrency(positionItem.position);
1414
+
1415
+ if (currency && this._currencies.hasOwnProperty(currency.code)) {
1416
+ array.remove(this._currencies[currency.code], i => i === positionItem);
1417
+ }
1418
+
1419
+ positionItem.dispose();
1420
+ }
1421
+
1323
1422
  return PositionContainer;
1324
1423
  })();
1325
1424
 
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){
1425
+ },{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionLevelDefinition":7,"./definitions/PositionLevelType":8,"./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
1426
  const array = require('@barchart/common-js/lang/array'),
1328
1427
  assert = require('@barchart/common-js/lang/assert'),
1329
1428
  Currency = require('@barchart/common-js/lang/Currency'),
1330
1429
  Decimal = require('@barchart/common-js/lang/Decimal'),
1430
+ Disposable = require('@barchart/common-js/lang/Disposable'),
1331
1431
  DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
1332
1432
  Event = require('@barchart/common-js/messaging/Event'),
1333
1433
  formatter = require('@barchart/common-js/lang/formatter'),
@@ -1475,7 +1575,7 @@ module.exports = (() => {
1475
1575
  this._dataFormat.portfolioType = null;
1476
1576
 
1477
1577
  this._items.forEach((item) => {
1478
- this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
1578
+ const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
1479
1579
  if (this._single) {
1480
1580
  const precision = sender.position.instrument.currency.precision;
1481
1581
 
@@ -1511,18 +1611,39 @@ module.exports = (() => {
1511
1611
  }
1512
1612
 
1513
1613
  calculatePriceData(this, this._container.getForexQuotes(), sender, false);
1514
- }));
1614
+ });
1615
+
1616
+ let newsBinding = Disposable.getEmpty();
1617
+ let fundamentalBinding = Disposable.getEmpty();
1515
1618
 
1516
1619
  if (this._single) {
1517
- this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
1620
+ newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
1518
1621
  this._dataActual.newsExists = exists;
1519
1622
  this._dataFormat.newsExists = exists;
1520
- }));
1623
+ });
1521
1624
 
1522
- this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
1625
+ fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
1523
1626
  this._dataFormat.fundamental = data;
1524
- }));
1627
+ });
1525
1628
  }
1629
+
1630
+ this._disposeStack.push(quoteBinding);
1631
+ this._disposeStack.push(newsBinding);
1632
+ this._disposeStack.push(fundamentalBinding);
1633
+
1634
+ this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
1635
+ quoteBinding.dispose();
1636
+ newsBinding.dispose();
1637
+ fundamentalBinding.dispose();
1638
+
1639
+ array.remove(this._items, i => i === item);
1640
+ array.remove(this._excludedItems, i => i === item);
1641
+ array.remove(this._consideredItems, i => i === item);
1642
+
1643
+ delete this._excludedItemMap[item.position.position];
1644
+
1645
+ this.refresh();
1646
+ }));
1526
1647
  });
1527
1648
 
1528
1649
  this.refresh();
@@ -1699,22 +1820,35 @@ module.exports = (() => {
1699
1820
  }
1700
1821
  }
1701
1822
 
1823
+ /**
1824
+ * Stops (or starts) group-level aggregation calculations.
1825
+ *
1826
+ * @public
1827
+ * @param {Boolean} value
1828
+ */
1702
1829
  setSuspended(value) {
1703
1830
  assert.argumentIsRequired(value, 'value', Boolean);
1704
1831
 
1705
1832
  if (this._suspended !== value) {
1706
- if (this._suspended = value) {
1833
+ this._suspended = value;
1834
+
1835
+ if (!this._suspended) {
1707
1836
  this.refresh();
1708
1837
  }
1709
1838
  }
1710
1839
  }
1711
1840
 
1712
1841
  /**
1713
- * Causes all aggregated data to be recalculated.
1842
+ * Causes all aggregated data to be recalculated (assuming the group has not
1843
+ * been suspended).
1714
1844
  *
1715
1845
  * @public
1716
1846
  */
1717
1847
  refresh() {
1848
+ if (this._suspended) {
1849
+ return;
1850
+ }
1851
+
1718
1852
  const rates = this._container.getForexQuotes();
1719
1853
 
1720
1854
  calculateStaticData(this, rates);
@@ -2029,11 +2163,12 @@ module.exports = (() => {
2029
2163
  return PositionGroup;
2030
2164
  })();
2031
2165
 
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){
2166
+ },{"./../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/Disposable":18,"@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
2167
  const array = require('@barchart/common-js/lang/array'),
2034
2168
  assert = require('@barchart/common-js/lang/assert'),
2035
2169
  Currency = require('@barchart/common-js/lang/Currency'),
2036
2170
  Decimal = require('@barchart/common-js/lang/Decimal'),
2171
+ Disposable = require('@barchart/common-js/lang/Disposable'),
2037
2172
  Event = require('@barchart/common-js/messaging/Event'),
2038
2173
  is = require('@barchart/common-js/lang/is');
2039
2174
 
@@ -2053,8 +2188,10 @@ module.exports = (() => {
2053
2188
  * @param {Object} currentSummary
2054
2189
  * @param {Array.<Object>} previousSummaries
2055
2190
  */
2056
- class PositionItem {
2191
+ class PositionItem extends Disposable {
2057
2192
  constructor(portfolio, position, currentSummary, previousSummaries) {
2193
+ super();
2194
+
2058
2195
  this._portfolio = portfolio;
2059
2196
  this._position = position;
2060
2197
  this._currency = position.instrument.currency || Currency.CAD;
@@ -2099,6 +2236,7 @@ module.exports = (() => {
2099
2236
  this._quoteChangedEvent = new Event(this);
2100
2237
  this._newsExistsChangedEvent = new Event(this);
2101
2238
  this._fundamentalDataChangeEvent = new Event(this);
2239
+ this._positionItemDisposeEvent = new Event(this);
2102
2240
  }
2103
2241
 
2104
2242
  /**
@@ -2181,6 +2319,10 @@ module.exports = (() => {
2181
2319
  setQuote(quote) {
2182
2320
  assert.argumentIsRequired(quote, 'quote', Object);
2183
2321
 
2322
+ if (this.getIsDisposed()) {
2323
+ return;
2324
+ }
2325
+
2184
2326
  if (this._currentPricePrevious !== quote.lastPrice) {
2185
2327
  calculatePriceData(this, quote.lastPrice);
2186
2328
 
@@ -2202,6 +2344,10 @@ module.exports = (() => {
2202
2344
  setPositionFundamentalData(data) {
2203
2345
  assert.argumentIsRequired(data, 'data', Object);
2204
2346
 
2347
+ if (this.getIsDisposed()) {
2348
+ return;
2349
+ }
2350
+
2205
2351
  this._fundamentalDataChangeEvent.fire(this._data.fundamental = data);
2206
2352
  }
2207
2353
 
@@ -2215,6 +2361,10 @@ module.exports = (() => {
2215
2361
  setNewsArticleExists(value) {
2216
2362
  assert.argumentIsRequired(value, 'value', Boolean);
2217
2363
 
2364
+ if (this.getIsDisposed()) {
2365
+ return;
2366
+ }
2367
+
2218
2368
  if (this._data.newsExists !== value) {
2219
2369
  this._newsExistsChangedEvent.fire(this._data.newsExists = value);
2220
2370
  }
@@ -2254,6 +2404,26 @@ module.exports = (() => {
2254
2404
  return this._newsExistsChangedEvent.register(handler);
2255
2405
  }
2256
2406
 
2407
+ /**
2408
+ * Registers an observer for object disposal.
2409
+ *
2410
+ * @public
2411
+ * @param {Function} handler
2412
+ * @returns {Disposable}
2413
+ */
2414
+ registerPositionItemDisposeHandler(handler) {
2415
+ return this._positionItemDisposeEvent.register(handler);
2416
+ }
2417
+
2418
+ _onDispose() {
2419
+ this._positionItemDisposeEvent.fire(this);
2420
+
2421
+ this._quoteChangedEvent.clear();
2422
+ this._newsExistsChangedEvent.clear();
2423
+ this._fundamentalDataChangeEvent.clear();
2424
+ this._positionItemDisposeEvent.clear();
2425
+ }
2426
+
2257
2427
  toString() {
2258
2428
  return '[PositionItem]';
2259
2429
  }
@@ -2397,13 +2567,15 @@ module.exports = (() => {
2397
2567
  return PositionItem;
2398
2568
  })();
2399
2569
 
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){
2570
+ },{"./../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
2571
  const assert = require('@barchart/common-js/lang/assert'),
2402
2572
  Currency = require('@barchart/common-js/lang/Currency'),
2403
2573
  is = require('@barchart/common-js/lang/is');
2404
2574
 
2405
2575
  const InstrumentType = require('./../../data/InstrumentType');
2406
2576
 
2577
+ const PositionLevelType = require('./PositionLevelType');
2578
+
2407
2579
  module.exports = (() => {
2408
2580
  'use strict';
2409
2581
 
@@ -2420,11 +2592,12 @@ module.exports = (() => {
2420
2592
  * @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
2421
2593
  * @param {Boolean=} single
2422
2594
  * @param {Boolean=} aggregateCash
2423
- * @param {Function=} injectPositions
2595
+ * @param {Function=} requiredGroupGenerator
2424
2596
  */
2425
2597
  class PositionLevelDefinition {
2426
- constructor(name, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
2598
+ constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, single, aggregateCash, requiredGroupGenerator) {
2427
2599
  assert.argumentIsRequired(name, 'name', String);
2600
+ assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
2428
2601
  assert.argumentIsRequired(keySelector, 'keySelector', Function);
2429
2602
  assert.argumentIsRequired(descriptionSelector, 'descriptionSelector', Function);
2430
2603
  assert.argumentIsRequired(currencySelector, 'currencySelector', Function);
@@ -2438,6 +2611,7 @@ module.exports = (() => {
2438
2611
  assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
2439
2612
 
2440
2613
  this._name = name;
2614
+ this._type = type;
2441
2615
 
2442
2616
  this._keySelector = keySelector;
2443
2617
  this._descriptionSelector = descriptionSelector;
@@ -2461,6 +2635,16 @@ module.exports = (() => {
2461
2635
  return this._name;
2462
2636
  }
2463
2637
 
2638
+ /**
2639
+ * A general description of the type of items grouped together.
2640
+ *
2641
+ * @public
2642
+ * @return {PositionLevelType}
2643
+ */
2644
+ get type() {
2645
+ return this._type;
2646
+ }
2647
+
2464
2648
  /**
2465
2649
  * A function, when given a {@link PositionItem} returns a string that is used
2466
2650
  * to group {@link PositionItem} instances into different groups.
@@ -2664,7 +2848,38 @@ module.exports = (() => {
2664
2848
  return PositionLevelDefinition;
2665
2849
  })();
2666
2850
 
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){
2851
+ },{"./../../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){
2852
+ const Enum = require('@barchart/common-js/lang/Enum');
2853
+
2854
+ module.exports = (() => {
2855
+ 'use strict';
2856
+
2857
+ class PositionLevelType extends Enum {
2858
+ constructor(code) {
2859
+ super(code, code);
2860
+ }
2861
+
2862
+ static get PORTFOLIO() {
2863
+ return portfolio;
2864
+ }
2865
+
2866
+ static get POSITION() {
2867
+ return position;
2868
+ }
2869
+
2870
+ static get OTHER() {
2871
+ return other;
2872
+ }
2873
+ }
2874
+
2875
+ const portfolio = new PositionLevelType('PORTFOLIO');
2876
+ const position = new PositionLevelType('POSITION');
2877
+ const other = new PositionLevelType('OTHER');
2878
+
2879
+ return PositionLevelType;
2880
+ })();
2881
+
2882
+ },{"@barchart/common-js/lang/Enum":19}],9:[function(require,module,exports){
2668
2883
  const assert = require('@barchart/common-js/lang/assert');
2669
2884
 
2670
2885
  const PositionLevelDefinition = require('./PositionLevelDefinition');
@@ -2735,7 +2950,7 @@ module.exports = (() => {
2735
2950
  return PositionTreeDefinitions;
2736
2951
  })();
2737
2952
 
2738
- },{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":21}],9:[function(require,module,exports){
2953
+ },{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":22}],10:[function(require,module,exports){
2739
2954
  'use strict';
2740
2955
 
2741
2956
  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 +3082,7 @@ module.exports = function () {
2867
3082
  return Stack;
2868
3083
  }();
2869
3084
 
2870
- },{"./../lang/assert":21}],10:[function(require,module,exports){
3085
+ },{"./../lang/assert":22}],11:[function(require,module,exports){
2871
3086
  'use strict';
2872
3087
 
2873
3088
  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; }; }();
@@ -3008,6 +3223,23 @@ module.exports = function () {
3008
3223
  }
3009
3224
  }
3010
3225
 
3226
+ /**
3227
+ * Removes the current node from the parent tree. Use on a root node
3228
+ * has no effect.
3229
+ *
3230
+ * @public
3231
+ */
3232
+
3233
+ }, {
3234
+ key: 'sever',
3235
+ value: function sever() {
3236
+ if (this.getIsRoot()) {
3237
+ return;
3238
+ }
3239
+
3240
+ this.getParent().removeChild(this);
3241
+ }
3242
+
3011
3243
  /**
3012
3244
  * Searches the children nodes for the first child node that matches the
3013
3245
  * predicate.
@@ -3176,7 +3408,7 @@ module.exports = function () {
3176
3408
  return Tree;
3177
3409
  }();
3178
3410
 
3179
- },{"./../lang/is":23}],11:[function(require,module,exports){
3411
+ },{"./../lang/is":24}],12:[function(require,module,exports){
3180
3412
  'use strict';
3181
3413
 
3182
3414
  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 +3552,7 @@ module.exports = function () {
3320
3552
  return ComparatorBuilder;
3321
3553
  }();
3322
3554
 
3323
- },{"./../../lang/assert":21,"./comparators":12}],12:[function(require,module,exports){
3555
+ },{"./../../lang/assert":22,"./comparators":13}],13:[function(require,module,exports){
3324
3556
  'use strict';
3325
3557
 
3326
3558
  var assert = require('./../../lang/assert');
@@ -3395,7 +3627,7 @@ module.exports = function () {
3395
3627
  };
3396
3628
  }();
3397
3629
 
3398
- },{"./../../lang/assert":21}],13:[function(require,module,exports){
3630
+ },{"./../../lang/assert":22}],14:[function(require,module,exports){
3399
3631
  'use strict';
3400
3632
 
3401
3633
  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 +3735,7 @@ module.exports = function () {
3503
3735
  return DisposableStack;
3504
3736
  }();
3505
3737
 
3506
- },{"./../../lang/Disposable":17,"./../../lang/assert":21,"./../../lang/is":23,"./../Stack":9}],14:[function(require,module,exports){
3738
+ },{"./../../lang/Disposable":18,"./../../lang/assert":22,"./../../lang/is":24,"./../Stack":10}],15:[function(require,module,exports){
3507
3739
  'use strict';
3508
3740
 
3509
3741
  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; }; }();
@@ -3534,7 +3766,7 @@ module.exports = function () {
3534
3766
  var Currency = function (_Enum) {
3535
3767
  _inherits(Currency, _Enum);
3536
3768
 
3537
- function Currency(code, description, precision) {
3769
+ function Currency(code, description, precision, alternateDescription) {
3538
3770
  _classCallCheck(this, Currency);
3539
3771
 
3540
3772
  var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
@@ -3542,7 +3774,11 @@ module.exports = function () {
3542
3774
  assert.argumentIsRequired(precision, 'precision', Number);
3543
3775
  assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
3544
3776
 
3777
+ assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
3778
+
3545
3779
  _this._precision = precision;
3780
+
3781
+ _this._alternateDescription = alternateDescription || description;
3546
3782
  return _this;
3547
3783
  }
3548
3784
 
@@ -3565,6 +3801,19 @@ module.exports = function () {
3565
3801
  return this._precision;
3566
3802
  }
3567
3803
 
3804
+ /**
3805
+ * An alternate human-readable description.
3806
+ *
3807
+ * @public
3808
+ * @returns {String}
3809
+ */
3810
+
3811
+ }, {
3812
+ key: 'alternateDescription',
3813
+ get: function get() {
3814
+ return this._alternateDescription;
3815
+ }
3816
+
3568
3817
  /**
3569
3818
  * Given a code, returns the enumeration item.
3570
3819
  *
@@ -3622,14 +3871,14 @@ module.exports = function () {
3622
3871
  return Currency;
3623
3872
  }(Enum);
3624
3873
 
3625
- var cad = new Currency('CAD', 'Canadian Dollar', 2);
3626
- var eur = new Currency('EUR', 'Euro', 2);
3627
- var usd = new Currency('USD', 'US Dollar', 2);
3874
+ var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
3875
+ var eur = new Currency('EUR', 'Euro', 2, 'EUR');
3876
+ var usd = new Currency('USD', 'US Dollar', 2, 'US$');
3628
3877
 
3629
3878
  return Currency;
3630
3879
  }();
3631
3880
 
3632
- },{"./Enum":18,"./assert":21,"./is":23}],15:[function(require,module,exports){
3881
+ },{"./Enum":19,"./assert":22,"./is":24}],16:[function(require,module,exports){
3633
3882
  'use strict';
3634
3883
 
3635
3884
  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; }; }();
@@ -4182,7 +4431,7 @@ module.exports = function () {
4182
4431
  return Day;
4183
4432
  }();
4184
4433
 
4185
- },{"./../collections/sorting/ComparatorBuilder":11,"./../collections/sorting/comparators":12,"./assert":21,"./is":23}],16:[function(require,module,exports){
4434
+ },{"./../collections/sorting/ComparatorBuilder":12,"./../collections/sorting/comparators":13,"./assert":22,"./is":24}],17:[function(require,module,exports){
4186
4435
  'use strict';
4187
4436
 
4188
4437
  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; }; }();
@@ -4385,6 +4634,20 @@ module.exports = function () {
4385
4634
  return this._big.gt(getBig(other));
4386
4635
  }
4387
4636
 
4637
+ /**
4638
+ * Returns true if the current instance is greater than or equal to the value.
4639
+ *
4640
+ * @public
4641
+ * @param {Decimal|Number|String} other - The value to compare.
4642
+ * @returns {Boolean}
4643
+ */
4644
+
4645
+ }, {
4646
+ key: 'getIsGreaterThanOrEqual',
4647
+ value: function getIsGreaterThanOrEqual(other) {
4648
+ return this._big.gte(getBig(other));
4649
+ }
4650
+
4388
4651
  /**
4389
4652
  * Returns true if the current instance is less than the value.
4390
4653
  *
@@ -4399,6 +4662,20 @@ module.exports = function () {
4399
4662
  return this._big.lt(getBig(other));
4400
4663
  }
4401
4664
 
4665
+ /**
4666
+ * Returns true if the current instance is less than or equal to the value.
4667
+ *
4668
+ * @public
4669
+ * @param {Decimal|Number|String} other - The value to compare.
4670
+ * @returns {Boolean}
4671
+ */
4672
+
4673
+ }, {
4674
+ key: 'getIsLessThanOrEqual',
4675
+ value: function getIsLessThanOrEqual(other) {
4676
+ return this._big.lte(getBig(other));
4677
+ }
4678
+
4402
4679
  /**
4403
4680
  * Returns true if the current instance is equal to the value.
4404
4681
  *
@@ -4598,9 +4875,9 @@ module.exports = function () {
4598
4875
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
4599
4876
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
4600
4877
 
4601
- if (a._big.gt(b)) {
4878
+ if (a._big.gt(b._big)) {
4602
4879
  return 1;
4603
- } else if (a._big.lt(b)) {
4880
+ } else if (a._big.lt(b._big)) {
4604
4881
  return -1;
4605
4882
  } else {
4606
4883
  return 0;
@@ -4762,7 +5039,7 @@ module.exports = function () {
4762
5039
  return Decimal;
4763
5040
  }();
4764
5041
 
4765
- },{"./Enum":18,"./assert":21,"./is":23,"big.js":26}],17:[function(require,module,exports){
5042
+ },{"./Enum":19,"./assert":22,"./is":24,"big.js":27}],18:[function(require,module,exports){
4766
5043
  'use strict';
4767
5044
 
4768
5045
  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; }; }();
@@ -4911,7 +5188,7 @@ module.exports = function () {
4911
5188
  return Disposable;
4912
5189
  }();
4913
5190
 
4914
- },{"./assert":21}],18:[function(require,module,exports){
5191
+ },{"./assert":22}],19:[function(require,module,exports){
4915
5192
  'use strict';
4916
5193
 
4917
5194
  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; }; }();
@@ -5053,7 +5330,7 @@ module.exports = function () {
5053
5330
  return Enum;
5054
5331
  }();
5055
5332
 
5056
- },{"./assert":21}],19:[function(require,module,exports){
5333
+ },{"./assert":22}],20:[function(require,module,exports){
5057
5334
  'use strict';
5058
5335
 
5059
5336
  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; }; }();
@@ -5061,12 +5338,10 @@ var _createClass = function () { function defineProperties(target, props) { for
5061
5338
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5062
5339
 
5063
5340
  var assert = require('./assert'),
5064
- is = require('./is'),
5065
5341
  memoize = require('./memoize');
5066
5342
 
5067
5343
  var Currency = require('./Currency'),
5068
- Decimal = require('./Decimal'),
5069
- Enum = require('./Enum');
5344
+ Decimal = require('./Decimal');
5070
5345
 
5071
5346
  module.exports = function () {
5072
5347
  'use strict';
@@ -5246,12 +5521,7 @@ module.exports = function () {
5246
5521
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
5247
5522
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
5248
5523
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
5249
-
5250
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5251
- rates[_key - 3] = arguments[_key];
5252
- }
5253
-
5254
- assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5524
+ //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5255
5525
 
5256
5526
  var converted = void 0;
5257
5527
 
@@ -5261,6 +5531,10 @@ module.exports = function () {
5261
5531
  var numerator = desiredCurrency;
5262
5532
  var denominator = currency;
5263
5533
 
5534
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5535
+ rates[_key - 3] = arguments[_key];
5536
+ }
5537
+
5264
5538
  var rate = rates.find(function (r) {
5265
5539
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
5266
5540
  });
@@ -5311,7 +5585,7 @@ module.exports = function () {
5311
5585
  return Rate;
5312
5586
  }();
5313
5587
 
5314
- },{"./Currency":14,"./Decimal":16,"./Enum":18,"./assert":21,"./is":23,"./memoize":24}],20:[function(require,module,exports){
5588
+ },{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
5315
5589
  'use strict';
5316
5590
 
5317
5591
  var assert = require('./assert'),
@@ -5688,11 +5962,31 @@ module.exports = function () {
5688
5962
  });
5689
5963
 
5690
5964
  return returnRef;
5965
+ },
5966
+
5967
+
5968
+ /**
5969
+ * Removes the first item from an array which matches a predicate.
5970
+ *
5971
+ * @static
5972
+ * @public
5973
+ * @param {Array} a
5974
+ * @param {Function} predicate
5975
+ */
5976
+ remove: function remove(a, predicate) {
5977
+ assert.argumentIsArray(a, 'a');
5978
+ assert.argumentIsRequired(predicate, 'predicate', Function);
5979
+
5980
+ var index = a.findIndex(predicate);
5981
+
5982
+ if (!(index < 0)) {
5983
+ a.splice(index, 1);
5984
+ }
5691
5985
  }
5692
5986
  };
5693
5987
  }();
5694
5988
 
5695
- },{"./assert":21,"./is":23}],21:[function(require,module,exports){
5989
+ },{"./assert":22,"./is":24}],22:[function(require,module,exports){
5696
5990
  'use strict';
5697
5991
 
5698
5992
  var is = require('./is');
@@ -5840,7 +6134,7 @@ module.exports = function () {
5840
6134
  };
5841
6135
  }();
5842
6136
 
5843
- },{"./is":23}],22:[function(require,module,exports){
6137
+ },{"./is":24}],23:[function(require,module,exports){
5844
6138
  'use strict';
5845
6139
 
5846
6140
  module.exports = function () {
@@ -5905,7 +6199,7 @@ module.exports = function () {
5905
6199
  };
5906
6200
  }();
5907
6201
 
5908
- },{}],23:[function(require,module,exports){
6202
+ },{}],24:[function(require,module,exports){
5909
6203
  'use strict';
5910
6204
 
5911
6205
  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; };
@@ -6128,7 +6422,7 @@ module.exports = function () {
6128
6422
  };
6129
6423
  }();
6130
6424
 
6131
- },{}],24:[function(require,module,exports){
6425
+ },{}],25:[function(require,module,exports){
6132
6426
  'use strict';
6133
6427
 
6134
6428
  var assert = require('./assert'),
@@ -6201,7 +6495,7 @@ module.exports = function () {
6201
6495
  };
6202
6496
  }();
6203
6497
 
6204
- },{"./assert":21,"./is":23}],25:[function(require,module,exports){
6498
+ },{"./assert":22,"./is":24}],26:[function(require,module,exports){
6205
6499
  'use strict';
6206
6500
 
6207
6501
  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; }; }();
@@ -6373,7 +6667,7 @@ module.exports = function () {
6373
6667
  return Event;
6374
6668
  }();
6375
6669
 
6376
- },{"./../lang/Disposable":17,"./../lang/assert":21}],26:[function(require,module,exports){
6670
+ },{"./../lang/Disposable":18,"./../lang/assert":22}],27:[function(require,module,exports){
6377
6671
  /*
6378
6672
  * big.js v5.0.3
6379
6673
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -7314,7 +7608,7 @@ module.exports = function () {
7314
7608
  }
7315
7609
  })(this);
7316
7610
 
7317
- },{}],27:[function(require,module,exports){
7611
+ },{}],28:[function(require,module,exports){
7318
7612
  const Day = require('@barchart/common-js/lang/Day'),
7319
7613
  Decimal = require('@barchart/common-js/lang/Decimal');
7320
7614
 
@@ -7671,7 +7965,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
7671
7965
  });
7672
7966
  });
7673
7967
 
7674
- },{"./../../../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){
7968
+ },{"./../../../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){
7675
7969
  const Currency = require('@barchart/common-js/lang/Currency'),
7676
7970
  Decimal = require('@barchart/common-js/lang/Decimal');
7677
7971
 
@@ -7679,6 +7973,7 @@ const InstrumentType = require('./../../../lib/data/InstrumentType');
7679
7973
 
7680
7974
  const PositionContainer = require('./../../../lib/processing/PositionContainer'),
7681
7975
  PositionLevelDefinition = require('./../../../lib/processing/definitions/PositionLevelDefinition'),
7976
+ PositionLevelType = require('./../../../lib/processing/definitions/PositionLevelType'),
7682
7977
  PositionTreeDefinition = require('./../../../lib/processing/definitions/PositionTreeDefinition');
7683
7978
 
7684
7979
  describe('When a position container data is gathered', () => {
@@ -7740,9 +8035,9 @@ describe('When a position container data is gathered', () => {
7740
8035
  beforeEach(() => {
7741
8036
  definitions = [
7742
8037
  new PositionTreeDefinition(name = 'the only tree', [
7743
- new PositionLevelDefinition('Total', x => 'totals', x => 'Total', x => Currency.CAD),
7744
- new PositionLevelDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
7745
- new PositionLevelDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
8038
+ new PositionLevelDefinition('Total', PositionLevelType.OTHER, x => 'totals', x => 'Total', x => Currency.CAD),
8039
+ new PositionLevelDefinition('Portfolio', PositionLevelType.PORTFOLIO, x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
8040
+ new PositionLevelDefinition('Position', PositionLevelType.POSITION, x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
7746
8041
  ])
7747
8042
  ];
7748
8043
 
@@ -7780,4 +8075,4 @@ describe('When a position container data is gathered', () => {
7780
8075
  });
7781
8076
  });
7782
8077
 
7783
- },{"./../../../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]);
8078
+ },{"./../../../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]);