@barchart/portfolio-api-common 1.0.47 → 1.0.48

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,6 +1,6 @@
1
1
  const assert = require('@barchart/common-js/lang/assert'),
2
2
  is = require('@barchart/common-js/lang/is'),
3
- numberFormatter = require('@barchart/common-js/lang/formatter');
3
+ formatter = require('@barchart/common-js/lang/formatter');
4
4
 
5
5
  const TransactionType = require('./../data/TransactionType');
6
6
 
@@ -51,7 +51,7 @@ module.exports = (() => {
51
51
  if (!is.undefined(formattedTransaction[key]) && is.fn(formattedTransaction[key].toFloat)) {
52
52
  const precision = transaction.instrument.currency.precision;
53
53
 
54
- formattedTransaction[key] = numberFormatter.numberToString(formattedTransaction[key].toFloat(), precision, ',');
54
+ formattedTransaction[key] = formatter.numberToString(formattedTransaction[key].toFloat(), precision, ',');
55
55
  }
56
56
  });
57
57
 
@@ -83,7 +83,7 @@ module.exports = (() => {
83
83
  const missingGroups = array.difference(currentDefinition.requiredGroups, populatedGroups.map(group => group.description));
84
84
 
85
85
  const empty = missingGroups.map((description) => {
86
- return new PositionGroup(description, [ ]);
86
+ return new PositionGroup([ ], description);
87
87
  });
88
88
 
89
89
  const compositeGroups = populatedGroups.concat(empty);
@@ -1,5 +1,7 @@
1
1
  const assert = require('@barchart/common-js/lang/assert'),
2
+ Currency = require('@barchart/common-js/lang/Currency'),
2
3
  Decimal = require('@barchart/common-js/lang/Decimal'),
4
+ formatter = require('@barchart/common-js/lang/formatter'),
3
5
  is = require('@barchart/common-js/lang/is');
4
6
 
5
7
  module.exports = (() => {
@@ -15,22 +17,31 @@ module.exports = (() => {
15
17
 
16
18
  this._single = is.boolean(single) && single;
17
19
 
18
- this._data = { };
20
+ this._dataFormat = { };
21
+ this._dataRaw = { };
22
+
23
+ this._dataFormat.description = this._description;
19
24
 
20
- this._data.description = this._description;
25
+ this._dataRaw.current = null;
26
+ this._dataRaw.previous = null;
21
27
 
22
- this._data.current = null;
23
- this._data.previous = null;
28
+ this._dataFormat.current = null;
29
+ this._dataFormat.previous = null;
24
30
 
25
- this._data.basis = null;
26
- this._data.market = null;
31
+ this._dataRaw.basis = null;
32
+ this._dataRaw.market = null;
33
+
34
+ this._dataFormat.basis = null;
35
+ this._dataFormat.market = null;
27
36
 
28
37
  this._items.forEach((item) => {
29
38
  item.registerPriceChangeHandler((data, sender) => {
30
39
  if (this._single) {
31
- data.current = data.current;
40
+ this._dataRaw.current = data.current;
41
+ this._dataFormat.current = format(data.current, sender.position.instrument.currency);
32
42
  } else {
33
- data.current = null;
43
+ this._dataRaw.current = null;
44
+ this._dataFormat.current = null;
34
45
  }
35
46
 
36
47
  calculateVariablePriceData(this, item, price);
@@ -45,7 +56,7 @@ module.exports = (() => {
45
56
  }
46
57
 
47
58
  get data() {
48
- return this._data;
59
+ return this._dataFormat;
49
60
  }
50
61
 
51
62
  get items() {
@@ -61,9 +72,15 @@ module.exports = (() => {
61
72
  }
62
73
  }
63
74
 
75
+ function format(decimal, currency) {
76
+ return formatter.numberToString(decimal.toFloat(), currency.precision, ',', false);
77
+ }
78
+
64
79
  function calculateStaticData(group) {
65
80
  const items = group._items;
66
- const data = group._data;
81
+
82
+ const raw = group._dataRaw;
83
+ const formatted = group._dataFormat;
67
84
 
68
85
  let updates;
69
86
 
@@ -84,7 +101,8 @@ module.exports = (() => {
84
101
  });
85
102
  }
86
103
 
87
- data.basis = updates.basis;
104
+ raw.basis = updates.basis;
105
+ formatted.basis = format(updates.basis, Currency.USD);
88
106
  }
89
107
 
90
108
  function calculateVariablePriceData(group, item, price) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -185,7 +185,7 @@ module.exports = (() => {
185
185
  return PositionSummaryFrame;
186
186
  })();
187
187
 
188
- },{"@barchart/common-js/lang/Day":10,"@barchart/common-js/lang/Enum":13,"@barchart/common-js/lang/array":14,"@barchart/common-js/lang/assert":15,"@barchart/common-js/lang/is":16}],2:[function(require,module,exports){
188
+ },{"@barchart/common-js/lang/Day":11,"@barchart/common-js/lang/Enum":14,"@barchart/common-js/lang/array":15,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],2:[function(require,module,exports){
189
189
  const assert = require('@barchart/common-js/lang/assert'),
190
190
  Enum = require('@barchart/common-js/lang/Enum');
191
191
 
@@ -512,7 +512,7 @@ module.exports = (() => {
512
512
  return TransactionType;
513
513
  })();
514
514
 
515
- },{"@barchart/common-js/lang/Enum":13,"@barchart/common-js/lang/assert":15}],3:[function(require,module,exports){
515
+ },{"@barchart/common-js/lang/Enum":14,"@barchart/common-js/lang/assert":16}],3:[function(require,module,exports){
516
516
  const array = require('@barchart/common-js/lang/array'),
517
517
  assert = require('@barchart/common-js/lang/assert'),
518
518
  is = require('@barchart/common-js/lang/is'),
@@ -598,7 +598,7 @@ module.exports = (() => {
598
598
  const missingGroups = array.difference(currentDefinition.requiredGroups, populatedGroups.map(group => group.description));
599
599
 
600
600
  const empty = missingGroups.map((description) => {
601
- return new PositionGroup(description, [ ]);
601
+ return new PositionGroup([ ], description);
602
602
  });
603
603
 
604
604
  const compositeGroups = populatedGroups.concat(empty);
@@ -651,9 +651,11 @@ module.exports = (() => {
651
651
  return PositionContainer;
652
652
  })();
653
653
 
654
- },{"./PositionGroup":4,"./PositionGroupDefinition":5,"./PositionItem":6,"@barchart/common-js/collections/Tree":7,"@barchart/common-js/lang/array":14,"@barchart/common-js/lang/assert":15,"@barchart/common-js/lang/is":16}],4:[function(require,module,exports){
654
+ },{"./PositionGroup":4,"./PositionGroupDefinition":5,"./PositionItem":6,"@barchart/common-js/collections/Tree":7,"@barchart/common-js/lang/array":15,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],4:[function(require,module,exports){
655
655
  const assert = require('@barchart/common-js/lang/assert'),
656
+ Currency = require('@barchart/common-js/lang/Currency'),
656
657
  Decimal = require('@barchart/common-js/lang/Decimal'),
658
+ formatter = require('@barchart/common-js/lang/formatter'),
657
659
  is = require('@barchart/common-js/lang/is');
658
660
 
659
661
  module.exports = (() => {
@@ -669,22 +671,31 @@ module.exports = (() => {
669
671
 
670
672
  this._single = is.boolean(single) && single;
671
673
 
672
- this._data = { };
674
+ this._dataFormat = { };
675
+ this._dataRaw = { };
676
+
677
+ this._dataFormat.description = this._description;
673
678
 
674
- this._data.description = this._description;
679
+ this._dataRaw.current = null;
680
+ this._dataRaw.previous = null;
675
681
 
676
- this._data.current = null;
677
- this._data.previous = null;
682
+ this._dataFormat.current = null;
683
+ this._dataFormat.previous = null;
684
+
685
+ this._dataRaw.basis = null;
686
+ this._dataRaw.market = null;
678
687
 
679
- this._data.basis = null;
680
- this._data.market = null;
688
+ this._dataFormat.basis = null;
689
+ this._dataFormat.market = null;
681
690
 
682
691
  this._items.forEach((item) => {
683
692
  item.registerPriceChangeHandler((data, sender) => {
684
693
  if (this._single) {
685
- data.current = data.current;
694
+ this._dataRaw.current = data.current;
695
+ this._dataFormat.current = format(data.current, sender.position.instrument.currency);
686
696
  } else {
687
- data.current = null;
697
+ this._dataRaw.current = null;
698
+ this._dataFormat.current = null;
688
699
  }
689
700
 
690
701
  calculateVariablePriceData(this, item, price);
@@ -699,7 +710,7 @@ module.exports = (() => {
699
710
  }
700
711
 
701
712
  get data() {
702
- return this._data;
713
+ return this._dataFormat;
703
714
  }
704
715
 
705
716
  get items() {
@@ -715,9 +726,15 @@ module.exports = (() => {
715
726
  }
716
727
  }
717
728
 
729
+ function format(decimal, currency) {
730
+ return formatter.numberToString(decimal.toFloat(), currency.precision, ',', false);
731
+ }
732
+
718
733
  function calculateStaticData(group) {
719
734
  const items = group._items;
720
- const data = group._data;
735
+
736
+ const raw = group._dataRaw;
737
+ const formatted = group._dataFormat;
721
738
 
722
739
  let updates;
723
740
 
@@ -738,7 +755,8 @@ module.exports = (() => {
738
755
  });
739
756
  }
740
757
 
741
- data.basis = updates.basis;
758
+ raw.basis = updates.basis;
759
+ formatted.basis = format(updates.basis, Currency.USD);
742
760
  }
743
761
 
744
762
  function calculateVariablePriceData(group, item, price) {
@@ -748,7 +766,7 @@ module.exports = (() => {
748
766
  return PositionGroup;
749
767
  })();
750
768
 
751
- },{"@barchart/common-js/lang/Decimal":11,"@barchart/common-js/lang/assert":15,"@barchart/common-js/lang/is":16}],5:[function(require,module,exports){
769
+ },{"@barchart/common-js/lang/Currency":10,"@barchart/common-js/lang/Decimal":12,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/formatter":17,"@barchart/common-js/lang/is":18}],5:[function(require,module,exports){
752
770
  const assert = require('@barchart/common-js/lang/assert'),
753
771
  is = require('@barchart/common-js/lang/is');
754
772
 
@@ -793,7 +811,7 @@ module.exports = (() => {
793
811
  return PositionGroupDefinition;
794
812
  })();
795
813
 
796
- },{"@barchart/common-js/lang/assert":15,"@barchart/common-js/lang/is":16}],6:[function(require,module,exports){
814
+ },{"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],6:[function(require,module,exports){
797
815
  const assert = require('@barchart/common-js/lang/assert'),
798
816
  Event = require('@barchart/common-js/messaging/Event'),
799
817
  is = require('@barchart/common-js/lang/is');
@@ -854,7 +872,7 @@ module.exports = (() => {
854
872
  return PositionItem;
855
873
  })();
856
874
 
857
- },{"@barchart/common-js/lang/assert":15,"@barchart/common-js/lang/is":16,"@barchart/common-js/messaging/Event":17}],7:[function(require,module,exports){
875
+ },{"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18,"@barchart/common-js/messaging/Event":19}],7:[function(require,module,exports){
858
876
  'use strict';
859
877
 
860
878
  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; }; }();
@@ -1163,7 +1181,7 @@ module.exports = function () {
1163
1181
  return Tree;
1164
1182
  }();
1165
1183
 
1166
- },{"./../lang/is":16}],8:[function(require,module,exports){
1184
+ },{"./../lang/is":18}],8:[function(require,module,exports){
1167
1185
  'use strict';
1168
1186
 
1169
1187
  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; }; }();
@@ -1307,7 +1325,7 @@ module.exports = function () {
1307
1325
  return ComparatorBuilder;
1308
1326
  }();
1309
1327
 
1310
- },{"./../../lang/assert":15,"./comparators":9}],9:[function(require,module,exports){
1328
+ },{"./../../lang/assert":16,"./comparators":9}],9:[function(require,module,exports){
1311
1329
  'use strict';
1312
1330
 
1313
1331
  var assert = require('./../../lang/assert');
@@ -1382,7 +1400,150 @@ module.exports = function () {
1382
1400
  };
1383
1401
  }();
1384
1402
 
1385
- },{"./../../lang/assert":15}],10:[function(require,module,exports){
1403
+ },{"./../../lang/assert":16}],10:[function(require,module,exports){
1404
+ 'use strict';
1405
+
1406
+ 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; }; }();
1407
+
1408
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1409
+
1410
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1411
+
1412
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1413
+
1414
+ var assert = require('./assert'),
1415
+ Enum = require('./Enum'),
1416
+ is = require('./is');
1417
+
1418
+ module.exports = function () {
1419
+ 'use strict';
1420
+
1421
+ /**
1422
+ * An enumeration for currency types.
1423
+ *
1424
+ * @public
1425
+ * @param {String} code - Currency code (e.g. "USD")
1426
+ * @param {String} description - The description (e.g. "US Dollar")
1427
+ * @param {Number} precision - The number of decimal places possible for by a real world transaction.
1428
+ * @extends {Enum}
1429
+ */
1430
+
1431
+ var Currency = function (_Enum) {
1432
+ _inherits(Currency, _Enum);
1433
+
1434
+ function Currency(code, description, precision, alternateDescription) {
1435
+ _classCallCheck(this, Currency);
1436
+
1437
+ var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
1438
+
1439
+ assert.argumentIsRequired(precision, 'precision', Number);
1440
+ assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
1441
+
1442
+ assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
1443
+
1444
+ _this._precision = precision;
1445
+
1446
+ _this._alternateDescription = alternateDescription || description;
1447
+ return _this;
1448
+ }
1449
+
1450
+ /**
1451
+ * The maximum number of decimal places supported by a real world transaction.
1452
+ *
1453
+ * @public
1454
+ * @returns {Number}
1455
+ */
1456
+
1457
+
1458
+ _createClass(Currency, [{
1459
+ key: 'toString',
1460
+ value: function toString() {
1461
+ return '[Currency (code=' + this.code + ')]';
1462
+ }
1463
+ }, {
1464
+ key: 'precision',
1465
+ get: function get() {
1466
+ return this._precision;
1467
+ }
1468
+
1469
+ /**
1470
+ * An alternate human-readable description.
1471
+ *
1472
+ * @public
1473
+ * @returns {String}
1474
+ */
1475
+
1476
+ }, {
1477
+ key: 'alternateDescription',
1478
+ get: function get() {
1479
+ return this._alternateDescription;
1480
+ }
1481
+
1482
+ /**
1483
+ * Given a code, returns the enumeration item.
1484
+ *
1485
+ * @public
1486
+ * @param {String} code
1487
+ * @returns {Currency|null}
1488
+ */
1489
+
1490
+ }], [{
1491
+ key: 'parse',
1492
+ value: function parse(code) {
1493
+ return Enum.fromCode(Currency, code);
1494
+ }
1495
+
1496
+ /**
1497
+ * The Canadian Dollar.
1498
+ *
1499
+ * @public
1500
+ * @returns {Currency}
1501
+ */
1502
+
1503
+ }, {
1504
+ key: 'CAD',
1505
+ get: function get() {
1506
+ return cad;
1507
+ }
1508
+
1509
+ /**
1510
+ * The Euro.
1511
+ *
1512
+ * @public
1513
+ * @returns {Currency}
1514
+ */
1515
+
1516
+ }, {
1517
+ key: 'EUR',
1518
+ get: function get() {
1519
+ return eur;
1520
+ }
1521
+
1522
+ /**
1523
+ * The US Dollar.
1524
+ *
1525
+ * @public
1526
+ * @returns {Currency}
1527
+ */
1528
+
1529
+ }, {
1530
+ key: 'USD',
1531
+ get: function get() {
1532
+ return usd;
1533
+ }
1534
+ }]);
1535
+
1536
+ return Currency;
1537
+ }(Enum);
1538
+
1539
+ var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
1540
+ var eur = new Currency('EUR', 'Euro', 2, 'EUR');
1541
+ var usd = new Currency('USD', 'US Dollar', 2, 'US$');
1542
+
1543
+ return Currency;
1544
+ }();
1545
+
1546
+ },{"./Enum":14,"./assert":16,"./is":18}],11:[function(require,module,exports){
1386
1547
  'use strict';
1387
1548
 
1388
1549
  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; }; }();
@@ -1935,7 +2096,7 @@ module.exports = function () {
1935
2096
  return Day;
1936
2097
  }();
1937
2098
 
1938
- },{"./../collections/sorting/ComparatorBuilder":8,"./../collections/sorting/comparators":9,"./assert":15,"./is":16}],11:[function(require,module,exports){
2099
+ },{"./../collections/sorting/ComparatorBuilder":8,"./../collections/sorting/comparators":9,"./assert":16,"./is":18}],12:[function(require,module,exports){
1939
2100
  'use strict';
1940
2101
 
1941
2102
  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; }; }();
@@ -2515,7 +2676,7 @@ module.exports = function () {
2515
2676
  return Decimal;
2516
2677
  }();
2517
2678
 
2518
- },{"./Enum":13,"./assert":15,"./is":16,"big.js":18}],12:[function(require,module,exports){
2679
+ },{"./Enum":14,"./assert":16,"./is":18,"big.js":20}],13:[function(require,module,exports){
2519
2680
  'use strict';
2520
2681
 
2521
2682
  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; }; }();
@@ -2664,7 +2825,7 @@ module.exports = function () {
2664
2825
  return Disposable;
2665
2826
  }();
2666
2827
 
2667
- },{"./assert":15}],13:[function(require,module,exports){
2828
+ },{"./assert":16}],14:[function(require,module,exports){
2668
2829
  'use strict';
2669
2830
 
2670
2831
  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; }; }();
@@ -2806,7 +2967,7 @@ module.exports = function () {
2806
2967
  return Enum;
2807
2968
  }();
2808
2969
 
2809
- },{"./assert":15}],14:[function(require,module,exports){
2970
+ },{"./assert":16}],15:[function(require,module,exports){
2810
2971
  'use strict';
2811
2972
 
2812
2973
  var assert = require('./assert'),
@@ -3187,7 +3348,7 @@ module.exports = function () {
3187
3348
  };
3188
3349
  }();
3189
3350
 
3190
- },{"./assert":15,"./is":16}],15:[function(require,module,exports){
3351
+ },{"./assert":16,"./is":18}],16:[function(require,module,exports){
3191
3352
  'use strict';
3192
3353
 
3193
3354
  var is = require('./is');
@@ -3335,7 +3496,72 @@ module.exports = function () {
3335
3496
  };
3336
3497
  }();
3337
3498
 
3338
- },{"./is":16}],16:[function(require,module,exports){
3499
+ },{"./is":18}],17:[function(require,module,exports){
3500
+ 'use strict';
3501
+
3502
+ module.exports = function () {
3503
+ 'use strict';
3504
+
3505
+ return {
3506
+ /**
3507
+ * Formats a number into a string for display purposes.
3508
+ */
3509
+ numberToString: function numberToString(value, digits, thousandsSeparator, useParenthesis) {
3510
+ if (value === '' || value === undefined || value === null || isNaN(value)) {
3511
+ return '';
3512
+ }
3513
+
3514
+ var applyParenthesis = value < 0 && useParenthesis === true;
3515
+
3516
+ if (applyParenthesis) {
3517
+ value = 0 - value;
3518
+ }
3519
+
3520
+ var returnRef = value.toFixed(digits);
3521
+
3522
+ if (thousandsSeparator && !(value > -1000 && value < 1000)) {
3523
+ var length = returnRef.length;
3524
+ var negative = value < 0;
3525
+
3526
+ var found = digits === 0;
3527
+ var counter = 0;
3528
+
3529
+ var buffer = [];
3530
+
3531
+ for (var i = length - 1; !(i < 0); i--) {
3532
+ if (counter === 3 && !(negative && i === 0)) {
3533
+ buffer.unshift(thousandsSeparator);
3534
+
3535
+ counter = 0;
3536
+ }
3537
+
3538
+ var character = returnRef.charAt(i);
3539
+
3540
+ buffer.unshift(character);
3541
+
3542
+ if (found) {
3543
+ counter = counter + 1;
3544
+ } else if (character === '.') {
3545
+ found = true;
3546
+ }
3547
+ }
3548
+
3549
+ if (applyParenthesis) {
3550
+ buffer.unshift('(');
3551
+ buffer.push(')');
3552
+ }
3553
+
3554
+ returnRef = buffer.join('');
3555
+ } else if (applyParenthesis) {
3556
+ returnRef = '(' + returnRef + ')';
3557
+ }
3558
+
3559
+ return returnRef;
3560
+ }
3561
+ };
3562
+ }();
3563
+
3564
+ },{}],18:[function(require,module,exports){
3339
3565
  'use strict';
3340
3566
 
3341
3567
  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; };
@@ -3558,7 +3784,7 @@ module.exports = function () {
3558
3784
  };
3559
3785
  }();
3560
3786
 
3561
- },{}],17:[function(require,module,exports){
3787
+ },{}],19:[function(require,module,exports){
3562
3788
  'use strict';
3563
3789
 
3564
3790
  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; }; }();
@@ -3730,7 +3956,7 @@ module.exports = function () {
3730
3956
  return Event;
3731
3957
  }();
3732
3958
 
3733
- },{"./../lang/Disposable":12,"./../lang/assert":15}],18:[function(require,module,exports){
3959
+ },{"./../lang/Disposable":13,"./../lang/assert":16}],20:[function(require,module,exports){
3734
3960
  /*
3735
3961
  * big.js v5.0.3
3736
3962
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -4671,7 +4897,7 @@ module.exports = function () {
4671
4897
  }
4672
4898
  })(this);
4673
4899
 
4674
- },{}],19:[function(require,module,exports){
4900
+ },{}],21:[function(require,module,exports){
4675
4901
  const Day = require('@barchart/common-js/lang/Day'),
4676
4902
  Decimal = require('@barchart/common-js/lang/Decimal');
4677
4903
 
@@ -5028,8 +5254,9 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
5028
5254
  });
5029
5255
  });
5030
5256
 
5031
- },{"./../../../lib/data/PositionSummaryFrame":1,"./../../../lib/data/TransactionType":2,"@barchart/common-js/lang/Day":10,"@barchart/common-js/lang/Decimal":11}],20:[function(require,module,exports){
5032
- const Decimal = require('@barchart/common-js/lang/Decimal');
5257
+ },{"./../../../lib/data/PositionSummaryFrame":1,"./../../../lib/data/TransactionType":2,"@barchart/common-js/lang/Day":11,"@barchart/common-js/lang/Decimal":12}],22:[function(require,module,exports){
5258
+ const Currency = require('@barchart/common-js/lang/Currency'),
5259
+ Decimal = require('@barchart/common-js/lang/Decimal');
5033
5260
 
5034
5261
  const PositionContainer = require('./../../../lib/processing/PositionContainer'),
5035
5262
  PositionGroupDefinition = require('./../../../lib/processing/PositionGroupDefinition');
@@ -5039,13 +5266,14 @@ describe('When a position container data is gathered', () => {
5039
5266
 
5040
5267
  let positionCounter = 0;
5041
5268
 
5042
- function getPosition(portfolio, symbol) {
5269
+ function getPosition(portfolio, symbol, currency) {
5043
5270
  return {
5044
5271
  portfolio: portfolio,
5045
5272
  position: (positionCounter++).toString(),
5046
5273
  instrument: {
5047
5274
  symbol: {
5048
- barchart: symbol
5275
+ barchart: symbol,
5276
+ currency: currency || Currency.USD
5049
5277
  }
5050
5278
  },
5051
5279
  snapshot: {
@@ -5124,4 +5352,4 @@ describe('When a position container data is gathered', () => {
5124
5352
  });
5125
5353
  });
5126
5354
 
5127
- },{"./../../../lib/processing/PositionContainer":3,"./../../../lib/processing/PositionGroupDefinition":5,"@barchart/common-js/lang/Decimal":11}]},{},[19,20]);
5355
+ },{"./../../../lib/processing/PositionContainer":3,"./../../../lib/processing/PositionGroupDefinition":5,"@barchart/common-js/lang/Currency":10,"@barchart/common-js/lang/Decimal":12}]},{},[21,22]);
@@ -1,4 +1,5 @@
1
- const Decimal = require('@barchart/common-js/lang/Decimal');
1
+ const Currency = require('@barchart/common-js/lang/Currency'),
2
+ Decimal = require('@barchart/common-js/lang/Decimal');
2
3
 
3
4
  const PositionContainer = require('./../../../lib/processing/PositionContainer'),
4
5
  PositionGroupDefinition = require('./../../../lib/processing/PositionGroupDefinition');
@@ -8,13 +9,14 @@ describe('When a position container data is gathered', () => {
8
9
 
9
10
  let positionCounter = 0;
10
11
 
11
- function getPosition(portfolio, symbol) {
12
+ function getPosition(portfolio, symbol, currency) {
12
13
  return {
13
14
  portfolio: portfolio,
14
15
  position: (positionCounter++).toString(),
15
16
  instrument: {
16
17
  symbol: {
17
- barchart: symbol
18
+ barchart: symbol,
19
+ currency: currency || Currency.USD
18
20
  }
19
21
  },
20
22
  snapshot: {