@barchart/portfolio-api-common 1.0.142 → 1.0.143
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.
|
@@ -4,6 +4,7 @@ const array = require('@barchart/common-js/lang/array'),
|
|
|
4
4
|
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
5
5
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
6
6
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
7
|
+
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
7
8
|
is = require('@barchart/common-js/lang/is'),
|
|
8
9
|
Rate = require('@barchart/common-js/lang/Rate'),
|
|
9
10
|
Tree = require('@barchart/common-js/collections/Tree');
|
|
@@ -47,6 +48,18 @@ module.exports = (() => {
|
|
|
47
48
|
const currentSummaryFrame = PositionSummaryFrame.YTD;
|
|
48
49
|
const currentSummaryRange = array.last(currentSummaryFrame.getRecentRanges(0));
|
|
49
50
|
|
|
51
|
+
this._groupBindings = { };
|
|
52
|
+
|
|
53
|
+
const addGroupBinding = (group, dispoable) => {
|
|
54
|
+
const id = group.id;
|
|
55
|
+
|
|
56
|
+
if (!this._groupBindings.hasOwnProperty(id)) {
|
|
57
|
+
this._groupBindings[id] = new DisposableStack();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this._groupBindings[id].push(dispoable);
|
|
61
|
+
};
|
|
62
|
+
|
|
50
63
|
this._portfolios = portfolios.reduce((map, portfolio) => {
|
|
51
64
|
map[portfolio.portfolio] = portfolio;
|
|
52
65
|
|
|
@@ -215,7 +228,19 @@ module.exports = (() => {
|
|
|
215
228
|
compositeGroups.sort(builder.toComparator());
|
|
216
229
|
|
|
217
230
|
const initializeGroupObservers = (group, groupTree) => {
|
|
218
|
-
|
|
231
|
+
addGroupBinding(group, group.registerGroupExcludedChangeHandler((excluded, sender) => {
|
|
232
|
+
groupTree.climb((parentGroup, parentTree) => {
|
|
233
|
+
let excludedItems = [ ];
|
|
234
|
+
|
|
235
|
+
currentTree.walk((childGroup, childTree) => {
|
|
236
|
+
if (childGroup.excluded) {
|
|
237
|
+
excludedItems = excludedItems.concat(childGroup.items);
|
|
238
|
+
}
|
|
239
|
+
}, false, false);
|
|
240
|
+
|
|
241
|
+
parentGroup.setExcludedItems(array.unique(excludedItems));
|
|
242
|
+
}, false);
|
|
243
|
+
}));
|
|
219
244
|
};
|
|
220
245
|
|
|
221
246
|
compositeGroups.forEach((group) => {
|
|
@@ -223,9 +248,9 @@ module.exports = (() => {
|
|
|
223
248
|
|
|
224
249
|
initializeGroupObservers(group, childTree);
|
|
225
250
|
|
|
226
|
-
group.registerMarketPercentChangeHandler(() => {
|
|
251
|
+
addGroupBinding(group, group.registerMarketPercentChangeHandler(() => {
|
|
227
252
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
228
|
-
});
|
|
253
|
+
}));
|
|
229
254
|
|
|
230
255
|
createGroups(childTree, group.items, array.dropLeft(levelDefinitions));
|
|
231
256
|
});
|
|
@@ -385,6 +410,7 @@ module.exports = (() => {
|
|
|
385
410
|
/**
|
|
386
411
|
* Returns a single level of grouping from one of the internal trees.
|
|
387
412
|
*
|
|
413
|
+
* @public
|
|
388
414
|
* @param {String} name
|
|
389
415
|
* @param {Array.<String> keys
|
|
390
416
|
* @returns {PositionGroup}
|
|
@@ -400,6 +426,7 @@ module.exports = (() => {
|
|
|
400
426
|
* Returns all child groups from a level of grouping within one of
|
|
401
427
|
* the internal trees.
|
|
402
428
|
*
|
|
429
|
+
* @public
|
|
403
430
|
* @param {String} name
|
|
404
431
|
* @param {Array.<String> keys
|
|
405
432
|
* @returns {Array.<PositionGroup>}
|
|
@@ -411,6 +438,13 @@ module.exports = (() => {
|
|
|
411
438
|
return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
|
|
412
439
|
}
|
|
413
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Returns all positions for the given portfolio.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
445
|
+
* @param {String} portfolio
|
|
446
|
+
* @return {Array.<Object>}
|
|
447
|
+
*/
|
|
414
448
|
getPositions(portfolio) {
|
|
415
449
|
return this._items.reduce((positions, item) => {
|
|
416
450
|
if (item.position.portfolio === portfolio) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const array = require('@barchart/common-js/lang/array'),
|
|
2
|
+
assert = require('@barchart/common-js/lang/assert'),
|
|
2
3
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
3
4
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
5
|
+
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
4
6
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
5
7
|
formatter = require('@barchart/common-js/lang/formatter'),
|
|
6
8
|
is = require('@barchart/common-js/lang/is'),
|
|
@@ -9,6 +11,8 @@ const assert = require('@barchart/common-js/lang/assert'),
|
|
|
9
11
|
module.exports = (() => {
|
|
10
12
|
'use strict';
|
|
11
13
|
|
|
14
|
+
let counter = 0;
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* A grouping of {@link PositionItem} instances. The group aggregates from across
|
|
14
18
|
* all the positions and performs currency translation, as necessary.
|
|
@@ -24,6 +28,7 @@ module.exports = (() => {
|
|
|
24
28
|
*/
|
|
25
29
|
class PositionGroup {
|
|
26
30
|
constructor(container, parent, items, currency, key, description, single) {
|
|
31
|
+
this._id = counter++;
|
|
27
32
|
this._container = container;
|
|
28
33
|
this._parent = parent || null;
|
|
29
34
|
|
|
@@ -41,10 +46,14 @@ module.exports = (() => {
|
|
|
41
46
|
this._showClosedPositions = false;
|
|
42
47
|
|
|
43
48
|
this._marketPercentChangeEvent = new Event(this);
|
|
44
|
-
this.
|
|
49
|
+
this._groupExcludedChangeEvent = new Event(this);
|
|
45
50
|
this._showClosedPositionsChangeEvent = new Event(this);
|
|
46
51
|
|
|
47
|
-
this.
|
|
52
|
+
this._disposeStack = new DisposableStack();
|
|
53
|
+
|
|
54
|
+
this._excludedItems = [ ];
|
|
55
|
+
this._excludedItemMap = { };
|
|
56
|
+
this._consideredItems = this._items;
|
|
48
57
|
|
|
49
58
|
this._dataFormat = { };
|
|
50
59
|
this._dataActual = { };
|
|
@@ -128,7 +137,7 @@ module.exports = (() => {
|
|
|
128
137
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
129
138
|
|
|
130
139
|
this._items.forEach((item) => {
|
|
131
|
-
item.registerQuoteChangeHandler((quote, sender) => {
|
|
140
|
+
this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
|
|
132
141
|
if (this._single) {
|
|
133
142
|
const precision = sender.position.instrument.currency.precision;
|
|
134
143
|
|
|
@@ -158,23 +167,33 @@ module.exports = (() => {
|
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
161
|
-
});
|
|
170
|
+
}));
|
|
162
171
|
|
|
163
172
|
if (this._single) {
|
|
164
|
-
item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
173
|
+
this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
165
174
|
this._dataActual.newsExists = exists;
|
|
166
175
|
this._dataFormat.newsExists = exists;
|
|
167
|
-
});
|
|
176
|
+
}));
|
|
168
177
|
|
|
169
|
-
item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
178
|
+
this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
170
179
|
this._dataFormat.fundamental = data;
|
|
171
|
-
});
|
|
180
|
+
}));
|
|
172
181
|
}
|
|
173
182
|
});
|
|
174
183
|
|
|
175
184
|
this.refresh();
|
|
176
185
|
}
|
|
177
186
|
|
|
187
|
+
/**
|
|
188
|
+
* A unique (and otherwise meaningless) idenfitifer for the group.
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
* @returns {Number}
|
|
192
|
+
*/
|
|
193
|
+
get id() {
|
|
194
|
+
return this._id;
|
|
195
|
+
}
|
|
196
|
+
|
|
178
197
|
/**
|
|
179
198
|
* The key of the group.
|
|
180
199
|
*
|
|
@@ -260,18 +279,23 @@ module.exports = (() => {
|
|
|
260
279
|
return this._excluded;
|
|
261
280
|
}
|
|
262
281
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Sets the list of items which are excluded from group aggregation calculations.
|
|
284
|
+
*
|
|
285
|
+
* @public
|
|
286
|
+
* @param {Array.<Object>} items
|
|
287
|
+
*/
|
|
288
|
+
setExcludedItems(items) {
|
|
289
|
+
this._excludedItems = items;
|
|
290
|
+
this._consideredItems = array.difference(this._items, this._excludedItems);
|
|
268
291
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
292
|
+
this._excludedItemMap = this._excludedItems.reduce((map, item) => {
|
|
293
|
+
const key = item.position.position;
|
|
272
294
|
|
|
273
|
-
|
|
295
|
+
map[key] = item;
|
|
296
|
+
}, { });
|
|
274
297
|
|
|
298
|
+
this.refresh();
|
|
275
299
|
}
|
|
276
300
|
|
|
277
301
|
/**
|
|
@@ -290,7 +314,7 @@ module.exports = (() => {
|
|
|
290
314
|
assert.argumentIsRequired(value, 'value', Boolean);
|
|
291
315
|
|
|
292
316
|
if (this._excluded !== value) {
|
|
293
|
-
this.
|
|
317
|
+
this._groupExcludedChangeEvent(this._excluded = value);
|
|
294
318
|
}
|
|
295
319
|
}
|
|
296
320
|
|
|
@@ -334,8 +358,27 @@ module.exports = (() => {
|
|
|
334
358
|
calculateMarketPercent(this, this._container.getForexQuotes(), true);
|
|
335
359
|
}
|
|
336
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Adds an observer for change in the market percentage of the group.
|
|
363
|
+
*
|
|
364
|
+
* @public
|
|
365
|
+
* @param {Function} handler
|
|
366
|
+
* @return {Disposable}
|
|
367
|
+
*/
|
|
337
368
|
registerMarketPercentChangeHandler(handler) {
|
|
338
|
-
this._marketPercentChangeEvent.register(handler);
|
|
369
|
+
return this._marketPercentChangeEvent.register(handler);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Adds an observer for changes to the exclusion of the group
|
|
374
|
+
* from higher level aggregations.
|
|
375
|
+
*
|
|
376
|
+
* @public
|
|
377
|
+
* @param {Function} handler
|
|
378
|
+
* @return {Disposable}
|
|
379
|
+
*/
|
|
380
|
+
registerGroupExcludedChangeHandler(handler) {
|
|
381
|
+
return this._groupExcludedChangeEvent.register(handler);
|
|
339
382
|
}
|
|
340
383
|
|
|
341
384
|
toString() {
|
|
@@ -381,7 +424,7 @@ module.exports = (() => {
|
|
|
381
424
|
|
|
382
425
|
const currency = group.currency;
|
|
383
426
|
|
|
384
|
-
const items = group.
|
|
427
|
+
const items = group._consideredItems;
|
|
385
428
|
|
|
386
429
|
group._bypassCurrencyTranslation = items.every(item => item.currency === currency);
|
|
387
430
|
|
|
@@ -449,11 +492,16 @@ module.exports = (() => {
|
|
|
449
492
|
}
|
|
450
493
|
|
|
451
494
|
const parent = group._parent;
|
|
495
|
+
const currency = group.currency;
|
|
452
496
|
|
|
453
497
|
const actual = group._dataActual;
|
|
454
498
|
const format = group._dataFormat;
|
|
455
499
|
|
|
456
|
-
const
|
|
500
|
+
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
501
|
+
|
|
502
|
+
if (!refresh && group._excludedItemMap.hasOwnProperty(item.position.position)) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
457
505
|
|
|
458
506
|
const translate = (item, value) => {
|
|
459
507
|
let translated;
|
|
@@ -467,12 +515,10 @@ module.exports = (() => {
|
|
|
467
515
|
return translated;
|
|
468
516
|
};
|
|
469
517
|
|
|
470
|
-
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
471
|
-
|
|
472
518
|
let updates;
|
|
473
519
|
|
|
474
520
|
if (refresh) {
|
|
475
|
-
const items = group.
|
|
521
|
+
const items = group._consideredItems;
|
|
476
522
|
|
|
477
523
|
updates = items.reduce((updates, item) => {
|
|
478
524
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
@@ -487,7 +533,6 @@ module.exports = (() => {
|
|
|
487
533
|
unrealized: Decimal.ZERO,
|
|
488
534
|
unrealizedToday: Decimal.ZERO,
|
|
489
535
|
summaryTotalCurrent: Decimal.ZERO
|
|
490
|
-
|
|
491
536
|
});
|
|
492
537
|
} else {
|
|
493
538
|
updates = {
|
|
@@ -196,9 +196,10 @@ module.exports = (() => {
|
|
|
196
196
|
*
|
|
197
197
|
* @public
|
|
198
198
|
* @param {Function} handler
|
|
199
|
+
* @returns {Disposable}
|
|
199
200
|
*/
|
|
200
201
|
registerQuoteChangeHandler(handler) {
|
|
201
|
-
this._quoteChangedEvent.register(handler);
|
|
202
|
+
return this._quoteChangedEvent.register(handler);
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
/**
|
|
@@ -206,9 +207,10 @@ module.exports = (() => {
|
|
|
206
207
|
*
|
|
207
208
|
* @public
|
|
208
209
|
* @param {Function} handler
|
|
210
|
+
* @returns {Disposable}
|
|
209
211
|
*/
|
|
210
212
|
registerFundamentalDataChangeHandler(handler) {
|
|
211
|
-
this._fundamentalDataChangeEvent.register(handler);
|
|
213
|
+
return this._fundamentalDataChangeEvent.register(handler);
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
/**
|
|
@@ -216,9 +218,10 @@ module.exports = (() => {
|
|
|
216
218
|
*
|
|
217
219
|
* @public
|
|
218
220
|
* @param {Function} handler
|
|
221
|
+
* @returns {Disposable}
|
|
219
222
|
*/
|
|
220
223
|
registerNewsExistsChangeHandler(handler) {
|
|
221
|
-
this._newsExistsChangedEvent.register(handler);
|
|
224
|
+
return this._newsExistsChangedEvent.register(handler);
|
|
222
225
|
}
|
|
223
226
|
|
|
224
227
|
toString() {
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -116,7 +116,7 @@ module.exports = (() => {
|
|
|
116
116
|
return InstrumentType;
|
|
117
117
|
})();
|
|
118
118
|
|
|
119
|
-
},{"@barchart/common-js/lang/Enum":
|
|
119
|
+
},{"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/assert":21}],2:[function(require,module,exports){
|
|
120
120
|
const array = require('@barchart/common-js/lang/array'),
|
|
121
121
|
assert = require('@barchart/common-js/lang/assert'),
|
|
122
122
|
Day = require('@barchart/common-js/lang/Day'),
|
|
@@ -373,7 +373,7 @@ module.exports = (() => {
|
|
|
373
373
|
return PositionSummaryFrame;
|
|
374
374
|
})();
|
|
375
375
|
|
|
376
|
-
},{"@barchart/common-js/lang/Day":
|
|
376
|
+
},{"@barchart/common-js/lang/Day":15,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],3:[function(require,module,exports){
|
|
377
377
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
378
378
|
Enum = require('@barchart/common-js/lang/Enum');
|
|
379
379
|
|
|
@@ -713,13 +713,14 @@ module.exports = (() => {
|
|
|
713
713
|
return TransactionType;
|
|
714
714
|
})();
|
|
715
715
|
|
|
716
|
-
},{"@barchart/common-js/lang/Enum":
|
|
716
|
+
},{"@barchart/common-js/lang/Enum":18,"@barchart/common-js/lang/assert":21}],4:[function(require,module,exports){
|
|
717
717
|
const array = require('@barchart/common-js/lang/array'),
|
|
718
718
|
assert = require('@barchart/common-js/lang/assert'),
|
|
719
719
|
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
720
720
|
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
721
721
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
722
722
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
723
|
+
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
723
724
|
is = require('@barchart/common-js/lang/is'),
|
|
724
725
|
Rate = require('@barchart/common-js/lang/Rate'),
|
|
725
726
|
Tree = require('@barchart/common-js/collections/Tree');
|
|
@@ -763,6 +764,18 @@ module.exports = (() => {
|
|
|
763
764
|
const currentSummaryFrame = PositionSummaryFrame.YTD;
|
|
764
765
|
const currentSummaryRange = array.last(currentSummaryFrame.getRecentRanges(0));
|
|
765
766
|
|
|
767
|
+
this._groupBindings = { };
|
|
768
|
+
|
|
769
|
+
const addGroupBinding = (group, dispoable) => {
|
|
770
|
+
const id = group.id;
|
|
771
|
+
|
|
772
|
+
if (!this._groupBindings.hasOwnProperty(id)) {
|
|
773
|
+
this._groupBindings[id] = new DisposableStack();
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
this._groupBindings[id].push(dispoable);
|
|
777
|
+
};
|
|
778
|
+
|
|
766
779
|
this._portfolios = portfolios.reduce((map, portfolio) => {
|
|
767
780
|
map[portfolio.portfolio] = portfolio;
|
|
768
781
|
|
|
@@ -931,7 +944,19 @@ module.exports = (() => {
|
|
|
931
944
|
compositeGroups.sort(builder.toComparator());
|
|
932
945
|
|
|
933
946
|
const initializeGroupObservers = (group, groupTree) => {
|
|
934
|
-
|
|
947
|
+
addGroupBinding(group, group.registerGroupExcludedChangeHandler((excluded, sender) => {
|
|
948
|
+
groupTree.climb((parentGroup, parentTree) => {
|
|
949
|
+
let excludedItems = [ ];
|
|
950
|
+
|
|
951
|
+
currentTree.walk((childGroup, childTree) => {
|
|
952
|
+
if (childGroup.excluded) {
|
|
953
|
+
excludedItems = excludedItems.concat(childGroup.items);
|
|
954
|
+
}
|
|
955
|
+
}, false, false);
|
|
956
|
+
|
|
957
|
+
parentGroup.setExcludedItems(array.unique(excludedItems));
|
|
958
|
+
}, false);
|
|
959
|
+
}));
|
|
935
960
|
};
|
|
936
961
|
|
|
937
962
|
compositeGroups.forEach((group) => {
|
|
@@ -939,9 +964,9 @@ module.exports = (() => {
|
|
|
939
964
|
|
|
940
965
|
initializeGroupObservers(group, childTree);
|
|
941
966
|
|
|
942
|
-
group.registerMarketPercentChangeHandler(() => {
|
|
967
|
+
addGroupBinding(group, group.registerMarketPercentChangeHandler(() => {
|
|
943
968
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
944
|
-
});
|
|
969
|
+
}));
|
|
945
970
|
|
|
946
971
|
createGroups(childTree, group.items, array.dropLeft(levelDefinitions));
|
|
947
972
|
});
|
|
@@ -1101,6 +1126,7 @@ module.exports = (() => {
|
|
|
1101
1126
|
/**
|
|
1102
1127
|
* Returns a single level of grouping from one of the internal trees.
|
|
1103
1128
|
*
|
|
1129
|
+
* @public
|
|
1104
1130
|
* @param {String} name
|
|
1105
1131
|
* @param {Array.<String> keys
|
|
1106
1132
|
* @returns {PositionGroup}
|
|
@@ -1116,6 +1142,7 @@ module.exports = (() => {
|
|
|
1116
1142
|
* Returns all child groups from a level of grouping within one of
|
|
1117
1143
|
* the internal trees.
|
|
1118
1144
|
*
|
|
1145
|
+
* @public
|
|
1119
1146
|
* @param {String} name
|
|
1120
1147
|
* @param {Array.<String> keys
|
|
1121
1148
|
* @returns {Array.<PositionGroup>}
|
|
@@ -1127,6 +1154,13 @@ module.exports = (() => {
|
|
|
1127
1154
|
return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
|
|
1128
1155
|
}
|
|
1129
1156
|
|
|
1157
|
+
/**
|
|
1158
|
+
* Returns all positions for the given portfolio.
|
|
1159
|
+
*
|
|
1160
|
+
* @public
|
|
1161
|
+
* @param {String} portfolio
|
|
1162
|
+
* @return {Array.<Object>}
|
|
1163
|
+
*/
|
|
1130
1164
|
getPositions(portfolio) {
|
|
1131
1165
|
return this._items.reduce((positions, item) => {
|
|
1132
1166
|
if (item.position.portfolio === portfolio) {
|
|
@@ -1181,10 +1215,12 @@ module.exports = (() => {
|
|
|
1181
1215
|
return PositionContainer;
|
|
1182
1216
|
})();
|
|
1183
1217
|
|
|
1184
|
-
},{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionTreeDefinition":8,"@barchart/common-js/collections/Tree":
|
|
1185
|
-
const
|
|
1218
|
+
},{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionTreeDefinition":8,"@barchart/common-js/collections/Tree":10,"@barchart/common-js/collections/sorting/ComparatorBuilder":11,"@barchart/common-js/collections/sorting/comparators":12,"@barchart/common-js/collections/specialized/DisposableStack":13,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Rate":19,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],5:[function(require,module,exports){
|
|
1219
|
+
const array = require('@barchart/common-js/lang/array'),
|
|
1220
|
+
assert = require('@barchart/common-js/lang/assert'),
|
|
1186
1221
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
1187
1222
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
1223
|
+
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
1188
1224
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
1189
1225
|
formatter = require('@barchart/common-js/lang/formatter'),
|
|
1190
1226
|
is = require('@barchart/common-js/lang/is'),
|
|
@@ -1193,6 +1229,8 @@ const assert = require('@barchart/common-js/lang/assert'),
|
|
|
1193
1229
|
module.exports = (() => {
|
|
1194
1230
|
'use strict';
|
|
1195
1231
|
|
|
1232
|
+
let counter = 0;
|
|
1233
|
+
|
|
1196
1234
|
/**
|
|
1197
1235
|
* A grouping of {@link PositionItem} instances. The group aggregates from across
|
|
1198
1236
|
* all the positions and performs currency translation, as necessary.
|
|
@@ -1208,6 +1246,7 @@ module.exports = (() => {
|
|
|
1208
1246
|
*/
|
|
1209
1247
|
class PositionGroup {
|
|
1210
1248
|
constructor(container, parent, items, currency, key, description, single) {
|
|
1249
|
+
this._id = counter++;
|
|
1211
1250
|
this._container = container;
|
|
1212
1251
|
this._parent = parent || null;
|
|
1213
1252
|
|
|
@@ -1225,10 +1264,14 @@ module.exports = (() => {
|
|
|
1225
1264
|
this._showClosedPositions = false;
|
|
1226
1265
|
|
|
1227
1266
|
this._marketPercentChangeEvent = new Event(this);
|
|
1228
|
-
this.
|
|
1267
|
+
this._groupExcludedChangeEvent = new Event(this);
|
|
1229
1268
|
this._showClosedPositionsChangeEvent = new Event(this);
|
|
1230
1269
|
|
|
1231
|
-
this.
|
|
1270
|
+
this._disposeStack = new DisposableStack();
|
|
1271
|
+
|
|
1272
|
+
this._excludedItems = [ ];
|
|
1273
|
+
this._excludedItemMap = { };
|
|
1274
|
+
this._consideredItems = this._items;
|
|
1232
1275
|
|
|
1233
1276
|
this._dataFormat = { };
|
|
1234
1277
|
this._dataActual = { };
|
|
@@ -1312,7 +1355,7 @@ module.exports = (() => {
|
|
|
1312
1355
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
1313
1356
|
|
|
1314
1357
|
this._items.forEach((item) => {
|
|
1315
|
-
item.registerQuoteChangeHandler((quote, sender) => {
|
|
1358
|
+
this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
|
|
1316
1359
|
if (this._single) {
|
|
1317
1360
|
const precision = sender.position.instrument.currency.precision;
|
|
1318
1361
|
|
|
@@ -1342,23 +1385,33 @@ module.exports = (() => {
|
|
|
1342
1385
|
}
|
|
1343
1386
|
|
|
1344
1387
|
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
1345
|
-
});
|
|
1388
|
+
}));
|
|
1346
1389
|
|
|
1347
1390
|
if (this._single) {
|
|
1348
|
-
item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1391
|
+
this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1349
1392
|
this._dataActual.newsExists = exists;
|
|
1350
1393
|
this._dataFormat.newsExists = exists;
|
|
1351
|
-
});
|
|
1394
|
+
}));
|
|
1352
1395
|
|
|
1353
|
-
item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1396
|
+
this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1354
1397
|
this._dataFormat.fundamental = data;
|
|
1355
|
-
});
|
|
1398
|
+
}));
|
|
1356
1399
|
}
|
|
1357
1400
|
});
|
|
1358
1401
|
|
|
1359
1402
|
this.refresh();
|
|
1360
1403
|
}
|
|
1361
1404
|
|
|
1405
|
+
/**
|
|
1406
|
+
* A unique (and otherwise meaningless) idenfitifer for the group.
|
|
1407
|
+
*
|
|
1408
|
+
* @public
|
|
1409
|
+
* @returns {Number}
|
|
1410
|
+
*/
|
|
1411
|
+
get id() {
|
|
1412
|
+
return this._id;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1362
1415
|
/**
|
|
1363
1416
|
* The key of the group.
|
|
1364
1417
|
*
|
|
@@ -1444,18 +1497,23 @@ module.exports = (() => {
|
|
|
1444
1497
|
return this._excluded;
|
|
1445
1498
|
}
|
|
1446
1499
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1500
|
+
/**
|
|
1501
|
+
* Sets the list of items which are excluded from group aggregation calculations.
|
|
1502
|
+
*
|
|
1503
|
+
* @public
|
|
1504
|
+
* @param {Array.<Object>} items
|
|
1505
|
+
*/
|
|
1506
|
+
setExcludedItems(items) {
|
|
1507
|
+
this._excludedItems = items;
|
|
1508
|
+
this._consideredItems = array.difference(this._items, this._excludedItems);
|
|
1452
1509
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
}
|
|
1510
|
+
this._excludedItemMap = this._excludedItems.reduce((map, item) => {
|
|
1511
|
+
const key = item.position.position;
|
|
1456
1512
|
|
|
1457
|
-
|
|
1513
|
+
map[key] = item;
|
|
1514
|
+
}, { });
|
|
1458
1515
|
|
|
1516
|
+
this.refresh();
|
|
1459
1517
|
}
|
|
1460
1518
|
|
|
1461
1519
|
/**
|
|
@@ -1474,7 +1532,7 @@ module.exports = (() => {
|
|
|
1474
1532
|
assert.argumentIsRequired(value, 'value', Boolean);
|
|
1475
1533
|
|
|
1476
1534
|
if (this._excluded !== value) {
|
|
1477
|
-
this.
|
|
1535
|
+
this._groupExcludedChangeEvent(this._excluded = value);
|
|
1478
1536
|
}
|
|
1479
1537
|
}
|
|
1480
1538
|
|
|
@@ -1518,8 +1576,27 @@ module.exports = (() => {
|
|
|
1518
1576
|
calculateMarketPercent(this, this._container.getForexQuotes(), true);
|
|
1519
1577
|
}
|
|
1520
1578
|
|
|
1579
|
+
/**
|
|
1580
|
+
* Adds an observer for change in the market percentage of the group.
|
|
1581
|
+
*
|
|
1582
|
+
* @public
|
|
1583
|
+
* @param {Function} handler
|
|
1584
|
+
* @return {Disposable}
|
|
1585
|
+
*/
|
|
1521
1586
|
registerMarketPercentChangeHandler(handler) {
|
|
1522
|
-
this._marketPercentChangeEvent.register(handler);
|
|
1587
|
+
return this._marketPercentChangeEvent.register(handler);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Adds an observer for changes to the exclusion of the group
|
|
1592
|
+
* from higher level aggregations.
|
|
1593
|
+
*
|
|
1594
|
+
* @public
|
|
1595
|
+
* @param {Function} handler
|
|
1596
|
+
* @return {Disposable}
|
|
1597
|
+
*/
|
|
1598
|
+
registerGroupExcludedChangeHandler(handler) {
|
|
1599
|
+
return this._groupExcludedChangeEvent.register(handler);
|
|
1523
1600
|
}
|
|
1524
1601
|
|
|
1525
1602
|
toString() {
|
|
@@ -1565,7 +1642,7 @@ module.exports = (() => {
|
|
|
1565
1642
|
|
|
1566
1643
|
const currency = group.currency;
|
|
1567
1644
|
|
|
1568
|
-
const items = group.
|
|
1645
|
+
const items = group._consideredItems;
|
|
1569
1646
|
|
|
1570
1647
|
group._bypassCurrencyTranslation = items.every(item => item.currency === currency);
|
|
1571
1648
|
|
|
@@ -1633,11 +1710,16 @@ module.exports = (() => {
|
|
|
1633
1710
|
}
|
|
1634
1711
|
|
|
1635
1712
|
const parent = group._parent;
|
|
1713
|
+
const currency = group.currency;
|
|
1636
1714
|
|
|
1637
1715
|
const actual = group._dataActual;
|
|
1638
1716
|
const format = group._dataFormat;
|
|
1639
1717
|
|
|
1640
|
-
const
|
|
1718
|
+
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
1719
|
+
|
|
1720
|
+
if (!refresh && group._excludedItemMap.hasOwnProperty(item.position.position)) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1641
1723
|
|
|
1642
1724
|
const translate = (item, value) => {
|
|
1643
1725
|
let translated;
|
|
@@ -1651,12 +1733,10 @@ module.exports = (() => {
|
|
|
1651
1733
|
return translated;
|
|
1652
1734
|
};
|
|
1653
1735
|
|
|
1654
|
-
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
1655
|
-
|
|
1656
1736
|
let updates;
|
|
1657
1737
|
|
|
1658
1738
|
if (refresh) {
|
|
1659
|
-
const items = group.
|
|
1739
|
+
const items = group._consideredItems;
|
|
1660
1740
|
|
|
1661
1741
|
updates = items.reduce((updates, item) => {
|
|
1662
1742
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
@@ -1671,7 +1751,6 @@ module.exports = (() => {
|
|
|
1671
1751
|
unrealized: Decimal.ZERO,
|
|
1672
1752
|
unrealizedToday: Decimal.ZERO,
|
|
1673
1753
|
summaryTotalCurrent: Decimal.ZERO
|
|
1674
|
-
|
|
1675
1754
|
});
|
|
1676
1755
|
} else {
|
|
1677
1756
|
updates = {
|
|
@@ -1783,7 +1862,7 @@ module.exports = (() => {
|
|
|
1783
1862
|
return PositionGroup;
|
|
1784
1863
|
})();
|
|
1785
1864
|
|
|
1786
|
-
},{"@barchart/common-js/lang/Currency":
|
|
1865
|
+
},{"@barchart/common-js/collections/specialized/DisposableStack":13,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/Rate":19,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/formatter":22,"@barchart/common-js/lang/is":23,"@barchart/common-js/messaging/Event":25}],6:[function(require,module,exports){
|
|
1787
1866
|
const array = require('@barchart/common-js/lang/array'),
|
|
1788
1867
|
assert = require('@barchart/common-js/lang/assert'),
|
|
1789
1868
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
@@ -1982,9 +2061,10 @@ module.exports = (() => {
|
|
|
1982
2061
|
*
|
|
1983
2062
|
* @public
|
|
1984
2063
|
* @param {Function} handler
|
|
2064
|
+
* @returns {Disposable}
|
|
1985
2065
|
*/
|
|
1986
2066
|
registerQuoteChangeHandler(handler) {
|
|
1987
|
-
this._quoteChangedEvent.register(handler);
|
|
2067
|
+
return this._quoteChangedEvent.register(handler);
|
|
1988
2068
|
}
|
|
1989
2069
|
|
|
1990
2070
|
/**
|
|
@@ -1992,9 +2072,10 @@ module.exports = (() => {
|
|
|
1992
2072
|
*
|
|
1993
2073
|
* @public
|
|
1994
2074
|
* @param {Function} handler
|
|
2075
|
+
* @returns {Disposable}
|
|
1995
2076
|
*/
|
|
1996
2077
|
registerFundamentalDataChangeHandler(handler) {
|
|
1997
|
-
this._fundamentalDataChangeEvent.register(handler);
|
|
2078
|
+
return this._fundamentalDataChangeEvent.register(handler);
|
|
1998
2079
|
}
|
|
1999
2080
|
|
|
2000
2081
|
/**
|
|
@@ -2002,9 +2083,10 @@ module.exports = (() => {
|
|
|
2002
2083
|
*
|
|
2003
2084
|
* @public
|
|
2004
2085
|
* @param {Function} handler
|
|
2086
|
+
* @returns {Disposable}
|
|
2005
2087
|
*/
|
|
2006
2088
|
registerNewsExistsChangeHandler(handler) {
|
|
2007
|
-
this._newsExistsChangedEvent.register(handler);
|
|
2089
|
+
return this._newsExistsChangedEvent.register(handler);
|
|
2008
2090
|
}
|
|
2009
2091
|
|
|
2010
2092
|
toString() {
|
|
@@ -2149,7 +2231,7 @@ module.exports = (() => {
|
|
|
2149
2231
|
return PositionItem;
|
|
2150
2232
|
})();
|
|
2151
2233
|
|
|
2152
|
-
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":
|
|
2234
|
+
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16,"@barchart/common-js/lang/array":20,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23,"@barchart/common-js/messaging/Event":25}],7:[function(require,module,exports){
|
|
2153
2235
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2154
2236
|
is = require('@barchart/common-js/lang/is');
|
|
2155
2237
|
|
|
@@ -2305,7 +2387,7 @@ module.exports = (() => {
|
|
|
2305
2387
|
return PositionLevelDefinition;
|
|
2306
2388
|
})();
|
|
2307
2389
|
|
|
2308
|
-
},{"@barchart/common-js/lang/assert":
|
|
2390
|
+
},{"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],8:[function(require,module,exports){
|
|
2309
2391
|
const assert = require('@barchart/common-js/lang/assert');
|
|
2310
2392
|
|
|
2311
2393
|
const PositionLevelDefinition = require('./PositionLevelDefinition');
|
|
@@ -2359,7 +2441,139 @@ module.exports = (() => {
|
|
|
2359
2441
|
return PositionTreeDefinitions;
|
|
2360
2442
|
})();
|
|
2361
2443
|
|
|
2362
|
-
},{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":
|
|
2444
|
+
},{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":21}],9:[function(require,module,exports){
|
|
2445
|
+
'use strict';
|
|
2446
|
+
|
|
2447
|
+
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; }; }();
|
|
2448
|
+
|
|
2449
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2450
|
+
|
|
2451
|
+
var assert = require('./../lang/assert');
|
|
2452
|
+
|
|
2453
|
+
module.exports = function () {
|
|
2454
|
+
'use strict';
|
|
2455
|
+
|
|
2456
|
+
/**
|
|
2457
|
+
* A stack collection (supports LIFO operations).
|
|
2458
|
+
*
|
|
2459
|
+
* @public
|
|
2460
|
+
*/
|
|
2461
|
+
|
|
2462
|
+
var Stack = function () {
|
|
2463
|
+
function Stack() {
|
|
2464
|
+
_classCallCheck(this, Stack);
|
|
2465
|
+
|
|
2466
|
+
this._array = [];
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Adds an item to the stack.
|
|
2471
|
+
*
|
|
2472
|
+
* @public
|
|
2473
|
+
* @param {object} item
|
|
2474
|
+
* @returns {object} - The item added to the stack.
|
|
2475
|
+
*/
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
_createClass(Stack, [{
|
|
2479
|
+
key: 'push',
|
|
2480
|
+
value: function push(item) {
|
|
2481
|
+
this._array.unshift(item);
|
|
2482
|
+
|
|
2483
|
+
return item;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
/**
|
|
2487
|
+
* Removes and returns an item from the stack. Throws if the stack is empty.
|
|
2488
|
+
*
|
|
2489
|
+
* @public
|
|
2490
|
+
* @returns {object} - The removed from the stack.
|
|
2491
|
+
*/
|
|
2492
|
+
|
|
2493
|
+
}, {
|
|
2494
|
+
key: 'pop',
|
|
2495
|
+
value: function pop() {
|
|
2496
|
+
if (this.empty()) {
|
|
2497
|
+
throw new Error('Stack is empty');
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
return this._array.shift();
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* Returns the next item in the stack (without removing it). Throws if the stack is empty.
|
|
2505
|
+
*
|
|
2506
|
+
* @public
|
|
2507
|
+
* @returns {object} - The item added to the queue.
|
|
2508
|
+
*/
|
|
2509
|
+
|
|
2510
|
+
}, {
|
|
2511
|
+
key: 'peek',
|
|
2512
|
+
value: function peek() {
|
|
2513
|
+
if (this.empty()) {
|
|
2514
|
+
throw new Error('Stack is empty');
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
return this._array[0];
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
/**
|
|
2521
|
+
* Returns true if the queue is empty; otherwise false.
|
|
2522
|
+
*
|
|
2523
|
+
* @public
|
|
2524
|
+
* @returns {boolean}
|
|
2525
|
+
*/
|
|
2526
|
+
|
|
2527
|
+
}, {
|
|
2528
|
+
key: 'empty',
|
|
2529
|
+
value: function empty() {
|
|
2530
|
+
return this._array.length === 0;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* Runs an action on each item in the stack.
|
|
2535
|
+
*
|
|
2536
|
+
* @public
|
|
2537
|
+
* @param {Function} action - The action to run.
|
|
2538
|
+
*/
|
|
2539
|
+
|
|
2540
|
+
}, {
|
|
2541
|
+
key: 'scan',
|
|
2542
|
+
value: function scan(action) {
|
|
2543
|
+
assert.argumentIsRequired(action, 'action', Function);
|
|
2544
|
+
|
|
2545
|
+
this._array.forEach(function (x) {
|
|
2546
|
+
return action(x);
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
/**
|
|
2551
|
+
* Outputs an array of the stacks's items; without affecting the
|
|
2552
|
+
* queue's internal state;
|
|
2553
|
+
*
|
|
2554
|
+
* @public
|
|
2555
|
+
* @returns {Array}
|
|
2556
|
+
*/
|
|
2557
|
+
|
|
2558
|
+
}, {
|
|
2559
|
+
key: 'toArray',
|
|
2560
|
+
value: function toArray() {
|
|
2561
|
+
return this._array.slice(0);
|
|
2562
|
+
}
|
|
2563
|
+
}, {
|
|
2564
|
+
key: 'toString',
|
|
2565
|
+
value: function toString() {
|
|
2566
|
+
return '[Stack]';
|
|
2567
|
+
}
|
|
2568
|
+
}]);
|
|
2569
|
+
|
|
2570
|
+
return Stack;
|
|
2571
|
+
}();
|
|
2572
|
+
|
|
2573
|
+
return Stack;
|
|
2574
|
+
}();
|
|
2575
|
+
|
|
2576
|
+
},{"./../lang/assert":21}],10:[function(require,module,exports){
|
|
2363
2577
|
'use strict';
|
|
2364
2578
|
|
|
2365
2579
|
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; }; }();
|
|
@@ -2668,7 +2882,7 @@ module.exports = function () {
|
|
|
2668
2882
|
return Tree;
|
|
2669
2883
|
}();
|
|
2670
2884
|
|
|
2671
|
-
},{"./../lang/is":
|
|
2885
|
+
},{"./../lang/is":23}],11:[function(require,module,exports){
|
|
2672
2886
|
'use strict';
|
|
2673
2887
|
|
|
2674
2888
|
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; }; }();
|
|
@@ -2812,7 +3026,7 @@ module.exports = function () {
|
|
|
2812
3026
|
return ComparatorBuilder;
|
|
2813
3027
|
}();
|
|
2814
3028
|
|
|
2815
|
-
},{"./../../lang/assert":
|
|
3029
|
+
},{"./../../lang/assert":21,"./comparators":12}],12:[function(require,module,exports){
|
|
2816
3030
|
'use strict';
|
|
2817
3031
|
|
|
2818
3032
|
var assert = require('./../../lang/assert');
|
|
@@ -2887,7 +3101,115 @@ module.exports = function () {
|
|
|
2887
3101
|
};
|
|
2888
3102
|
}();
|
|
2889
3103
|
|
|
2890
|
-
},{"./../../lang/assert":
|
|
3104
|
+
},{"./../../lang/assert":21}],13:[function(require,module,exports){
|
|
3105
|
+
'use strict';
|
|
3106
|
+
|
|
3107
|
+
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; }; }();
|
|
3108
|
+
|
|
3109
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3110
|
+
|
|
3111
|
+
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; }
|
|
3112
|
+
|
|
3113
|
+
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; }
|
|
3114
|
+
|
|
3115
|
+
var Stack = require('./../Stack');
|
|
3116
|
+
|
|
3117
|
+
var assert = require('./../../lang/assert'),
|
|
3118
|
+
Disposable = require('./../../lang/Disposable'),
|
|
3119
|
+
is = require('./../../lang/is');
|
|
3120
|
+
|
|
3121
|
+
module.exports = function () {
|
|
3122
|
+
'use strict';
|
|
3123
|
+
|
|
3124
|
+
/**
|
|
3125
|
+
* A stack of {@link Disposable} instances which itself inherits {@Disposable}.
|
|
3126
|
+
* When {@link DisposableStack#dispose} is called, then each item in the collection
|
|
3127
|
+
* is disposed in order.
|
|
3128
|
+
*
|
|
3129
|
+
* @public
|
|
3130
|
+
* @extends {Disposable}
|
|
3131
|
+
*/
|
|
3132
|
+
|
|
3133
|
+
var DisposableStack = function (_Disposable) {
|
|
3134
|
+
_inherits(DisposableStack, _Disposable);
|
|
3135
|
+
|
|
3136
|
+
function DisposableStack() {
|
|
3137
|
+
_classCallCheck(this, DisposableStack);
|
|
3138
|
+
|
|
3139
|
+
var _this = _possibleConstructorReturn(this, (DisposableStack.__proto__ || Object.getPrototypeOf(DisposableStack)).call(this));
|
|
3140
|
+
|
|
3141
|
+
_this._stack = new Stack();
|
|
3142
|
+
return _this;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
/**
|
|
3146
|
+
* Adds a new {@link Disposable} instance to the stack.
|
|
3147
|
+
*
|
|
3148
|
+
* @public
|
|
3149
|
+
* @param {Disposable} disposable - The item to add.
|
|
3150
|
+
*/
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
_createClass(DisposableStack, [{
|
|
3154
|
+
key: 'push',
|
|
3155
|
+
value: function push(disposable) {
|
|
3156
|
+
assert.argumentIsRequired(disposable, 'disposable', Disposable, 'Disposable');
|
|
3157
|
+
|
|
3158
|
+
if (this.getIsDisposed()) {
|
|
3159
|
+
throw new Error('Unable to push item onto DisposableStack because it has been disposed.');
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
this._stack.push(disposable);
|
|
3163
|
+
}
|
|
3164
|
+
}, {
|
|
3165
|
+
key: '_onDispose',
|
|
3166
|
+
value: function _onDispose() {
|
|
3167
|
+
while (!this._stack.empty()) {
|
|
3168
|
+
this._stack.pop().dispose();
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
}], [{
|
|
3172
|
+
key: 'fromArray',
|
|
3173
|
+
value: function fromArray(bindings) {
|
|
3174
|
+
assert.argumentIsArray(bindings, 'bindings', Disposable, 'Disposable');
|
|
3175
|
+
|
|
3176
|
+
var returnRef = new DisposableStack();
|
|
3177
|
+
|
|
3178
|
+
for (var i = 0; i < bindings.length; i++) {
|
|
3179
|
+
returnRef.push(bindings[i]);
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
return returnRef;
|
|
3183
|
+
}
|
|
3184
|
+
}, {
|
|
3185
|
+
key: 'pushPromise',
|
|
3186
|
+
value: function pushPromise(stack, promise) {
|
|
3187
|
+
assert.argumentIsRequired(stack, 'stack', DisposableStack, 'DisposableStack');
|
|
3188
|
+
assert.argumentIsRequired(promise, 'promise');
|
|
3189
|
+
|
|
3190
|
+
return promise.then(function (b) {
|
|
3191
|
+
var bindings = void 0;
|
|
3192
|
+
|
|
3193
|
+
if (is.array(b)) {
|
|
3194
|
+
bindings = b;
|
|
3195
|
+
} else {
|
|
3196
|
+
bindings = [b];
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
bindings.forEach(function (binding) {
|
|
3200
|
+
return stack.push(binding);
|
|
3201
|
+
});
|
|
3202
|
+
});
|
|
3203
|
+
}
|
|
3204
|
+
}]);
|
|
3205
|
+
|
|
3206
|
+
return DisposableStack;
|
|
3207
|
+
}(Disposable);
|
|
3208
|
+
|
|
3209
|
+
return DisposableStack;
|
|
3210
|
+
}();
|
|
3211
|
+
|
|
3212
|
+
},{"./../../lang/Disposable":17,"./../../lang/assert":21,"./../../lang/is":23,"./../Stack":9}],14:[function(require,module,exports){
|
|
2891
3213
|
'use strict';
|
|
2892
3214
|
|
|
2893
3215
|
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; }; }();
|
|
@@ -3030,7 +3352,7 @@ module.exports = function () {
|
|
|
3030
3352
|
return Currency;
|
|
3031
3353
|
}();
|
|
3032
3354
|
|
|
3033
|
-
},{"./Enum":
|
|
3355
|
+
},{"./Enum":18,"./assert":21,"./is":23}],15:[function(require,module,exports){
|
|
3034
3356
|
'use strict';
|
|
3035
3357
|
|
|
3036
3358
|
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; }; }();
|
|
@@ -3583,7 +3905,7 @@ module.exports = function () {
|
|
|
3583
3905
|
return Day;
|
|
3584
3906
|
}();
|
|
3585
3907
|
|
|
3586
|
-
},{"./../collections/sorting/ComparatorBuilder":
|
|
3908
|
+
},{"./../collections/sorting/ComparatorBuilder":11,"./../collections/sorting/comparators":12,"./assert":21,"./is":23}],16:[function(require,module,exports){
|
|
3587
3909
|
'use strict';
|
|
3588
3910
|
|
|
3589
3911
|
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; }; }();
|
|
@@ -4163,7 +4485,7 @@ module.exports = function () {
|
|
|
4163
4485
|
return Decimal;
|
|
4164
4486
|
}();
|
|
4165
4487
|
|
|
4166
|
-
},{"./Enum":
|
|
4488
|
+
},{"./Enum":18,"./assert":21,"./is":23,"big.js":26}],17:[function(require,module,exports){
|
|
4167
4489
|
'use strict';
|
|
4168
4490
|
|
|
4169
4491
|
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; }; }();
|
|
@@ -4312,7 +4634,7 @@ module.exports = function () {
|
|
|
4312
4634
|
return Disposable;
|
|
4313
4635
|
}();
|
|
4314
4636
|
|
|
4315
|
-
},{"./assert":
|
|
4637
|
+
},{"./assert":21}],18:[function(require,module,exports){
|
|
4316
4638
|
'use strict';
|
|
4317
4639
|
|
|
4318
4640
|
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; }; }();
|
|
@@ -4454,7 +4776,7 @@ module.exports = function () {
|
|
|
4454
4776
|
return Enum;
|
|
4455
4777
|
}();
|
|
4456
4778
|
|
|
4457
|
-
},{"./assert":
|
|
4779
|
+
},{"./assert":21}],19:[function(require,module,exports){
|
|
4458
4780
|
'use strict';
|
|
4459
4781
|
|
|
4460
4782
|
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; }; }();
|
|
@@ -4709,7 +5031,7 @@ module.exports = function () {
|
|
|
4709
5031
|
return Rate;
|
|
4710
5032
|
}();
|
|
4711
5033
|
|
|
4712
|
-
},{"./Currency":
|
|
5034
|
+
},{"./Currency":14,"./Decimal":16,"./assert":21,"./memoize":24}],20:[function(require,module,exports){
|
|
4713
5035
|
'use strict';
|
|
4714
5036
|
|
|
4715
5037
|
var assert = require('./assert'),
|
|
@@ -5090,7 +5412,7 @@ module.exports = function () {
|
|
|
5090
5412
|
};
|
|
5091
5413
|
}();
|
|
5092
5414
|
|
|
5093
|
-
},{"./assert":
|
|
5415
|
+
},{"./assert":21,"./is":23}],21:[function(require,module,exports){
|
|
5094
5416
|
'use strict';
|
|
5095
5417
|
|
|
5096
5418
|
var is = require('./is');
|
|
@@ -5238,7 +5560,7 @@ module.exports = function () {
|
|
|
5238
5560
|
};
|
|
5239
5561
|
}();
|
|
5240
5562
|
|
|
5241
|
-
},{"./is":
|
|
5563
|
+
},{"./is":23}],22:[function(require,module,exports){
|
|
5242
5564
|
'use strict';
|
|
5243
5565
|
|
|
5244
5566
|
module.exports = function () {
|
|
@@ -5303,7 +5625,7 @@ module.exports = function () {
|
|
|
5303
5625
|
};
|
|
5304
5626
|
}();
|
|
5305
5627
|
|
|
5306
|
-
},{}],
|
|
5628
|
+
},{}],23:[function(require,module,exports){
|
|
5307
5629
|
'use strict';
|
|
5308
5630
|
|
|
5309
5631
|
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; };
|
|
@@ -5526,7 +5848,7 @@ module.exports = function () {
|
|
|
5526
5848
|
};
|
|
5527
5849
|
}();
|
|
5528
5850
|
|
|
5529
|
-
},{}],
|
|
5851
|
+
},{}],24:[function(require,module,exports){
|
|
5530
5852
|
'use strict';
|
|
5531
5853
|
|
|
5532
5854
|
var assert = require('./assert'),
|
|
@@ -5599,7 +5921,7 @@ module.exports = function () {
|
|
|
5599
5921
|
};
|
|
5600
5922
|
}();
|
|
5601
5923
|
|
|
5602
|
-
},{"./assert":
|
|
5924
|
+
},{"./assert":21,"./is":23}],25:[function(require,module,exports){
|
|
5603
5925
|
'use strict';
|
|
5604
5926
|
|
|
5605
5927
|
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; }; }();
|
|
@@ -5771,7 +6093,7 @@ module.exports = function () {
|
|
|
5771
6093
|
return Event;
|
|
5772
6094
|
}();
|
|
5773
6095
|
|
|
5774
|
-
},{"./../lang/Disposable":
|
|
6096
|
+
},{"./../lang/Disposable":17,"./../lang/assert":21}],26:[function(require,module,exports){
|
|
5775
6097
|
/*
|
|
5776
6098
|
* big.js v5.0.3
|
|
5777
6099
|
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
|
|
@@ -6712,7 +7034,7 @@ module.exports = function () {
|
|
|
6712
7034
|
}
|
|
6713
7035
|
})(this);
|
|
6714
7036
|
|
|
6715
|
-
},{}],
|
|
7037
|
+
},{}],27:[function(require,module,exports){
|
|
6716
7038
|
const Day = require('@barchart/common-js/lang/Day'),
|
|
6717
7039
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
6718
7040
|
|
|
@@ -7069,7 +7391,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
7069
7391
|
});
|
|
7070
7392
|
});
|
|
7071
7393
|
|
|
7072
|
-
},{"./../../../lib/data/PositionSummaryFrame":2,"./../../../lib/data/TransactionType":3,"@barchart/common-js/lang/Day":
|
|
7394
|
+
},{"./../../../lib/data/PositionSummaryFrame":2,"./../../../lib/data/TransactionType":3,"@barchart/common-js/lang/Day":15,"@barchart/common-js/lang/Decimal":16}],28:[function(require,module,exports){
|
|
7073
7395
|
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
7074
7396
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
7075
7397
|
|
|
@@ -7178,4 +7500,4 @@ describe('When a position container data is gathered', () => {
|
|
|
7178
7500
|
});
|
|
7179
7501
|
});
|
|
7180
7502
|
|
|
7181
|
-
},{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":4,"./../../../lib/processing/definitions/PositionLevelDefinition":7,"./../../../lib/processing/definitions/PositionTreeDefinition":8,"@barchart/common-js/lang/Currency":
|
|
7503
|
+
},{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":4,"./../../../lib/processing/definitions/PositionLevelDefinition":7,"./../../../lib/processing/definitions/PositionTreeDefinition":8,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/Decimal":16}]},{},[27,28]);
|