@barchart/portfolio-api-common 1.0.185 → 1.0.189
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 +3 -3
- package/lib/processing/PositionGroup.js +79 -70
- package/package.json +1 -1
- package/test/SpecRunner.js +178 -90
|
@@ -248,7 +248,7 @@ module.exports = (() => {
|
|
|
248
248
|
addSummaryPrevious(this._summariesPrevious, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
-
const item = createPositionItem(position);
|
|
251
|
+
const item = createPositionItem.call(this, position);
|
|
252
252
|
|
|
253
253
|
addBarchartSymbol(this._symbols, item);
|
|
254
254
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
@@ -262,13 +262,13 @@ module.exports = (() => {
|
|
|
262
262
|
let groupTree;
|
|
263
263
|
|
|
264
264
|
if (parentTree.getChildren().length > 0) {
|
|
265
|
-
groupTree = parentTree.
|
|
265
|
+
groupTree = parentTree.findChild(childGroup => childGroup.key === levelKey) || null;
|
|
266
266
|
} else {
|
|
267
267
|
groupTree = null;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
if (groupTree !== null) {
|
|
271
|
-
groupTree.addItem(item);
|
|
271
|
+
groupTree.getValue().addItem(item);
|
|
272
272
|
|
|
273
273
|
createGroupOrInjectItem(groupTree, treeDefinition, array.dropLeft(levelDefinitions));
|
|
274
274
|
} else {
|
|
@@ -60,7 +60,7 @@ module.exports = (() => {
|
|
|
60
60
|
|
|
61
61
|
this._excludedItems = [ ];
|
|
62
62
|
this._excludedItemMap = { };
|
|
63
|
-
this._consideredItems = this._items;
|
|
63
|
+
this._consideredItems = this._items.slice(0);
|
|
64
64
|
|
|
65
65
|
this._dataFormat = { };
|
|
66
66
|
this._dataActual = { };
|
|
@@ -149,75 +149,7 @@ module.exports = (() => {
|
|
|
149
149
|
this._dataFormat.portfolioType = null;
|
|
150
150
|
|
|
151
151
|
this._items.forEach((item) => {
|
|
152
|
-
|
|
153
|
-
if (this._single) {
|
|
154
|
-
const precision = sender.position.instrument.currency.precision;
|
|
155
|
-
|
|
156
|
-
this._dataActual.currentPrice = quote.lastPrice;
|
|
157
|
-
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
158
|
-
|
|
159
|
-
this._dataActual.quoteLast = quote.previousPrice;
|
|
160
|
-
this._dataActual.quoteOpen = quote.openPrice;
|
|
161
|
-
this._dataActual.quoteHigh = quote.highPrice;
|
|
162
|
-
this._dataActual.quoteLow = quote.lowPrice;
|
|
163
|
-
this._dataActual.quoteChange = quote.priceChange;
|
|
164
|
-
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
165
|
-
this._dataActual.quoteTime = quote.timeDisplay;
|
|
166
|
-
this._dataActual.quoteVolume = quote.volume;
|
|
167
|
-
|
|
168
|
-
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
169
|
-
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
170
|
-
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
171
|
-
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
172
|
-
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
173
|
-
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
174
|
-
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
175
|
-
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
176
|
-
|
|
177
|
-
const quoteChangePositive = quote.lastPriceDirection === 'up';
|
|
178
|
-
const quoteChangeNegative = quote.lastPriceDirection === 'down';
|
|
179
|
-
|
|
180
|
-
setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
|
|
181
|
-
this._dataFormat.quoteChangeNegative = quoteChangeNegative;
|
|
182
|
-
} else {
|
|
183
|
-
this._dataActual.currentPrice = null;
|
|
184
|
-
this._dataFormat.currentPrice = null;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
let newsBinding = Disposable.getEmpty();
|
|
191
|
-
let fundamentalBinding = Disposable.getEmpty();
|
|
192
|
-
|
|
193
|
-
if (this._single) {
|
|
194
|
-
newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
195
|
-
this._dataActual.newsExists = exists;
|
|
196
|
-
this._dataFormat.newsExists = exists;
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
200
|
-
this._dataFormat.fundamental = data;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
this._disposeStack.push(quoteBinding);
|
|
205
|
-
this._disposeStack.push(newsBinding);
|
|
206
|
-
this._disposeStack.push(fundamentalBinding);
|
|
207
|
-
|
|
208
|
-
this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
|
|
209
|
-
quoteBinding.dispose();
|
|
210
|
-
newsBinding.dispose();
|
|
211
|
-
fundamentalBinding.dispose();
|
|
212
|
-
|
|
213
|
-
array.remove(this._items, i => i === item);
|
|
214
|
-
array.remove(this._excludedItems, i => i === item);
|
|
215
|
-
array.remove(this._consideredItems, i => i === item);
|
|
216
|
-
|
|
217
|
-
delete this._excludedItemMap[item.position.position];
|
|
218
|
-
|
|
219
|
-
this.refresh();
|
|
220
|
-
}));
|
|
152
|
+
bindItem.call(this, item);
|
|
221
153
|
});
|
|
222
154
|
|
|
223
155
|
this.refresh();
|
|
@@ -335,6 +267,10 @@ module.exports = (() => {
|
|
|
335
267
|
* @param {PositionItem} item
|
|
336
268
|
*/
|
|
337
269
|
addItem(item) {
|
|
270
|
+
this._items.push(item);
|
|
271
|
+
this._consideredItems.push(item);
|
|
272
|
+
|
|
273
|
+
bindItem.call(this, item);
|
|
338
274
|
|
|
339
275
|
this.refresh();
|
|
340
276
|
}
|
|
@@ -468,6 +404,79 @@ module.exports = (() => {
|
|
|
468
404
|
}
|
|
469
405
|
}
|
|
470
406
|
|
|
407
|
+
function bindItem(item) {
|
|
408
|
+
const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
|
|
409
|
+
if (this._single) {
|
|
410
|
+
const precision = sender.position.instrument.currency.precision;
|
|
411
|
+
|
|
412
|
+
this._dataActual.currentPrice = quote.lastPrice;
|
|
413
|
+
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
414
|
+
|
|
415
|
+
this._dataActual.quoteLast = quote.previousPrice;
|
|
416
|
+
this._dataActual.quoteOpen = quote.openPrice;
|
|
417
|
+
this._dataActual.quoteHigh = quote.highPrice;
|
|
418
|
+
this._dataActual.quoteLow = quote.lowPrice;
|
|
419
|
+
this._dataActual.quoteChange = quote.priceChange;
|
|
420
|
+
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
421
|
+
this._dataActual.quoteTime = quote.timeDisplay;
|
|
422
|
+
this._dataActual.quoteVolume = quote.volume;
|
|
423
|
+
|
|
424
|
+
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
425
|
+
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
426
|
+
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
427
|
+
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
428
|
+
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
429
|
+
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
430
|
+
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
431
|
+
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
432
|
+
|
|
433
|
+
const quoteChangePositive = quote.lastPriceDirection === 'up';
|
|
434
|
+
const quoteChangeNegative = quote.lastPriceDirection === 'down';
|
|
435
|
+
|
|
436
|
+
setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
|
|
437
|
+
|
|
438
|
+
this._dataFormat.quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
|
|
439
|
+
} else {
|
|
440
|
+
this._dataActual.currentPrice = null;
|
|
441
|
+
this._dataFormat.currentPrice = null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
let newsBinding = Disposable.getEmpty();
|
|
448
|
+
let fundamentalBinding = Disposable.getEmpty();
|
|
449
|
+
|
|
450
|
+
if (this._single) {
|
|
451
|
+
newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
452
|
+
this._dataActual.newsExists = exists;
|
|
453
|
+
this._dataFormat.newsExists = exists;
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
457
|
+
this._dataFormat.fundamental = data;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
this._disposeStack.push(quoteBinding);
|
|
462
|
+
this._disposeStack.push(newsBinding);
|
|
463
|
+
this._disposeStack.push(fundamentalBinding);
|
|
464
|
+
|
|
465
|
+
this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
|
|
466
|
+
quoteBinding.dispose();
|
|
467
|
+
newsBinding.dispose();
|
|
468
|
+
fundamentalBinding.dispose();
|
|
469
|
+
|
|
470
|
+
array.remove(this._items, i => i === item);
|
|
471
|
+
array.remove(this._excludedItems, i => i === item);
|
|
472
|
+
array.remove(this._consideredItems, i => i === item);
|
|
473
|
+
|
|
474
|
+
delete this._excludedItemMap[item.position.position];
|
|
475
|
+
|
|
476
|
+
this.refresh();
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
|
|
471
480
|
function formatNumber(number, precision) {
|
|
472
481
|
if (is.number(number)) {
|
|
473
482
|
return formatter.numberToString(number, precision, ',', false);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){function e
|
|
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
|
|
|
@@ -964,7 +964,7 @@ module.exports = (() => {
|
|
|
964
964
|
addSummaryPrevious(this._summariesPrevious, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
965
965
|
});
|
|
966
966
|
|
|
967
|
-
const item = createPositionItem(position);
|
|
967
|
+
const item = createPositionItem.call(this, position);
|
|
968
968
|
|
|
969
969
|
addBarchartSymbol(this._symbols, item);
|
|
970
970
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
@@ -978,13 +978,13 @@ module.exports = (() => {
|
|
|
978
978
|
let groupTree;
|
|
979
979
|
|
|
980
980
|
if (parentTree.getChildren().length > 0) {
|
|
981
|
-
groupTree = parentTree.
|
|
981
|
+
groupTree = parentTree.findChild(childGroup => childGroup.key === levelKey) || null;
|
|
982
982
|
} else {
|
|
983
983
|
groupTree = null;
|
|
984
984
|
}
|
|
985
985
|
|
|
986
986
|
if (groupTree !== null) {
|
|
987
|
-
groupTree.addItem(item);
|
|
987
|
+
groupTree.getValue().addItem(item);
|
|
988
988
|
|
|
989
989
|
createGroupOrInjectItem(groupTree, treeDefinition, array.dropLeft(levelDefinitions));
|
|
990
990
|
} else {
|
|
@@ -1588,7 +1588,7 @@ module.exports = (() => {
|
|
|
1588
1588
|
|
|
1589
1589
|
this._excludedItems = [ ];
|
|
1590
1590
|
this._excludedItemMap = { };
|
|
1591
|
-
this._consideredItems = this._items;
|
|
1591
|
+
this._consideredItems = this._items.slice(0);
|
|
1592
1592
|
|
|
1593
1593
|
this._dataFormat = { };
|
|
1594
1594
|
this._dataActual = { };
|
|
@@ -1677,75 +1677,7 @@ module.exports = (() => {
|
|
|
1677
1677
|
this._dataFormat.portfolioType = null;
|
|
1678
1678
|
|
|
1679
1679
|
this._items.forEach((item) => {
|
|
1680
|
-
|
|
1681
|
-
if (this._single) {
|
|
1682
|
-
const precision = sender.position.instrument.currency.precision;
|
|
1683
|
-
|
|
1684
|
-
this._dataActual.currentPrice = quote.lastPrice;
|
|
1685
|
-
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
1686
|
-
|
|
1687
|
-
this._dataActual.quoteLast = quote.previousPrice;
|
|
1688
|
-
this._dataActual.quoteOpen = quote.openPrice;
|
|
1689
|
-
this._dataActual.quoteHigh = quote.highPrice;
|
|
1690
|
-
this._dataActual.quoteLow = quote.lowPrice;
|
|
1691
|
-
this._dataActual.quoteChange = quote.priceChange;
|
|
1692
|
-
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
1693
|
-
this._dataActual.quoteTime = quote.timeDisplay;
|
|
1694
|
-
this._dataActual.quoteVolume = quote.volume;
|
|
1695
|
-
|
|
1696
|
-
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
1697
|
-
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
1698
|
-
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
1699
|
-
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
1700
|
-
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
1701
|
-
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
1702
|
-
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
1703
|
-
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
1704
|
-
|
|
1705
|
-
const quoteChangePositive = quote.lastPriceDirection === 'up';
|
|
1706
|
-
const quoteChangeNegative = quote.lastPriceDirection === 'down';
|
|
1707
|
-
|
|
1708
|
-
setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
|
|
1709
|
-
this._dataFormat.quoteChangeNegative = quoteChangeNegative;
|
|
1710
|
-
} else {
|
|
1711
|
-
this._dataActual.currentPrice = null;
|
|
1712
|
-
this._dataFormat.currentPrice = null;
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
1716
|
-
});
|
|
1717
|
-
|
|
1718
|
-
let newsBinding = Disposable.getEmpty();
|
|
1719
|
-
let fundamentalBinding = Disposable.getEmpty();
|
|
1720
|
-
|
|
1721
|
-
if (this._single) {
|
|
1722
|
-
newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1723
|
-
this._dataActual.newsExists = exists;
|
|
1724
|
-
this._dataFormat.newsExists = exists;
|
|
1725
|
-
});
|
|
1726
|
-
|
|
1727
|
-
fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1728
|
-
this._dataFormat.fundamental = data;
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
this._disposeStack.push(quoteBinding);
|
|
1733
|
-
this._disposeStack.push(newsBinding);
|
|
1734
|
-
this._disposeStack.push(fundamentalBinding);
|
|
1735
|
-
|
|
1736
|
-
this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
|
|
1737
|
-
quoteBinding.dispose();
|
|
1738
|
-
newsBinding.dispose();
|
|
1739
|
-
fundamentalBinding.dispose();
|
|
1740
|
-
|
|
1741
|
-
array.remove(this._items, i => i === item);
|
|
1742
|
-
array.remove(this._excludedItems, i => i === item);
|
|
1743
|
-
array.remove(this._consideredItems, i => i === item);
|
|
1744
|
-
|
|
1745
|
-
delete this._excludedItemMap[item.position.position];
|
|
1746
|
-
|
|
1747
|
-
this.refresh();
|
|
1748
|
-
}));
|
|
1680
|
+
bindItem.call(this, item);
|
|
1749
1681
|
});
|
|
1750
1682
|
|
|
1751
1683
|
this.refresh();
|
|
@@ -1863,6 +1795,10 @@ module.exports = (() => {
|
|
|
1863
1795
|
* @param {PositionItem} item
|
|
1864
1796
|
*/
|
|
1865
1797
|
addItem(item) {
|
|
1798
|
+
this._items.push(item);
|
|
1799
|
+
this._consideredItems.push(item);
|
|
1800
|
+
|
|
1801
|
+
bindItem.call(this, item);
|
|
1866
1802
|
|
|
1867
1803
|
this.refresh();
|
|
1868
1804
|
}
|
|
@@ -1996,6 +1932,79 @@ module.exports = (() => {
|
|
|
1996
1932
|
}
|
|
1997
1933
|
}
|
|
1998
1934
|
|
|
1935
|
+
function bindItem(item) {
|
|
1936
|
+
const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
|
|
1937
|
+
if (this._single) {
|
|
1938
|
+
const precision = sender.position.instrument.currency.precision;
|
|
1939
|
+
|
|
1940
|
+
this._dataActual.currentPrice = quote.lastPrice;
|
|
1941
|
+
this._dataFormat.currentPrice = formatNumber(this._dataActual.currentPrice, precision);
|
|
1942
|
+
|
|
1943
|
+
this._dataActual.quoteLast = quote.previousPrice;
|
|
1944
|
+
this._dataActual.quoteOpen = quote.openPrice;
|
|
1945
|
+
this._dataActual.quoteHigh = quote.highPrice;
|
|
1946
|
+
this._dataActual.quoteLow = quote.lowPrice;
|
|
1947
|
+
this._dataActual.quoteChange = quote.priceChange;
|
|
1948
|
+
this._dataActual.quoteChangePercent = quote.percentChange;
|
|
1949
|
+
this._dataActual.quoteTime = quote.timeDisplay;
|
|
1950
|
+
this._dataActual.quoteVolume = quote.volume;
|
|
1951
|
+
|
|
1952
|
+
this._dataFormat.quoteLast = formatNumber(this._dataActual.quoteLast , precision);
|
|
1953
|
+
this._dataFormat.quoteOpen = formatNumber(this._dataActual.quoteOpen, precision);
|
|
1954
|
+
this._dataFormat.quoteHigh = formatNumber(this._dataActual.quoteHigh, precision);
|
|
1955
|
+
this._dataFormat.quoteLow = formatNumber(this._dataActual.quoteLow, precision);
|
|
1956
|
+
this._dataFormat.quoteChange = formatNumber(this._dataActual.quoteChange, precision);
|
|
1957
|
+
this._dataFormat.quoteChangePercent = formatPercent(new Decimal(this._dataActual.quoteChangePercent || 0), 2);
|
|
1958
|
+
this._dataFormat.quoteTime = this._dataActual.quoteTime;
|
|
1959
|
+
this._dataFormat.quoteVolume = formatNumber(this._dataActual.quoteVolume, 0);
|
|
1960
|
+
|
|
1961
|
+
const quoteChangePositive = quote.lastPriceDirection === 'up';
|
|
1962
|
+
const quoteChangeNegative = quote.lastPriceDirection === 'down';
|
|
1963
|
+
|
|
1964
|
+
setTimeout(() => this._dataFormat.quoteChangeDirection = { up: quoteChangePositive, down: quoteChangeNegative }, 0);
|
|
1965
|
+
|
|
1966
|
+
this._dataFormat.quoteChangeNegative = is.number(this._dataActual.quoteChange) && this._dataActual.quoteChange < 0;
|
|
1967
|
+
} else {
|
|
1968
|
+
this._dataActual.currentPrice = null;
|
|
1969
|
+
this._dataFormat.currentPrice = null;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
1973
|
+
});
|
|
1974
|
+
|
|
1975
|
+
let newsBinding = Disposable.getEmpty();
|
|
1976
|
+
let fundamentalBinding = Disposable.getEmpty();
|
|
1977
|
+
|
|
1978
|
+
if (this._single) {
|
|
1979
|
+
newsBinding = item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1980
|
+
this._dataActual.newsExists = exists;
|
|
1981
|
+
this._dataFormat.newsExists = exists;
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
fundamentalBinding = item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1985
|
+
this._dataFormat.fundamental = data;
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
this._disposeStack.push(quoteBinding);
|
|
1990
|
+
this._disposeStack.push(newsBinding);
|
|
1991
|
+
this._disposeStack.push(fundamentalBinding);
|
|
1992
|
+
|
|
1993
|
+
this._disposeStack.push(item.registerPositionItemDisposeHandler(() => {
|
|
1994
|
+
quoteBinding.dispose();
|
|
1995
|
+
newsBinding.dispose();
|
|
1996
|
+
fundamentalBinding.dispose();
|
|
1997
|
+
|
|
1998
|
+
array.remove(this._items, i => i === item);
|
|
1999
|
+
array.remove(this._excludedItems, i => i === item);
|
|
2000
|
+
array.remove(this._consideredItems, i => i === item);
|
|
2001
|
+
|
|
2002
|
+
delete this._excludedItemMap[item.position.position];
|
|
2003
|
+
|
|
2004
|
+
this.refresh();
|
|
2005
|
+
}));
|
|
2006
|
+
}
|
|
2007
|
+
|
|
1999
2008
|
function formatNumber(number, precision) {
|
|
2000
2009
|
if (is.number(number)) {
|
|
2001
2010
|
return formatter.numberToString(number, precision, ',', false);
|
|
@@ -3343,6 +3352,23 @@ module.exports = function () {
|
|
|
3343
3352
|
}
|
|
3344
3353
|
}
|
|
3345
3354
|
|
|
3355
|
+
/**
|
|
3356
|
+
* Removes the current node from the parent tree. Use on a root node
|
|
3357
|
+
* has no effect.
|
|
3358
|
+
*
|
|
3359
|
+
* @public
|
|
3360
|
+
*/
|
|
3361
|
+
|
|
3362
|
+
}, {
|
|
3363
|
+
key: 'sever',
|
|
3364
|
+
value: function sever() {
|
|
3365
|
+
if (this.getIsRoot()) {
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
this.getParent().removeChild(this);
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3346
3372
|
/**
|
|
3347
3373
|
* Searches the children nodes for the first child node that matches the
|
|
3348
3374
|
* predicate.
|
|
@@ -3869,7 +3895,7 @@ module.exports = function () {
|
|
|
3869
3895
|
var Currency = function (_Enum) {
|
|
3870
3896
|
_inherits(Currency, _Enum);
|
|
3871
3897
|
|
|
3872
|
-
function Currency(code, description, precision) {
|
|
3898
|
+
function Currency(code, description, precision, alternateDescription) {
|
|
3873
3899
|
_classCallCheck(this, Currency);
|
|
3874
3900
|
|
|
3875
3901
|
var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
|
|
@@ -3877,7 +3903,11 @@ module.exports = function () {
|
|
|
3877
3903
|
assert.argumentIsRequired(precision, 'precision', Number);
|
|
3878
3904
|
assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
|
|
3879
3905
|
|
|
3906
|
+
assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
|
|
3907
|
+
|
|
3880
3908
|
_this._precision = precision;
|
|
3909
|
+
|
|
3910
|
+
_this._alternateDescription = alternateDescription || description;
|
|
3881
3911
|
return _this;
|
|
3882
3912
|
}
|
|
3883
3913
|
|
|
@@ -3900,6 +3930,19 @@ module.exports = function () {
|
|
|
3900
3930
|
return this._precision;
|
|
3901
3931
|
}
|
|
3902
3932
|
|
|
3933
|
+
/**
|
|
3934
|
+
* An alternate human-readable description.
|
|
3935
|
+
*
|
|
3936
|
+
* @public
|
|
3937
|
+
* @returns {String}
|
|
3938
|
+
*/
|
|
3939
|
+
|
|
3940
|
+
}, {
|
|
3941
|
+
key: 'alternateDescription',
|
|
3942
|
+
get: function get() {
|
|
3943
|
+
return this._alternateDescription;
|
|
3944
|
+
}
|
|
3945
|
+
|
|
3903
3946
|
/**
|
|
3904
3947
|
* Given a code, returns the enumeration item.
|
|
3905
3948
|
*
|
|
@@ -3957,9 +4000,9 @@ module.exports = function () {
|
|
|
3957
4000
|
return Currency;
|
|
3958
4001
|
}(Enum);
|
|
3959
4002
|
|
|
3960
|
-
var cad = new Currency('CAD', 'Canadian Dollar', 2);
|
|
3961
|
-
var eur = new Currency('EUR', 'Euro', 2);
|
|
3962
|
-
var usd = new Currency('USD', 'US Dollar', 2);
|
|
4003
|
+
var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
|
|
4004
|
+
var eur = new Currency('EUR', 'Euro', 2, 'EUR');
|
|
4005
|
+
var usd = new Currency('USD', 'US Dollar', 2, 'US$');
|
|
3963
4006
|
|
|
3964
4007
|
return Currency;
|
|
3965
4008
|
}();
|
|
@@ -4720,6 +4763,20 @@ module.exports = function () {
|
|
|
4720
4763
|
return this._big.gt(getBig(other));
|
|
4721
4764
|
}
|
|
4722
4765
|
|
|
4766
|
+
/**
|
|
4767
|
+
* Returns true if the current instance is greater than or equal to the value.
|
|
4768
|
+
*
|
|
4769
|
+
* @public
|
|
4770
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
4771
|
+
* @returns {Boolean}
|
|
4772
|
+
*/
|
|
4773
|
+
|
|
4774
|
+
}, {
|
|
4775
|
+
key: 'getIsGreaterThanOrEqual',
|
|
4776
|
+
value: function getIsGreaterThanOrEqual(other) {
|
|
4777
|
+
return this._big.gte(getBig(other));
|
|
4778
|
+
}
|
|
4779
|
+
|
|
4723
4780
|
/**
|
|
4724
4781
|
* Returns true if the current instance is less than the value.
|
|
4725
4782
|
*
|
|
@@ -4734,6 +4791,20 @@ module.exports = function () {
|
|
|
4734
4791
|
return this._big.lt(getBig(other));
|
|
4735
4792
|
}
|
|
4736
4793
|
|
|
4794
|
+
/**
|
|
4795
|
+
* Returns true if the current instance is less than or equal to the value.
|
|
4796
|
+
*
|
|
4797
|
+
* @public
|
|
4798
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
4799
|
+
* @returns {Boolean}
|
|
4800
|
+
*/
|
|
4801
|
+
|
|
4802
|
+
}, {
|
|
4803
|
+
key: 'getIsLessThanOrEqual',
|
|
4804
|
+
value: function getIsLessThanOrEqual(other) {
|
|
4805
|
+
return this._big.lte(getBig(other));
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4737
4808
|
/**
|
|
4738
4809
|
* Returns true if the current instance is equal to the value.
|
|
4739
4810
|
*
|
|
@@ -4933,9 +5004,9 @@ module.exports = function () {
|
|
|
4933
5004
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
4934
5005
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
4935
5006
|
|
|
4936
|
-
if (a._big.gt(b)) {
|
|
5007
|
+
if (a._big.gt(b._big)) {
|
|
4937
5008
|
return 1;
|
|
4938
|
-
} else if (a._big.lt(b)) {
|
|
5009
|
+
} else if (a._big.lt(b._big)) {
|
|
4939
5010
|
return -1;
|
|
4940
5011
|
} else {
|
|
4941
5012
|
return 0;
|
|
@@ -5396,12 +5467,10 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
5396
5467
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5397
5468
|
|
|
5398
5469
|
var assert = require('./assert'),
|
|
5399
|
-
is = require('./is'),
|
|
5400
5470
|
memoize = require('./memoize');
|
|
5401
5471
|
|
|
5402
5472
|
var Currency = require('./Currency'),
|
|
5403
|
-
Decimal = require('./Decimal')
|
|
5404
|
-
Enum = require('./Enum');
|
|
5473
|
+
Decimal = require('./Decimal');
|
|
5405
5474
|
|
|
5406
5475
|
module.exports = function () {
|
|
5407
5476
|
'use strict';
|
|
@@ -5581,12 +5650,7 @@ module.exports = function () {
|
|
|
5581
5650
|
assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
|
|
5582
5651
|
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
5583
5652
|
assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
|
|
5584
|
-
|
|
5585
|
-
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5586
|
-
rates[_key - 3] = arguments[_key];
|
|
5587
|
-
}
|
|
5588
|
-
|
|
5589
|
-
assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
5653
|
+
//assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
5590
5654
|
|
|
5591
5655
|
var converted = void 0;
|
|
5592
5656
|
|
|
@@ -5596,6 +5660,10 @@ module.exports = function () {
|
|
|
5596
5660
|
var numerator = desiredCurrency;
|
|
5597
5661
|
var denominator = currency;
|
|
5598
5662
|
|
|
5663
|
+
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5664
|
+
rates[_key - 3] = arguments[_key];
|
|
5665
|
+
}
|
|
5666
|
+
|
|
5599
5667
|
var rate = rates.find(function (r) {
|
|
5600
5668
|
return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
|
|
5601
5669
|
});
|
|
@@ -5646,7 +5714,7 @@ module.exports = function () {
|
|
|
5646
5714
|
return Rate;
|
|
5647
5715
|
}();
|
|
5648
5716
|
|
|
5649
|
-
},{"./Currency":15,"./Decimal":17,"./
|
|
5717
|
+
},{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
|
|
5650
5718
|
'use strict';
|
|
5651
5719
|
|
|
5652
5720
|
var assert = require('./assert'),
|
|
@@ -6023,6 +6091,26 @@ module.exports = function () {
|
|
|
6023
6091
|
});
|
|
6024
6092
|
|
|
6025
6093
|
return returnRef;
|
|
6094
|
+
},
|
|
6095
|
+
|
|
6096
|
+
|
|
6097
|
+
/**
|
|
6098
|
+
* Removes the first item from an array which matches a predicate.
|
|
6099
|
+
*
|
|
6100
|
+
* @static
|
|
6101
|
+
* @public
|
|
6102
|
+
* @param {Array} a
|
|
6103
|
+
* @param {Function} predicate
|
|
6104
|
+
*/
|
|
6105
|
+
remove: function remove(a, predicate) {
|
|
6106
|
+
assert.argumentIsArray(a, 'a');
|
|
6107
|
+
assert.argumentIsRequired(predicate, 'predicate', Function);
|
|
6108
|
+
|
|
6109
|
+
var index = a.findIndex(predicate);
|
|
6110
|
+
|
|
6111
|
+
if (!(index < 0)) {
|
|
6112
|
+
a.splice(index, 1);
|
|
6113
|
+
}
|
|
6026
6114
|
}
|
|
6027
6115
|
};
|
|
6028
6116
|
}();
|