@barchart/portfolio-api-common 1.0.139 → 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.
- package/lib/processing/PositionContainer.js +10 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +26 -30
|
@@ -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);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -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);
|
|
@@ -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
|
|
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
|
|
2968
|
-
var eur = new Currency('EUR', 'Euro', 2
|
|
2969
|
-
var usd = new Currency('USD', 'US Dollar', 2
|
|
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
|
|
3936
|
+
if (a._big.gt(b)) {
|
|
3944
3937
|
return 1;
|
|
3945
|
-
} else if (a._big.lt(b
|
|
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
|
-
|
|
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'),
|