@barchart/portfolio-api-common 1.0.167 → 1.0.171

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.
@@ -11,7 +11,9 @@ const array = require('@barchart/common-js/lang/array'),
11
11
 
12
12
  const PositionSummaryFrame = require('./../data/PositionSummaryFrame');
13
13
 
14
- const PositionTreeDefinition = require('./definitions/PositionTreeDefinition');
14
+ const PositionLevelDefinition = require('./definitions/PositionLevelDefinition'),
15
+ PositionLevelType = require('./definitions/PositionLevelType'),
16
+ PositionTreeDefinition = require('./definitions/PositionTreeDefinition');
15
17
 
16
18
  const PositionGroup = require('./PositionGroup'),
17
19
  PositionItem = require('./PositionItem');
@@ -128,10 +130,9 @@ module.exports = (() => {
128
130
  }, { });
129
131
 
130
132
  this._currencies = this._items.reduce((map, item) => {
131
- const position = item.position;
133
+ const currency = extractCurrency(item.position);
132
134
 
133
- if (position.instrument && position.instrument.currency) {
134
- const currency = position.instrument.currency;
135
+ if (currency) {
135
136
  const code = currency.code;
136
137
 
137
138
  if (!map.hasOwnProperty(code)) {
@@ -242,11 +243,17 @@ module.exports = (() => {
242
243
  assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
243
244
 
244
245
  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));
246
+ getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(item => removePositionItem.call(this, item));
248
247
 
248
+ delete this._portfolios[portfolio.portfolio];
249
249
 
250
+ Object.keys(this._trees).forEach((key) => {
251
+ this._trees[key].walk((group, groupNode) => {
252
+ if (group.definition.type === PositionLevelType.PORTFOLIO && group.key === PositionLevelDefinition.getKeyForPortfolioGroup(portfolio)) {
253
+ groupNode.sever();
254
+ }
255
+ }, true, false);
256
+ });
250
257
  });
251
258
  }
252
259
 
@@ -338,7 +345,6 @@ module.exports = (() => {
338
345
  assert.argumentIsRequired(quote, 'quote', Object);
339
346
 
340
347
  const rate = Rate.fromPair(quote.lastPrice, symbol);
341
-
342
348
  const index = this._forexQuotes.findIndex(existing => existing.formatPair() === rate.formatPair());
343
349
 
344
350
  if (index < 0) {
@@ -517,6 +523,14 @@ module.exports = (() => {
517
523
  }
518
524
  }
519
525
 
526
+ function extractCurrency(position) {
527
+ if (position.instrument && position.instrument.currency) {
528
+ return position.instrument.currency;
529
+ } else {
530
+ return null;
531
+ }
532
+ }
533
+
520
534
  function addGroupBinding(group, dispoable) {
521
535
  const id = group.id;
522
536
 
@@ -661,6 +675,29 @@ module.exports = (() => {
661
675
  return;
662
676
  }
663
677
 
678
+ delete this._summariesCurrent[positionItem.position.position];
679
+ delete this._summariesPrevious[positionItem.position.position];
680
+
681
+ array.remove(this._items, i => i === positionItem);
682
+
683
+ const barchartSymbol = extractSymbolForBarchart(positionItem.position);
684
+
685
+ if (this._symbols.hasOwnProperty(barchartSymbol)) {
686
+ array.remove(this._symbols[barchartSymbol], i => i === positionItem);
687
+ }
688
+
689
+ const displaySymbol = extractSymbolForDisplay(positionItem.position);
690
+
691
+ if (this._symbolsDisplay.hasOwnProperty(displaySymbol)) {
692
+ array.remove(this._symbols[displaySymbol], i => i === positionItem);
693
+ }
694
+
695
+ const currency = extractCurrency(positionItem.position);
696
+
697
+ if (currency && this._currencies.hasOwnProperty(currency.code)) {
698
+ array.remove(this._currencies[currency.code], i => i === positionItem);
699
+ }
700
+
664
701
  positionItem.dispose();
665
702
  }
666
703
 
@@ -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
  DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
6
7
  Event = require('@barchart/common-js/messaging/Event'),
7
8
  formatter = require('@barchart/common-js/lang/formatter'),
@@ -149,7 +150,7 @@ module.exports = (() => {
149
150
  this._dataFormat.portfolioType = null;
150
151
 
151
152
  this._items.forEach((item) => {
152
- this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
153
+ const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
153
154
  if (this._single) {
154
155
  const precision = sender.position.instrument.currency.precision;
155
156
 
@@ -185,18 +186,39 @@ module.exports = (() => {
185
186
  }
186
187
 
187
188
  calculatePriceData(this, this._container.getForexQuotes(), sender, false);
188
- }));
189
+ });
190
+
191
+ let newsBinding = Disposable.getEmpty();
192
+ let fundamentalBinding = Disposable.getEmpty();
189
193
 
190
194
  if (this._single) {
191
- this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
195
+ newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
192
196
  this._dataActual.newsExists = exists;
193
197
  this._dataFormat.newsExists = exists;
194
- }));
198
+ });
195
199
 
196
- this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
200
+ fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
197
201
  this._dataFormat.fundamental = data;
198
- }));
202
+ });
199
203
  }
