@barchart/portfolio-api-common 1.0.136 → 1.0.140

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.
@@ -396,6 +396,16 @@ module.exports = (() => {
396
396
  return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
397
397
  }
398
398
 
399
+ getPositions(portfolio) {
400
+ return this._items.reduce((positions, item) => {
401
+ if (item.position.portfolio === portfolio) {
402
+ positions.push(item);
403
+ }
404
+
405
+ return positions;
406
+ }, []);
407
+ }
408
+
399
409
  startTransaction(name, executor) {
400
410
  assert.argumentIsRequired(name, 'name', String);
401
411
  assert.argumentIsRequired(executor, 'executor', Function);
@@ -146,7 +146,7 @@ module.exports = (() => {
146
146
  this._dataFormat.newsExists = exists;
147
147
  });
148
148
 
149
- item._fundamentalDataChangeEvent((data, sender) => {
149
+ item.registerFundamentalDataChangeHandler((data, sender) => {
150
150
  this._dataFormat.fundamental = data;
151
151
  });
152
152
  }
@@ -264,7 +264,7 @@ module.exports = (() => {
264
264
  assert.argumentIsRequired(value, 'value', Boolean);
265
265
 
266
266
  if (this._showClosedPositions !== value) {
267
- this._showClosedPositionsChangeEvent(this._showClosedPositions = value);
267
+ this._showClosedPositionsChangeEvent.fire(this._showClosedPositions = value);
268
268
  }
269
269
  }
270
270
 
@@ -172,7 +172,7 @@ module.exports = (() => {
172
172
  setPositionFundamentalData(data) {
173
173
  assert.argumentIsRequired(data, 'data', Object);
174
174
 
175
- this._fundamentalDataChangeEvent(this._data.fundamental = data);
175
+ this._fundamentalDataChangeEvent.fire(this._data.fundamental = data);
176
176
  }
177
177
 
178
178
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.136",
3
+ "version": "1.0.140",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1112,6 +1112,16 @@ module.exports = (() => {
1112
1112
  return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
1113
1113
  }
1114
1114
 
1115
+ getPositions(portfolio) {
1116
+ return this._items.reduce((positions, item) => {
1117
+ if (item.position.portfolio === portfolio) {
1118
+ positions.push(item);
1119
+ }
1120
+
1121
+ return positions;
1122
+ }, []);
1123
+ }
1124
+
1115
1125
  startTransaction(name, executor) {
1116
1126
  assert.argumentIsRequired(name, 'name', String);
1117
1127
  assert.argumentIsRequired(executor, 'executor', Function);
@@ -1305,7 +1315,7 @@ module.exports = (() => {
1305
1315
  this._dataFormat.newsExists = exists;
1306
1316
  });
1307
1317
 
1308
- item._fundamentalDataChangeEvent((data, sender) => {
1318
+ item.registerFundamentalDataChangeHandler((data, sender) => {
1309
1319
  this._dataFormat.fundamental = data;
1310
1320
  });
1311
1321
  }
@@ -1423,7 +1433,7 @@ module.exports = (() => {
1423
1433
  assert.argumentIsRequired(value, 'value', Boolean);
1424
1434
 
1425
1435
  if (this._showClosedPositions !== value) {
1426
- this._showClosedPositionsChangeEvent(this._showClosedPositions = value);
1436
+ this._showClosedPositionsChangeEvent.fire(this._showClosedPositions = value);
1427
1437
  }
1428
1438
  }
1429
1439
 
@@ -1899,7 +1909,7 @@ module.exports = (() => {
1899
1909
  setPositionFundamentalData(data) {
1900
1910
  assert.argumentIsRequired(data, 'data', Object);
1901
1911
 
1902
- this._fundamentalDataChangeEvent(this._data.fundamental = data);
1912
+ this._fundamentalDataChangeEvent.fire(this._data.fundamental = data);
1903
1913
  }
1904
1914
 
1905
1915
  /**
@@ -2859,7 +2869,7 @@ module.exports = function () {
2859
2869
  var Currency = function (_Enum) {
2860
2870
  _inherits(Currency, _Enum);
2861
2871
 
2862
- function Currency(code, description, precision, alternateDescription) {
2872
+ function Currency(code, description, precision) {
2863
2873
  _classCallCheck(this, Currency);
2864
2874
 
2865
2875
  var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
@@ -2867,11 +2877,7 @@ module.exports = function () {
2867
2877
  assert.argumentIsRequired(precision, 'precision', Number);
2868
2878
  assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
2869
2879
 
2870
- assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
2871
-
2872
2880
  _this._precision = precision;
2873
-
2874
- _this._alternateDescription = alternateDescription || description;
2875
2881
  return _this;
2876
2882
  }
2877
2883
 
@@ -2894,19 +2900,6 @@ module.exports = function () {
2894
2900
  return this._precision;
2895
2901
  }
2896
2902
 
2897
- /**
2898
- * An alternate human-readable description.
2899
- *
2900
- * @public
2901
- * @returns {String}
2902
- */
2903
-
2904
- }, {
2905
- key: 'alternateDescription',
2906
- get: function get() {
2907
- return this._alternateDescription;
2908
- }
2909
-
2910
2903
  /**
2911
2904
  * Given a code, returns the enumeration item.
2912
2905
  *
@@ -2964,9 +2957,9 @@ module.exports = function () {
2964
2957
  return Currency;
2965
2958
  }(Enum);
2966
2959
 
2967
- var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
2968
- var eur = new Currency('EUR', 'Euro', 2, 'EUR');
2969
- var usd = new Currency('USD', 'US Dollar', 2, 'US$');
2960
+ var cad = new Currency('CAD', 'Canadian Dollar', 2);
2961
+ var eur = new Currency('EUR', 'Euro', 2);
2962
+ var usd = new Currency('USD', 'US Dollar', 2);
2970
2963
 
2971
2964
  return Currency;
2972
2965
  }();
@@ -3940,9 +3933,9 @@ module.exports = function () {
3940
3933
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
3941
3934
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
3942
3935
 
3943
- if (a._big.gt(b._big)) {
3936
+ if (a._big.gt(b)) {
3944
3937
  return 1;
3945
- } else if (a._big.lt(b._big)) {
3938
+ } else if (a._big.lt(b)) {
3946
3939
  return -1;
3947
3940
  } else {
3948
3941
  return 0;
@@ -4403,10 +4396,12 @@ var _createClass = function () { function defineProperties(target, props) { for
4403
4396
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4404
4397
 
4405
4398
  var assert = require('./assert'),
4399
+ is = require('./is'),
4406
4400
  memoize = require('./memoize');
4407
4401
 
4408
4402
  var Currency = require('./Currency'),
4409
- Decimal = require('./Decimal');
4403
+ Decimal = require('./Decimal'),
4404
+ Enum = require('./Enum');
4410
4405
 
4411
4406
  module.exports = function () {
4412
4407
  'use strict';
@@ -4586,7 +4581,12 @@ module.exports = function () {
4586
4581
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
4587
4582
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
4588
4583
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
4589
- //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
4584
+
4585
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
4586
+ rates[_key - 3] = arguments[_key];
4587
+ }
4588
+
4589
+ assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
4590
4590
 
4591
4591
  var converted = void 0;
4592
4592
 
@@ -4596,10 +4596,6 @@ module.exports = function () {
4596
4596
  var numerator = desiredCurrency;
4597
4597
  var denominator = currency;
4598
4598
 
4599
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
4600
- rates[_key - 3] = arguments[_key];
4601
- }
4602
-
4603
4599
  var rate = rates.find(function (r) {
4604
4600
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
4605
4601
  });
@@ -4650,7 +4646,7 @@ module.exports = function () {
4650
4646
  return Rate;
4651
4647
  }();
4652
4648
 
4653
- },{"./Currency":12,"./Decimal":14,"./assert":19,"./memoize":22}],18:[function(require,module,exports){
4649
+ },{"./Currency":12,"./Decimal":14,"./Enum":16,"./assert":19,"./is":21,"./memoize":22}],18:[function(require,module,exports){
4654
4650
  'use strict';
4655
4651
 
4656
4652
  var assert = require('./assert'),