@barchart/portfolio-api-common 1.0.141 → 1.0.142
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.
|
@@ -214,9 +214,15 @@ module.exports = (() => {
|
|
|
214
214
|
|
|
215
215
|
compositeGroups.sort(builder.toComparator());
|
|
216
216
|
|
|
217
|
+
const initializeGroupObservers = (group, groupTree) => {
|
|
218
|
+
|
|
219
|
+
};
|
|
220
|
+
|
|
217
221
|
compositeGroups.forEach((group) => {
|
|
218
222
|
const childTree = currentTree.addChild(group);
|
|
219
223
|
|
|
224
|
+
initializeGroupObservers(group, childTree);
|
|
225
|
+
|
|
220
226
|
group.registerMarketPercentChangeHandler(() => {
|
|
221
227
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
222
228
|
});
|
|
@@ -44,6 +44,8 @@ module.exports = (() => {
|
|
|
44
44
|
this._excludedChangeEvent = new Event(this);
|
|
45
45
|
this._showClosedPositionsChangeEvent = new Event(this);
|
|
46
46
|
|
|
47
|
+
this._excludedItems = { };
|
|
48
|
+
|
|
47
49
|
this._dataFormat = { };
|
|
48
50
|
this._dataActual = { };
|
|
49
51
|
|
|
@@ -74,6 +76,15 @@ module.exports = (() => {
|
|
|
74
76
|
this._dataFormat.fundamental = { };
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
this._dataActual.quoteLast = null;
|
|
80
|
+
this._dataActual.quoteOpen = null;
|
|
81
|
+
this._dataActual.quoteHigh = null;
|
|
82
|
+
this._dataActual.quoteLow = null;
|
|
83
|
+
this._dataActual.quoteChange = null;
|
|
84
|
+
this._dataActual.quoteChangePercent = null;
|
|
85
|
+
this._dataActual.quoteTime = null;
|
|
86
|
+
this._dataActual.quoteVolume = null;
|
|
87
|
+
|
|
77
88
|
this._dataFormat.quoteLast = null;
|
|
78
89
|
this._dataFormat.quoteOpen = null;
|
|
79
90
|
this._dataFormat.quoteHigh = null;
|
|
@@ -124,14 +135,23 @@ module.exports = (() => {
|
|
|
124
135
|
this._dataActual.currentPrice = quote.lastPrice;
|
|
125
136
|
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
126
137
|
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
132
|
-
this.
|
|
133
|
-
this.
|
|
134
|
-
this.
|
|
138
|
+
this._dataActual.quoteLast = quote.previousPrice;
|
|
139
|
+
this._dataActual.quoteOpen = quote.openPrice;
|
|
140
|
+
this._dataActual.quoteHigh = quote.highPrice;
|
|
141
|
+
this._dataActual.quoteLow = quote.lowPrice;
|
|
142
|
+
this._dataActual.quoteChange = quote.priceChange;
|
|
143
|
+
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
144
|
+
this._dataActual.quoteTime = quote.timeDisplay;
|
|
145
|
+
this._dataActual.quoteVolume = quote.volume;
|
|
146
|
+
|
|
147
|
+
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
148
|
+
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
149
|
+
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
150
|
+
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
151
|
+
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
152
|
+
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
153
|
+
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
154
|
+
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
135
155
|
} else {
|
|
136
156
|
this._dataActual.currentPrice = null;
|
|
137
157
|
this._dataFormat.currentPrice = null;
|
|
@@ -240,6 +260,20 @@ module.exports = (() => {
|
|
|
240
260
|
return this._excluded;
|
|
241
261
|
}
|
|
242
262
|
|
|
263
|
+
addExcludedItems(items) {
|
|
264
|
+
items.forEach((item) => {
|
|
265
|
+
const key = item.position.position;
|
|
266
|
+
|
|
267
|
+
if (this._excludedItems.hasOwnProperty(key)) {
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
removeExcludedItems(items) {
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
243
277
|
/**
|
|
244
278
|
* Causes aggregated data to be recalculated using a new exchange rate.
|
|
245
279
|
*
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -930,9 +930,15 @@ module.exports = (() => {
|
|
|
930
930
|
|
|
931
931
|
compositeGroups.sort(builder.toComparator());
|
|
932
932
|
|
|
933
|
+
const initializeGroupObservers = (group, groupTree) => {
|
|
934
|
+
|
|
935
|
+
};
|
|
936
|
+
|
|
933
937
|
compositeGroups.forEach((group) => {
|
|
934
938
|
const childTree = currentTree.addChild(group);
|
|
935
939
|
|
|
940
|
+
initializeGroupObservers(group, childTree);
|
|
941
|
+
|
|
936
942
|
group.registerMarketPercentChangeHandler(() => {
|
|
937
943
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
938
944
|
});
|
|
@@ -1222,6 +1228,8 @@ module.exports = (() => {
|
|
|
1222
1228
|
this._excludedChangeEvent = new Event(this);
|
|
1223
1229
|
this._showClosedPositionsChangeEvent = new Event(this);
|
|
1224
1230
|
|
|
1231
|
+
this._excludedItems = { };
|
|
1232
|
+
|
|
1225
1233
|
this._dataFormat = { };
|
|
1226
1234
|
this._dataActual = { };
|
|
1227
1235
|
|
|
@@ -1252,6 +1260,15 @@ module.exports = (() => {
|
|
|
1252
1260
|
this._dataFormat.fundamental = { };
|
|
1253
1261
|
}
|
|
1254
1262
|
|
|
1263
|
+
this._dataActual.quoteLast = null;
|
|
1264
|
+
this._dataActual.quoteOpen = null;
|
|
1265
|
+
this._dataActual.quoteHigh = null;
|
|
1266
|
+
this._dataActual.quoteLow = null;
|
|
1267
|
+
this._dataActual.quoteChange = null;
|
|
1268
|
+
this._dataActual.quoteChangePercent = null;
|
|
1269
|
+
this._dataActual.quoteTime = null;
|
|
1270
|
+
this._dataActual.quoteVolume = null;
|
|
1271
|
+
|
|
1255
1272
|
this._dataFormat.quoteLast = null;
|
|
1256
1273
|
this._dataFormat.quoteOpen = null;
|
|
1257
1274
|
this._dataFormat.quoteHigh = null;
|
|
@@ -1302,14 +1319,23 @@ module.exports = (() => {
|
|
|
1302
1319
|
this._dataActual.currentPrice = quote.lastPrice;
|
|
1303
1320
|
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
1304
1321
|
|
|
1305
|
-
this.
|
|
1306
|
-
this.
|
|
1307
|
-
this.
|
|
1308
|
-
this.
|
|
1309
|
-
this.
|
|
1310
|
-
this.
|
|
1311
|
-
this.
|
|
1312
|
-
this.
|
|
1322
|
+
this._dataActual.quoteLast = quote.previousPrice;
|
|
1323
|
+
this._dataActual.quoteOpen = quote.openPrice;
|
|
1324
|
+
this._dataActual.quoteHigh = quote.highPrice;
|
|
1325
|
+
this._dataActual.quoteLow = quote.lowPrice;
|
|
1326
|
+
this._dataActual.quoteChange = quote.priceChange;
|
|
1327
|
+
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
1328
|
+
this._dataActual.quoteTime = quote.timeDisplay;
|
|
1329
|
+
this._dataActual.quoteVolume = quote.volume;
|
|
1330
|
+
|
|
1331
|
+
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
1332
|
+
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
1333
|
+
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
1334
|
+
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
1335
|
+
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
1336
|
+
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
1337
|
+
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
1338
|
+
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
1313
1339
|
} else {
|
|
1314
1340
|
this._dataActual.currentPrice = null;
|
|
1315
1341
|
this._dataFormat.currentPrice = null;
|
|
@@ -1418,6 +1444,20 @@ module.exports = (() => {
|
|
|
1418
1444
|
return this._excluded;
|
|
1419
1445
|
}
|
|
1420
1446
|
|
|
1447
|
+
addExcludedItems(items) {
|
|
1448
|
+
items.forEach((item) => {
|
|
1449
|
+
const key = item.position.position;
|
|
1450
|
+
|
|
1451
|
+
if (this._excludedItems.hasOwnProperty(key)) {
|
|
1452
|
+
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
removeExcludedItems(items) {
|
|
1458
|
+
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1421
1461
|
/**
|
|
1422
1462
|
* Causes aggregated data to be recalculated using a new exchange rate.
|
|
1423
1463
|
*
|
|
@@ -2878,7 +2918,7 @@ module.exports = function () {
|
|
|
2878
2918
|
var Currency = function (_Enum) {
|
|
2879
2919
|
_inherits(Currency, _Enum);
|
|
2880
2920
|
|
|
2881
|
-
function Currency(code, description, precision) {
|
|
2921
|
+
function Currency(code, description, precision, alternateDescription) {
|
|
2882
2922
|
_classCallCheck(this, Currency);
|
|
2883
2923
|
|
|
2884
2924
|
var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
|
|
@@ -2886,7 +2926,11 @@ module.exports = function () {
|
|
|
2886
2926
|
assert.argumentIsRequired(precision, 'precision', Number);
|
|
2887
2927
|
assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
|
|
2888
2928
|
|
|
2929
|
+
assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
|
|
2930
|
+
|
|
2889
2931
|
_this._precision = precision;
|
|
2932
|
+
|
|
2933
|
+
_this._alternateDescription = alternateDescription || description;
|
|
2890
2934
|
return _this;
|
|
2891
2935
|
}
|
|
2892
2936
|
|
|
@@ -2909,6 +2953,19 @@ module.exports = function () {
|
|
|
2909
2953
|
return this._precision;
|
|
2910
2954
|
}
|
|
2911
2955
|
|
|
2956
|
+
/**
|
|
2957
|
+
* An alternate human-readable description.
|
|
2958
|
+
*
|
|
2959
|
+
* @public
|
|
2960
|
+
* @returns {String}
|
|
2961
|
+
*/
|
|
2962
|
+
|
|
2963
|
+
}, {
|
|
2964
|
+
key: 'alternateDescription',
|
|
2965
|
+
get: function get() {
|
|
2966
|
+
return this._alternateDescription;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2912
2969
|
/**
|
|
2913
2970
|
* Given a code, returns the enumeration item.
|
|
2914
2971
|
*
|
|
@@ -2966,9 +3023,9 @@ module.exports = function () {
|
|
|
2966
3023
|
return Currency;
|
|
2967
3024
|
}(Enum);
|
|
2968
3025
|
|
|
2969
|
-
var cad = new Currency('CAD', 'Canadian Dollar', 2);
|
|
2970
|
-
var eur = new Currency('EUR', 'Euro', 2);
|
|
2971
|
-
var usd = new Currency('USD', 'US Dollar', 2);
|
|
3026
|
+
var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
|
|
3027
|
+
var eur = new Currency('EUR', 'Euro', 2, 'EUR');
|
|
3028
|
+
var usd = new Currency('USD', 'US Dollar', 2, 'US$');
|
|
2972
3029
|
|
|
2973
3030
|
return Currency;
|
|
2974
3031
|
}();
|
|
@@ -3942,9 +3999,9 @@ module.exports = function () {
|
|
|
3942
3999
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
3943
4000
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
3944
4001
|
|
|
3945
|
-
if (a._big.gt(b)) {
|
|
4002
|
+
if (a._big.gt(b._big)) {
|
|
3946
4003
|
return 1;
|
|
3947
|
-
} else if (a._big.lt(b)) {
|
|
4004
|
+
} else if (a._big.lt(b._big)) {
|
|
3948
4005
|
return -1;
|
|
3949
4006
|
} else {
|
|
3950
4007
|
return 0;
|
|
@@ -4405,12 +4462,10 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
4405
4462
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4406
4463
|
|
|
4407
4464
|
var assert = require('./assert'),
|
|
4408
|
-
is = require('./is'),
|
|
4409
4465
|
memoize = require('./memoize');
|
|
4410
4466
|
|
|
4411
4467
|
var Currency = require('./Currency'),
|
|
4412
|
-
Decimal = require('./Decimal')
|
|
4413
|
-
Enum = require('./Enum');
|
|
4468
|
+
Decimal = require('./Decimal');
|
|
4414
4469
|
|
|
4415
4470
|
module.exports = function () {
|
|
4416
4471
|
'use strict';
|
|
@@ -4590,12 +4645,7 @@ module.exports = function () {
|
|
|
4590
4645
|
assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
|
|
4591
4646
|
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
4592
4647
|
assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
|
|
4593
|
-
|
|
4594
|
-
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
4595
|
-
rates[_key - 3] = arguments[_key];
|
|
4596
|
-
}
|
|
4597
|
-
|
|
4598
|
-
assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
4648
|
+
//assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
4599
4649
|
|
|
4600
4650
|
var converted = void 0;
|
|
4601
4651
|
|
|
@@ -4605,6 +4655,10 @@ module.exports = function () {
|
|
|
4605
4655
|
var numerator = desiredCurrency;
|
|
4606
4656
|
var denominator = currency;
|
|
4607
4657
|
|
|
4658
|
+
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
4659
|
+
rates[_key - 3] = arguments[_key];
|
|
4660
|
+
}
|
|
4661
|
+
|
|
4608
4662
|
var rate = rates.find(function (r) {
|
|
4609
4663
|
return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
|
|
4610
4664
|
});
|
|
@@ -4655,7 +4709,7 @@ module.exports = function () {
|
|
|
4655
4709
|
return Rate;
|
|
4656
4710
|
}();
|
|
4657
4711
|
|
|
4658
|
-
},{"./Currency":12,"./Decimal":14,"./
|
|
4712
|
+
},{"./Currency":12,"./Decimal":14,"./assert":19,"./memoize":22}],18:[function(require,module,exports){
|
|
4659
4713
|
'use strict';
|
|
4660
4714
|
|
|
4661
4715
|
var assert = require('./assert'),
|