204
+
205
+ this._disposeStack.push(quoteBinding);
206
+ this._disposeStack.push(newsBinding);
207
+ this._disposeStack.push(fundamentalBinding);
208
+
209
+ this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
210
+ quoteBinding.dispose();
211
+ newsBinding.dispose();
212
+ fundamentalBinding.dispose();
213
+
214
+ array.remove(this._items, i => i === item);
215
+ array.remove(this._excludedItems, i => i === item);
216
+ array.remove(this._consideredItems, i => i === item);
217
+
218
+ delete this._excludedItemMap[item.position.position];
219
+
220
+ this.refresh();
221
+ }));
200
222
  });
201
223
 
202
224
  this.refresh();
@@ -392,11 +414,16 @@ module.exports = (() => {
392
414
  }
393
415
 
394
416
  /**
395
- * Causes all aggregated data to be recalculated.
417
+ * Causes all aggregated data to be recalculated (assuming the group has not
418
+ * been suspended).
396
419
  *
397
420
  * @public
398
421
  */
399
422
  refresh() {
423
+ if (this._suspended) {
424
+ return;
425
+ }
426
+
400
427
  const rates = this._container.getForexQuotes();
401
428
 
402
429
  calculateStaticData(this, rates);
@@ -600,6 +627,7 @@ module.exports = (() => {
600
627
 
601
628
  updates = items.reduce((updates, item) => {
602
629
  updates.market = updates.market.add(translate(item, item.data.market));
630
+ updates.marketAbsolute = updates.marketAbsolute.add(translate(item, item.data.market));
603
631
  updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
604
632
  updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
605
633
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
@@ -607,6 +635,7 @@ module.exports = (() => {
607
635
  return updates;
608
636
  }, {
609
637
  market: Decimal.ZERO,
638
+ marketAbsolute: Decimal.ZERO,
610
639
  marketDirection: unchanged,
611
640
  unrealized: Decimal.ZERO,
612
641
  unrealizedToday: Decimal.ZERO,
@@ -615,6 +644,7 @@ module.exports = (() => {
615
644
  } else {
616
645
  updates = {
617
646
  market: actual.market.add(translate(item, item.data.marketChange)),
647
+ marketAbsolute: actual.marketAbsolute.add(translate(item, item.data.marketAbsoluteChange)),
618
648
  marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
619
649
  unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
620
650
  unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
@@ -623,6 +653,7 @@ module.exports = (() => {
623
653
  }
624
654
 
625
655
  actual.market = updates.market;
656
+ actual.marketAbsolute = updates.marketAbsolute;
626
657
  actual.unrealized = updates.unrealized;
627
658
  actual.unrealizedToday = updates.unrealizedToday;
628
659
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
@@ -667,16 +698,16 @@ module.exports = (() => {
667
698
  if (parent !== null && !excluded) {
668
699
  const parentData = parent._dataActual;
669
700
 
670
- if (parentData.market !== null && !parentData.market.getIsZero()) {
701
+ if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsZero()) {
671
702
  let numerator;
672
703
 
673
704
  if (group.currency !== parent.currency) {
674
705
  numerator = Rate.convert(actual.market, group.currency, parent.currency, ...rates);
675
706
  } else {
676
- numerator = actual.market;
707
+ numerator = actual.marketAbsolute;
677
708
  }
678
709
 
679
- marketPercent = numerator.divide(parentData.market);
710
+ marketPercent = numerator.divide(parentData.marketAbsolute);
680
711
  } else {
681
712
  marketPercent = null;
682
713
  }
@@ -46,6 +46,9 @@ module.exports = (() => {
46
46
  this._data.market = null;
47
47
  this._data.marketChange = null;
48
48
 
49
+ this._data.marketAbsolute = null;
50
+ this._data.marketAbsoluteChange = null;
51
+
49
52
  this._data.unrealizedToday = null;
50
53
  this._data.unrealizedTodayChange = null;
51
54
 
@@ -329,6 +332,18 @@ module.exports = (() => {
329
332
  data.market = market;
330
333
  data.marketChange = marketChange;
331
334
 
335
+ let marketAbsolute = market.absolute;
336
+ let marketAbsoluteChange;
337
+
338
+ if (data.marketAbsolute === null) {
339
+ marketAbsoluteChange = marketAbsolute;
340
+ } else {
341
+ marketAbsoluteChange = marketAbsolute.subtract(data.marketAbsolute);
342
+ }
343
+
344
+ data.marketAbsolute = market;
345
+ data.marketAbsoluteChange = marketChange;
346
+
332
347
  let unrealizedToday;
333
348
  let unrealizedTodayChange;
334
349
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.167",
3
+ "version": "1.0.171",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -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
 
@@ -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)) {
@@ -958,11 +959,17 @@ module.exports = (() => {
958
959
  assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
959
960
 
960
961
  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));
962
+ getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(item => removePositionItem.call(this, item));
964
963
 
964
+ delete this._portfolios[portfolio.portfolio];
965
965
 
966
+ Object.keys(this._trees).forEach((key) => {
967
+ this._trees[key].walk((group, groupNode) => {
968
+ if (group.definition.type === PositionLevelType.PORTFOLIO && group.key === PositionLevelDefinition.getKeyForPortfolioGroup(portfolio)) {
969
+ groupNode.sever();
970
+ }
971
+ }, true, false);
972
+ });
966
973
  });
967
974
  }
968
975
 
@@ -1054,7 +1061,6 @@ module.exports = (() => {
1054
1061
  assert.argumentIsRequired(quote, 'quote', Object);
1055
1062
 
1056
1063
  const rate = Rate.fromPair(quote.lastPrice, symbol);
1057
-
1058
1064
  const index = this._forexQuotes.findIndex(existing => existing.formatPair() === rate.formatPair());
1059
1065
 
1060
1066
  if (index < 0) {
@@ -1233,6 +1239,14 @@ module.exports = (() => {
1233
1239
  }
1234
1240
  }
1235
1241
 
1242
+ function extractCurrency(position) {
1243
+ if (position.instrument && position.instrument.currency) {
1244
+ return position.instrument.currency;
1245
+ } else {
1246
+ return null;
1247
+ }
1248
+ }
1249
+
1236
1250
  function addGroupBinding(group, dispoable) {
1237
1251
  const id = group.id;
1238
1252
 
@@ -1377,17 +1391,41 @@ module.exports = (() => {
1377
1391
  return;
1378
1392
  }
1379
1393
 
1394
+ delete this._summariesCurrent[positionItem.position.position];
1395
+ delete this._summariesPrevious[positionItem.position.position];
1396
+
1397
+ array.remove(this._items, i => i === positionItem);
1398
+
1399
+ const barchartSymbol = extractSymbolForBarchart(positionItem.position);
1400
+
1401
+ if (this._symbols.hasOwnProperty(barchartSymbol)) {
1402
+ array.remove(this._symbols[barchartSymbol], i => i === positionItem);
1403
+ }
1404
+
1405
+ const displaySymbol = extractSymbolForDisplay(positionItem.position);
1406
+
1407
+ if (this._symbolsDisplay.hasOwnProperty(displaySymbol)) {
1408
+ array.remove(this._symbols[displaySymbol], i => i === positionItem);
1409
+ }
1410
+
1411
+ const currency = extractCurrency(positionItem.position);
1412
+
1413
+ if (currency && this._currencies.hasOwnProperty(currency.code)) {
1414
+ array.remove(this._currencies[currency.code], i => i === positionItem);
1415
+ }
1416
+
1380
1417
  positionItem.dispose();
1381
1418
  }
1382
1419
 
1383
1420
  return PositionContainer;
1384
1421
  })();
1385
1422
 
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){
1423
+ },{"./../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){
1387
1424
  const array = require('@barchart/common-js/lang/array'),
1388
1425
  assert = require('@barchart/common-js/lang/assert'),
1389
1426
  Currency = require('@barchart/common-js/lang/Currency'),
1390
1427
  Decimal = require('@barchart/common-js/lang/Decimal'),
1428
+ Disposable = require('@barchart/common-js/lang/Disposable'),
1391
1429
  DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
1392
1430
  Event = require('@barchart/common-js/messaging/Event'),
1393
1431
  formatter = require('@barchart/common-js/lang/formatter'),
@@ -1535,7 +1573,7 @@ module.exports = (() => {
1535
1573
  this._dataFormat.portfolioType = null;
1536
1574
 
1537
1575
  this._items.forEach((item) => {
1538
- this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
1576
+ const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
1539
1577
  if (this._single) {
1540
1578
  const precision = sender.position.instrument.currency.precision;
1541
1579
 
@@ -1571,18 +1609,39 @@ module.exports = (() => {
1571
1609
  }
1572
1610
 
1573
1611
  calculatePriceData(this, this._container.getForexQuotes(), sender, false);
1574
- }));
1612
+ });
1613
+
1614
+ let newsBinding = Disposable.getEmpty();
1615
+ let fundamentalBinding = Disposable.getEmpty();
1575
1616
 
1576
1617
  if (this._single) {
1577
- this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
1618
+ newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
1578
1619
  this._dataActual.newsExists = exists;
1579
1620
  this._dataFormat.newsExists = exists;
1580
- }));
1621
+ });
1581
1622
 
1582
- this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
1623
+ fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
1583
1624
  this._dataFormat.fundamental = data;
1584
- }));
1625
+ });
1585
1626
  }
1627
+
1628
+ this._disposeStack.push(quoteBinding);
1629
+ this._disposeStack.push(newsBinding);
1630
+ this._disposeStack.push(fundamentalBinding);
1631
+
1632
+ this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
1633
+ quoteBinding.dispose();
1634
+ newsBinding.dispose();
1635
+ fundamentalBinding.dispose();
1636
+
1637
+ array.remove(this._items, i => i === item);
1638
+ array.remove(this._excludedItems, i => i === item);
1639
+ array.remove(this._consideredItems, i => i === item);
1640
+
1641
+ delete this._excludedItemMap[item.position.position];
1642
+
1643
+ this.refresh();
1644
+ }));
1586
1645
  });
1587
1646
 
1588
1647
  this.refresh();
@@ -1778,11 +1837,16 @@ module.exports = (() => {
1778
1837
  }
1779
1838
 
1780
1839
  /**
1781
- * Causes all aggregated data to be recalculated.
1840
+ * Causes all aggregated data to be recalculated (assuming the group has not
1841
+ * been suspended).
1782
1842
  *
1783
1843
  * @public
1784
1844
  */
1785
1845
  refresh() {
1846
+ if (this._suspended) {
1847
+ return;
1848
+ }
1849
+
1786
1850
  const rates = this._container.getForexQuotes();
1787
1851
 
1788
1852
  calculateStaticData(this, rates);
@@ -1986,6 +2050,7 @@ module.exports = (() => {
1986
2050
 
1987
2051
  updates = items.reduce((updates, item) => {
1988
2052
  updates.market = updates.market.add(translate(item, item.data.market));
2053
+ updates.marketAbsolute = updates.marketAbsolute.add(translate(item, item.data.market));
1989
2054
  updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
1990
2055
  updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
1991
2056
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
@@ -1993,6 +2058,7 @@ module.exports = (() => {
1993
2058
  return updates;
1994
2059
  }, {
1995
2060
  market: Decimal.ZERO,
2061
+ marketAbsolute: Decimal.ZERO,
1996
2062
  marketDirection: unchanged,
1997
2063
  unrealized: Decimal.ZERO,
1998
2064
  unrealizedToday: Decimal.ZERO,
@@ -2001,6 +2067,7 @@ module.exports = (() => {
2001
2067
  } else {
2002
2068
  updates = {
2003
2069
  market: actual.market.add(translate(item, item.data.marketChange)),
2070
+ marketAbsolute: actual.marketAbsolute.add(translate(item, item.data.marketAbsoluteChange)),
2004
2071
  marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
2005
2072
  unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
2006
2073
  unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
@@ -2009,6 +2076,7 @@ module.exports = (() => {
2009
2076
  }
2010
2077
 
2011
2078
  actual.market = updates.market;
2079
+ actual.marketAbsolute = updates.marketAbsolute;
2012
2080
  actual.unrealized = updates.unrealized;
2013
2081
  actual.unrealizedToday = updates.unrealizedToday;
2014
2082
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
@@ -2053,16 +2121,16 @@ module.exports = (() => {
2053
2121
  if (parent !== null && !excluded) {
2054
2122
  const parentData = parent._dataActual;
2055
2123
 
2056
- if (parentData.market !== null && !parentData.market.getIsZero()) {
2124
+ if (parentData.marketAbsolute !== null && !parentData.marketAbsolute.getIsZero()) {
2057
2125
  let numerator;
2058
2126
 
2059
2127
  if (group.currency !== parent.currency) {
2060
2128
  numerator = Rate.convert(actual.market, group.currency, parent.currency, ...rates);
2061
2129
  } else {
2062
- numerator = actual.market;
2130
+ numerator = actual.marketAbsolute;
2063
2131
  }
2064
2132
 
2065
- marketPercent = numerator.divide(parentData.market);
2133
+ marketPercent = numerator.divide(parentData.marketAbsolute);
2066
2134
  } else {
2067
2135
  marketPercent = null;
2068
2136
  }
@@ -2097,7 +2165,7 @@ module.exports = (() => {
2097
2165
  return PositionGroup;
2098
2166
  })();
2099
2167
 
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){
2168
+ },{"./../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){
2101
2169
  const array = require('@barchart/common-js/lang/array'),
2102
2170
  assert = require('@barchart/common-js/lang/assert'),
2103
2171
  Currency = require('@barchart/common-js/lang/Currency'),
@@ -2146,6 +2214,9 @@ module.exports = (() => {
2146
2214
  this._data.market = null;
2147
2215
  this._data.marketChange = null;
2148
2216
 
2217
+ this._data.marketAbsolute = null;
2218
+ this._data.marketAbsoluteChange = null;
2219
+
2149
2220
  this._data.unrealizedToday = null;
2150
2221
  this._data.unrealizedTodayChange = null;
2151
2222
 
@@ -2429,6 +2500,18 @@ module.exports = (() => {
2429
2500
  data.market = market;
2430
2501
  data.marketChange = marketChange;
2431
2502
 
2503
+ let marketAbsolute = market.absolute;
2504
+ let marketAbsoluteChange;
2505
+
2506
+ if (data.marketAbsolute === null) {
2507
+ marketAbsoluteChange = marketAbsolute;
2508
+ } else {
2509
+ marketAbsoluteChange = marketAbsolute.subtract(data.marketAbsolute);
2510
+ }
2511
+
2512
+ data.marketAbsolute = market;
2513
+ data.marketAbsoluteChange = marketChange;
2514
+
2432
2515
  let unrealizedToday;
2433
2516
  let unrealizedTodayChange;
2434
2517
 
@@ -3157,6 +3240,23 @@ module.exports = function () {
3157
3240
  }
3158
3241
  }
3159
3242
 
3243
+ /**
3244
+ * Removes the current node from the parent tree. Use on a root node
3245
+ * has no effect.
3246
+ *
3247
+ * @public
3248
+ */
3249
+
3250
+ }, {
3251
+ key: 'sever',
3252
+ value: function sever() {
3253
+ if (this.getIsRoot()) {
3254
+ return;
3255
+ }
3256
+
3257
+ this.getParent().removeChild(this);
3258
+ }
3259
+
3160
3260
  /**
3161
3261
  * Searches the children nodes for the first child node that matches the
3162
3262
  * predicate.
@@ -4551,6 +4651,20 @@ module.exports = function () {
4551
4651
  return this._big.gt(getBig(other));
4552
4652
  }
4553
4653
 
4654
+ /**
4655
+ * Returns true if the current instance is greater than or equal to the value.
4656
+ *
4657
+ * @public
4658
+ * @param {Decimal|Number|String} other - The value to compare.
4659
+ * @returns {Boolean}
4660
+ */
4661
+
4662
+ }, {
4663
+ key: 'getIsGreaterThanOrEqual',
4664
+ value: function getIsGreaterThanOrEqual(other) {
4665
+ return this._big.gte(getBig(other));
4666
+ }
4667
+
4554
4668
  /**
4555
4669
  * Returns true if the current instance is less than the value.
4556
4670
  *
@@ -4565,6 +4679,20 @@ module.exports = function () {
4565
4679
  return this._big.lt(getBig(other));
4566
4680
  }
4567
4681
 
4682
+ /**
4683
+ * Returns true if the current instance is less than or equal to the value.
4684
+ *
4685
+ * @public
4686
+ * @param {Decimal|Number|String} other - The value to compare.
4687
+ * @returns {Boolean}
4688
+ */
4689
+
4690
+ }, {
4691
+ key: 'getIsLessThanOrEqual',
4692
+ value: function getIsLessThanOrEqual(other) {
4693
+ return this._big.lte(getBig(other));
4694
+ }
4695
+
4568
4696
  /**
4569
4697
  * Returns true if the current instance is equal to the value.
4570
4698
  *
@@ -5851,6 +5979,26 @@ module.exports = function () {
5851
5979
  });
5852
5980
 
5853
5981
  return returnRef;
5982
+ },
5983
+
5984
+
5985
+ /**
5986
+ * Removes the first item from an array which matches a predicate.
5987
+ *
5988
+ * @static
5989
+ * @public
5990
+ * @param {Array} a
5991
+ * @param {Function} predicate
5992
+ */
5993
+ remove: function remove(a, predicate) {
5994
+ assert.argumentIsArray(a, 'a');
5995
+ assert.argumentIsRequired(predicate, 'predicate', Function);
5996
+
5997
+ var index = a.findIndex(predicate);
5998
+
5999
+ if (!(index < 0)) {
6000
+ a.splice(index, 1);
6001
+ }
5854
6002
  }
5855
6003
  };
5856
6004
  }();