@barchart/portfolio-api-common 1.0.142 → 1.0.146
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,21 @@ 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
|
+
if (parentGroup !== null) {
|
|
234
|
+
let excludedItems = [];
|
|
235
|
+
|
|
236
|
+
currentTree.walk((childGroup, childTree) => {
|
|
237
|
+
if (childGroup.excluded) {
|
|
238
|
+
excludedItems = excludedItems.concat(childGroup.items);
|
|
239
|
+
}
|
|
240
|
+
}, false, false);
|
|
241
|
+
|
|
242
|
+
parentGroup.setExcludedItems(array.unique(excludedItems));
|
|
243
|
+
}
|
|
244
|
+
}, false);
|
|
245
|
+
}));
|
|
219
246
|
};
|
|
220
247
|
|
|
221
248
|
compositeGroups.forEach((group) => {
|
|
@@ -223,9 +250,9 @@ module.exports = (() => {
|
|
|
223
250
|
|
|
224
251
|
initializeGroupObservers(group, childTree);
|
|
225
252
|
|
|
226
|
-
group.registerMarketPercentChangeHandler(() => {
|
|
253
|
+
addGroupBinding(group, group.registerMarketPercentChangeHandler(() => {
|
|
227
254
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
228
|
-
});
|
|
255
|
+
}));
|
|
229
256
|
|
|
230
257
|
createGroups(childTree, group.items, array.dropLeft(levelDefinitions));
|
|
231
258
|
});
|
|
@@ -385,6 +412,7 @@ module.exports = (() => {
|
|
|
385
412
|
/**
|
|
386
413
|
* Returns a single level of grouping from one of the internal trees.
|
|
387
414
|
*
|
|
415
|
+
* @public
|
|
388
416
|
* @param {String} name
|
|
389
417
|
* @param {Array.<String> keys
|
|
390
418
|
* @returns {PositionGroup}
|
|
@@ -400,6 +428,7 @@ module.exports = (() => {
|
|
|
400
428
|
* Returns all child groups from a level of grouping within one of
|
|
401
429
|
* the internal trees.
|
|
402
430
|
*
|
|
431
|
+
* @public
|
|
403
432
|
* @param {String} name
|
|
404
433
|
* @param {Array.<String> keys
|
|
405
434
|
* @returns {Array.<PositionGroup>}
|
|
@@ -411,6 +440,13 @@ module.exports = (() => {
|
|
|
411
440
|
return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
|
|
412
441
|
}
|
|
413
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Returns all positions for the given portfolio.
|
|
445
|
+
*
|
|
446
|
+
* @public
|
|
447
|
+
* @param {String} portfolio
|
|
448
|
+
* @return {Array.<Object>}
|
|
449
|
+
*/
|
|
414
450
|
getPositions(portfolio) {
|
|
415
451
|
return this._items.reduce((positions, item) => {
|
|
416
452
|
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,25 @@ module.exports = (() => {
|
|
|
260
279
|
return this._excluded;
|
|
261
280
|
}
|
|
262
281
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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);
|
|
266
291
|
|
|
267
|
-
|
|
292
|
+
this._excludedItemMap = this._excludedItems.reduce((map, item) => {
|
|
293
|
+
const key = item.position.position;
|
|
268
294
|
|
|
269
|
-
|
|
270
|
-
});
|
|
271
|
-
}
|
|
295
|
+
map[key] = item;
|
|
272
296
|
|
|
273
|
-
|
|
297
|
+
return map;
|
|
298
|
+
}, { });
|
|
274
299
|
|
|
300
|
+
this.refresh();
|
|
275
301
|
}
|
|
276
302
|
|
|
277
303
|
/**
|
|
@@ -290,7 +316,7 @@ module.exports = (() => {
|
|
|
290
316
|
assert.argumentIsRequired(value, 'value', Boolean);
|
|
291
317
|
|
|
292
318
|
if (this._excluded !== value) {
|
|
293
|
-
this.
|
|
319
|
+
this._groupExcludedChangeEvent.fire(this._excluded = value);
|
|
294
320
|
}
|
|
295
321
|
}
|
|
296
322
|
|
|
@@ -334,8 +360,27 @@ module.exports = (() => {
|
|
|
334
360
|
calculateMarketPercent(this, this._container.getForexQuotes(), true);
|
|
335
361
|
}
|
|
336
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Adds an observer for change in the market percentage of the group.
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
* @param {Function} handler
|
|
368
|
+
* @return {Disposable}
|
|
369
|
+
*/
|
|
337
370
|
registerMarketPercentChangeHandler(handler) {
|
|
338
|
-
this._marketPercentChangeEvent.register(handler);
|
|
371
|
+
return this._marketPercentChangeEvent.register(handler);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Adds an observer for changes to the exclusion of the group
|
|
376
|
+
* from higher level aggregations.
|
|
377
|
+
*
|
|
378
|
+
* @public
|
|
379
|
+
* @param {Function} handler
|
|
380
|
+
* @return {Disposable}
|
|
381
|
+
*/
|
|
382
|
+
registerGroupExcludedChangeHandler(handler) {
|
|
383
|
+
return this._groupExcludedChangeEvent.register(handler);
|
|
339
384
|
}
|
|
340
385
|
|
|
341
386
|
toString() {
|
|
@@ -381,7 +426,7 @@ module.exports = (() => {
|
|
|
381
426
|
|
|
382
427
|
const currency = group.currency;
|
|
383
428
|
|
|
384
|
-
const items = group.
|
|
429
|
+
const items = group._consideredItems;
|
|
385
430
|
|
|
386
431
|
group._bypassCurrencyTranslation = items.every(item => item.currency === currency);
|
|
387
432
|
|
|
@@ -449,11 +494,16 @@ module.exports = (() => {
|
|
|
449
494
|
}
|
|
450
495
|
|
|
451
496
|
const parent = group._parent;
|
|
497
|
+
const currency = group.currency;
|
|
452
498
|
|
|
453
499
|
const actual = group._dataActual;
|
|
454
500
|
const format = group._dataFormat;
|
|
455
501
|
|
|
456
|
-
const
|
|
502
|
+
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
503
|
+
|
|
504
|
+
if (!refresh && group._excludedItemMap.hasOwnProperty(item.position.position)) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
457
507
|
|
|
458
508
|
const translate = (item, value) => {
|
|
459
509
|
let translated;
|
|
@@ -467,12 +517,10 @@ module.exports = (() => {
|
|
|
467
517
|
return translated;
|
|
468
518
|
};
|
|
469
519
|
|
|
470
|
-
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
471
|
-
|
|
472
520
|
let updates;
|
|
473
521
|
|
|
474
522
|
if (refresh) {
|
|
475
|
-
const items = group.
|
|
523
|
+
const items = group._consideredItems;
|
|
476
524
|
|
|
477
525
|
updates = items.reduce((updates, item) => {
|
|
478
526
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
@@ -487,7 +535,6 @@ module.exports = (() => {
|
|
|
487
535
|
unrealized: Decimal.ZERO,
|
|
488
536
|
unrealizedToday: Decimal.ZERO,
|
|
489
537
|
summaryTotalCurrent: Decimal.ZERO
|
|
490
|
-
|
|
491
538
|
});
|
|
492
539
|
} else {
|
|
493
540
|
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,21 @@ 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
|
+
if (parentGroup !== null) {
|
|
950
|
+
let excludedItems = [];
|
|
951
|
+
|
|
952
|
+
currentTree.walk((childGroup, childTree) => {
|
|
953
|
+
if (childGroup.excluded) {
|
|
954
|
+
excludedItems = excludedItems.concat(childGroup.items);
|
|
955
|
+
}
|
|
956
|
+
}, false, false);
|
|
957
|
+
|
|
958
|
+
parentGroup.setExcludedItems(array.unique(excludedItems));
|
|
959
|
+
}
|
|
960
|
+
}, false);
|
|
961
|
+
}));
|
|
935
962
|
};
|
|
936
963
|
|
|
937
964
|
compositeGroups.forEach((group) => {
|
|
@@ -939,9 +966,9 @@ module.exports = (() => {
|
|
|
939
966
|
|
|
940
967
|
initializeGroupObservers(group, childTree);
|
|
941
968
|
|
|
942
|
-
group.registerMarketPercentChangeHandler(() => {
|
|
969
|
+
addGroupBinding(group, group.registerMarketPercentChangeHandler(() => {
|
|
943
970
|
currentTree.walk((childGroup) => childGroup.refreshMarketPercent());
|
|
944
|
-
});
|
|
971
|
+
}));
|
|
945
972
|
|
|
946
973
|
createGroups(childTree, group.items, array.dropLeft(levelDefinitions));
|
|
947
974
|
});
|
|
@@ -1101,6 +1128,7 @@ module.exports = (() => {
|
|
|
1101
1128
|
/**
|
|
1102
1129
|
* Returns a single level of grouping from one of the internal trees.
|
|
1103
1130
|
*
|
|
1131
|
+
* @public
|
|
1104
1132
|
* @param {String} name
|
|
1105
1133
|
* @param {Array.<String> keys
|
|
1106
1134
|
* @returns {PositionGroup}
|
|
@@ -1116,6 +1144,7 @@ module.exports = (() => {
|
|
|
1116
1144
|
* Returns all child groups from a level of grouping within one of
|
|
1117
1145
|
* the internal trees.
|
|
1118
1146
|
*
|
|
1147
|
+
* @public
|
|
1119
1148
|
* @param {String} name
|
|
1120
1149
|
* @param {Array.<String> keys
|
|
1121
1150
|
* @returns {Array.<PositionGroup>}
|
|
@@ -1127,6 +1156,13 @@ module.exports = (() => {
|
|
|
1127
1156
|
return findNode(this._trees[name], keys).getChildren().map(node => node.getValue());
|
|
1128
1157
|
}
|
|
1129
1158
|
|
|
1159
|
+
/**
|
|
1160
|
+
* Returns all positions for the given portfolio.
|
|
1161
|
+
*
|
|
1162
|
+
* @public
|
|
1163
|
+
* @param {String} portfolio
|
|
1164
|
+
* @return {Array.<Object>}
|
|
1165
|
+
*/
|
|
1130
1166
|
getPositions(portfolio) {
|
|
1131
1167
|
return this._items.reduce((positions, item) => {
|
|
1132
1168
|
if (item.position.portfolio === portfolio) {
|
|
@@ -1181,10 +1217,12 @@ module.exports = (() => {
|
|
|
1181
1217
|
return PositionContainer;
|
|
1182
1218
|
})();
|
|
1183
1219
|
|
|
1184
|
-
},{"./../data/PositionSummaryFrame":2,"./PositionGroup":5,"./PositionItem":6,"./definitions/PositionTreeDefinition":8,"@barchart/common-js/collections/Tree":
|
|
1185
|
-
const
|
|
1220
|
+
},{"./../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){
|
|
1221
|
+
const array = require('@barchart/common-js/lang/array'),
|
|
1222
|
+
assert = require('@barchart/common-js/lang/assert'),
|
|
1186
1223
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
1187
1224
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
1225
|
+
DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
|
|
1188
1226
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
1189
1227
|
formatter = require('@barchart/common-js/lang/formatter'),
|
|
1190
1228
|
is = require('@barchart/common-js/lang/is'),
|
|
@@ -1193,6 +1231,8 @@ const assert = require('@barchart/common-js/lang/assert'),
|
|
|
1193
1231
|
module.exports = (() => {
|
|
1194
1232
|
'use strict';
|
|
1195
1233
|
|
|
1234
|
+
let counter = 0;
|
|
1235
|
+
|
|
1196
1236
|
/**
|
|
1197
1237
|
* A grouping of {@link PositionItem} instances. The group aggregates from across
|
|
1198
1238
|
* all the positions and performs currency translation, as necessary.
|
|
@@ -1208,6 +1248,7 @@ module.exports = (() => {
|
|
|
1208
1248
|
*/
|
|
1209
1249
|
class PositionGroup {
|
|
1210
1250
|
constructor(container, parent, items, currency, key, description, single) {
|
|
1251
|
+
this._id = counter++;
|
|
1211
1252
|
this._container = container;
|
|
1212
1253
|
this._parent = parent || null;
|
|
1213
1254
|
|
|
@@ -1225,10 +1266,14 @@ module.exports = (() => {
|
|
|
1225
1266
|
this._showClosedPositions = false;
|
|
1226
1267
|
|
|
1227
1268
|
this._marketPercentChangeEvent = new Event(this);
|
|
1228
|
-
this.
|
|
1269
|
+
this._groupExcludedChangeEvent = new Event(this);
|
|
1229
1270
|
this._showClosedPositionsChangeEvent = new Event(this);
|
|
1230
1271
|
|
|
1231
|
-
this.
|
|
1272
|
+
this._disposeStack = new DisposableStack();
|
|
1273
|
+
|
|
1274
|
+
this._excludedItems = [ ];
|
|
1275
|
+
this._excludedItemMap = { };
|
|
1276
|
+
this._consideredItems = this._items;
|
|
1232
1277
|
|
|
1233
1278
|
this._dataFormat = { };
|
|
1234
1279
|
this._dataActual = { };
|
|
@@ -1312,7 +1357,7 @@ module.exports = (() => {
|
|
|
1312
1357
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
1313
1358
|
|
|
1314
1359
|
this._items.forEach((item) => {
|
|
1315
|
-
item.registerQuoteChangeHandler((quote, sender) => {
|
|
1360
|
+
this._disposeStack.push(item.registerQuoteChangeHandler((quote, sender) => {
|
|
1316
1361
|
if (this._single) {
|
|
1317
1362
|
const precision = sender.position.instrument.currency.precision;
|
|
1318
1363
|
|
|
@@ -1342,23 +1387,33 @@ module.exports = (() => {
|
|
|
1342
1387
|
}
|
|
1343
1388
|
|
|
1344
1389
|
calculatePriceData(this, this._container.getForexQuotes(), sender, false);
|
|
1345
|
-
});
|
|
1390
|
+
}));
|
|
1346
1391
|
|
|
1347
1392
|
if (this._single) {
|
|
1348
|
-
item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1393
|
+
this._disposeStack.push(item.registerNewsExistsChangeHandler((exists, sender) => {
|
|
1349
1394
|
this._dataActual.newsExists = exists;
|
|
1350
1395
|
this._dataFormat.newsExists = exists;
|
|
1351
|
-
});
|
|
1396
|
+
}));
|
|
1352
1397
|
|
|
1353
|
-
item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1398
|
+
this._disposeStack.push(item.registerFundamentalDataChangeHandler((data, sender) => {
|
|
1354
1399
|
this._dataFormat.fundamental = data;
|
|
1355
|
-
});
|
|
1400
|
+
}));
|
|
1356
1401
|
}
|
|
1357
1402
|
});
|
|
1358
1403
|
|
|
1359
1404
|
this.refresh();
|
|
1360
1405
|
}
|
|
1361
1406
|
|
|
1407
|
+
/**
|
|
1408
|
+
* A unique (and otherwise meaningless) idenfitifer for the group.
|
|
1409
|
+
*
|
|
1410
|
+
* @public
|
|
1411
|
+
* @returns {Number}
|
|
1412
|
+
*/
|
|
1413
|
+
get id() {
|
|
1414
|
+
return this._id;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1362
1417
|
/**
|
|
1363
1418
|
* The key of the group.
|
|
1364
1419
|
*
|
|
@@ -1444,18 +1499,25 @@ module.exports = (() => {
|
|
|
1444
1499
|
return this._excluded;
|
|
1445
1500
|
}
|
|
1446
1501
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1502
|
+
/**
|
|
1503
|
+
* Sets the list of items which are excluded from group aggregation calculations.
|
|
1504
|
+
*
|
|
1505
|
+
* @public
|
|
1506
|
+
* @param {Array.<Object>} items
|
|
1507
|
+
*/
|
|
1508
|
+
setExcludedItems(items) {
|
|
1509
|
+
this._excludedItems = items;
|
|
1510
|
+
this._consideredItems = array.difference(this._items, this._excludedItems);
|
|
1450
1511
|
|
|
1451
|
-
|
|
1512
|
+
this._excludedItemMap = this._excludedItems.reduce((map, item) => {
|
|
1513
|
+
const key = item.position.position;
|
|
1452
1514
|
|
|
1453
|
-
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1515
|
+
map[key] = item;
|
|
1456
1516
|
|
|
1457
|
-
|
|
1517
|
+
return map;
|
|
1518
|
+
}, { });
|
|
1458
1519
|
|
|
1520
|
+
this.refresh();
|
|
1459
1521
|
}
|
|
1460
1522
|
|
|
1461
1523
|
/**
|
|
@@ -1474,7 +1536,7 @@ module.exports = (() => {
|
|
|
1474
1536
|
assert.argumentIsRequired(value, 'value', Boolean);
|
|
1475
1537
|
|
|
1476
1538
|
if (this._excluded !== value) {
|
|
1477
|
-
this.
|
|
1539
|
+
this._groupExcludedChangeEvent.fire(this._excluded = value);
|
|
1478
1540
|
}
|
|
1479
1541
|
}
|
|
1480
1542
|
|
|
@@ -1518,8 +1580,27 @@ module.exports = (() => {
|
|
|
1518
1580
|
calculateMarketPercent(this, this._container.getForexQuotes(), true);
|
|
1519
1581
|
}
|
|
1520
1582
|
|
|
1583
|
+
/**
|
|
1584
|
+
* Adds an observer for change in the market percentage of the group.
|
|
1585
|
+
*
|
|
1586
|
+
* @public
|
|
1587
|
+
* @param {Function} handler
|
|
1588
|
+
* @return {Disposable}
|
|
1589
|
+
*/
|
|
1521
1590
|
registerMarketPercentChangeHandler(handler) {
|
|
1522
|
-
this._marketPercentChangeEvent.register(handler);
|
|
1591
|
+
return this._marketPercentChangeEvent.register(handler);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Adds an observer for changes to the exclusion of the group
|
|
1596
|
+
* from higher level aggregations.
|
|
1597
|
+
*
|
|
1598
|
+
* @public
|
|
1599
|
+
* @param {Function} handler
|
|
1600
|
+
* @return {Disposable}
|
|
1601
|
+
*/
|
|
1602
|
+
registerGroupExcludedChangeHandler(handler) {
|
|
1603
|
+
return this._groupExcludedChangeEvent.register(handler);
|
|
1523
1604
|
}
|
|
1524
1605
|
|
|
1525
1606
|
toString() {
|
|
@@ -1565,7 +1646,7 @@ module.exports = (() => {
|
|
|
1565
1646
|
|
|
1566
1647
|
const currency = group.currency;
|
|
1567
1648
|
|
|
1568
|
-
const items = group.
|
|
1649
|
+
const items = group._consideredItems;
|
|
1569
1650
|
|
|
1570
1651
|
group._bypassCurrencyTranslation = items.every(item => item.currency === currency);
|
|
1571
1652
|
|
|
@@ -1633,11 +1714,16 @@ module.exports = (() => {
|
|
|
1633
1714
|
}
|
|
1634
1715
|
|
|
1635
1716
|
const parent = group._parent;
|
|
1717
|
+
const currency = group.currency;
|
|
1636
1718
|
|
|
1637
1719
|
const actual = group._dataActual;
|
|
1638
1720
|
const format = group._dataFormat;
|
|
1639
1721
|
|
|
1640
|
-
const
|
|
1722
|
+
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
1723
|
+
|
|
1724
|
+
if (!refresh && group._excludedItemMap.hasOwnProperty(item.position.position)) {
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1641
1727
|
|
|
1642
1728
|
const translate = (item, value) => {
|
|
1643
1729
|
let translated;
|
|
@@ -1651,12 +1737,10 @@ module.exports = (() => {
|
|
|
1651
1737
|
return translated;
|
|
1652
1738
|
};
|
|
1653
1739
|
|
|
1654
|
-
const refresh = (is.boolean(forceRefresh) && forceRefresh) || (actual.market === null || actual.unrealizedToday === null || actual.total === null);
|
|
1655
|
-
|
|
1656
1740
|
let updates;
|
|
1657
1741
|
|
|
1658
1742
|
if (refresh) {
|
|
1659
|
-
const items = group.
|
|
1743
|
+
const items = group._consideredItems;
|
|
1660
1744
|
|
|
1661
1745
|
updates = items.reduce((updates, item) => {
|
|
1662
1746
|
updates.market = updates.market.add(translate(item, item.data.market));
|
|
@@ -1671,7 +1755,6 @@ module.exports = (() => {
|
|
|
1671
1755
|
unrealized: Decimal.ZERO,
|
|
1672
1756
|
unrealizedToday: Decimal.ZERO,
|
|
1673
1757
|
summaryTotalCurrent: Decimal.ZERO
|
|
1674
|
-
|
|
1675
1758
|
});
|
|
1676
1759
|
} else {
|
|
1677
1760
|
updates = {
|
|
@@ -1783,7 +1866,7 @@ module.exports = (() => {
|
|
|
1783
1866
|
return PositionGroup;
|
|
1784
1867
|
})();
|
|
1785
1868
|
|
|
1786
|
-
},{"@barchart/common-js/lang/Currency":
|
|
1869
|
+
},{"@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
1870
|
const array = require('@barchart/common-js/lang/array'),
|
|
1788
1871
|
assert = require('@barchart/common-js/lang/assert'),
|
|
1789
1872
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
@@ -1982,9 +2065,10 @@ module.exports = (() => {
|
|
|
1982
2065
|
*
|
|
1983
2066
|
* @public
|
|
1984
2067
|
* @param {Function} handler
|
|
2068
|
+
* @returns {Disposable}
|
|
1985
2069
|
*/
|
|
1986
2070
|
registerQuoteChangeHandler(handler) {
|
|
1987
|
-
this._quoteChangedEvent.register(handler);
|
|
2071
|
+
return this._quoteChangedEvent.register(handler);
|
|
1988
2072
|
}
|
|
1989
2073
|
|
|
1990
2074
|
/**
|
|
@@ -1992,9 +2076,10 @@ module.exports = (() => {
|
|
|
1992
2076
|
*
|
|
1993
2077
|
* @public
|
|
1994
2078
|
* @param {Function} handler
|
|
2079
|
+
* @returns {Disposable}
|
|
1995
2080
|
*/
|
|
1996
2081
|
registerFundamentalDataChangeHandler(handler) {
|
|
1997
|
-
this._fundamentalDataChangeEvent.register(handler);
|
|
2082
|
+
return this._fundamentalDataChangeEvent.register(handler);
|
|
1998
2083
|
}
|
|
1999
2084
|
|
|
2000
2085
|
/**
|
|
@@ -2002,9 +2087,10 @@ module.exports = (() => {
|
|
|
2002
2087
|
*
|
|
2003
2088
|
* @public
|
|
2004
2089
|
* @param {Function} handler
|
|
2090
|
+
* @returns {Disposable}
|
|
2005
2091
|
*/
|
|
2006
2092
|
registerNewsExistsChangeHandler(handler) {
|
|
2007
|
-
this._newsExistsChangedEvent.register(handler);
|
|
2093
|
+
return this._newsExistsChangedEvent.register(handler);
|
|
2008
2094
|
}
|
|
2009
2095
|
|
|
2010
2096
|
toString() {
|
|
@@ -2149,7 +2235,7 @@ module.exports = (() => {
|
|
|
2149
2235
|
return PositionItem;
|
|
2150
2236
|
})();
|
|
2151
2237
|
|
|
2152
|
-
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":
|
|
2238
|
+
},{"./../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
2239
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2154
2240
|
is = require('@barchart/common-js/lang/is');
|
|
2155
2241
|
|
|
@@ -2305,7 +2391,7 @@ module.exports = (() => {
|
|
|
2305
2391
|
return PositionLevelDefinition;
|
|
2306
2392
|
})();
|
|
2307
2393
|
|
|
2308
|
-
},{"@barchart/common-js/lang/assert":
|
|
2394
|
+
},{"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],8:[function(require,module,exports){
|
|
2309
2395
|
const assert = require('@barchart/common-js/lang/assert');
|
|
2310
2396
|
|
|
2311
2397
|
const PositionLevelDefinition = require('./PositionLevelDefinition');
|
|
@@ -2359,7 +2445,139 @@ module.exports = (() => {
|
|
|
2359
2445
|
return PositionTreeDefinitions;
|
|
2360
2446
|
})();
|
|
2361
2447
|
|
|
2362
|
-
},{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":
|
|
2448
|
+
},{"./PositionLevelDefinition":7,"@barchart/common-js/lang/assert":21}],9:[function(require,module,exports){
|
|
2449
|
+
'use strict';
|
|
2450
|
+
|
|
2451
|
+
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; }; }();
|
|
2452
|
+
|
|
2453
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2454
|
+
|
|
2455
|
+
var assert = require('./../lang/assert');
|
|
2456
|
+
|
|
2457
|
+
module.exports = function () {
|
|
2458
|
+
'use strict';
|
|
2459
|
+
|
|
2460
|
+
/**
|
|
2461
|
+
* A stack collection (supports LIFO operations).
|
|
2462
|
+
*
|
|
2463
|
+
* @public
|
|
2464
|
+
*/
|
|
2465
|
+
|
|
2466
|
+
var Stack = function () {
|
|
2467
|
+
function Stack() {
|
|
2468
|
+
_classCallCheck(this, Stack);
|
|
2469
|
+
|
|
2470
|
+
this._array = [];
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
/**
|
|
2474
|
+
* Adds an item to the stack.
|
|
2475
|
+
*
|
|
2476
|
+
* @public
|
|
2477
|
+
* @param {object} item
|
|
2478
|
+
* @returns {object} - The item added to the stack.
|
|
2479
|
+
*/
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
_createClass(Stack, [{
|
|
2483
|
+
key: 'push',
|
|
2484
|
+
value: function push(item) {
|
|
2485
|
+
this._array.unshift(item);
|
|
2486
|
+
|
|
2487
|
+
return item;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
/**
|
|
2491
|
+
* Removes and returns an item from the stack. Throws if the stack is empty.
|
|
2492
|
+
*
|
|
2493
|
+
* @public
|
|
2494
|
+
* @returns {object} - The removed from the stack.
|
|
2495
|
+
*/
|
|
2496
|
+
|
|
2497
|
+
}, {
|
|
2498
|
+
key: 'pop',
|
|
2499
|
+
value: function pop() {
|
|
2500
|
+
if (this.empty()) {
|
|
2501
|
+
throw new Error('Stack is empty');
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
return this._array.shift();
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
/**
|
|
2508
|
+
* Returns the next item in the stack (without removing it). Throws if the stack is empty.
|
|
2509
|
+
*
|
|
2510
|
+
* @public
|
|
2511
|
+
* @returns {object} - The item added to the queue.
|
|
2512
|
+
*/
|
|
2513
|
+
|
|
2514
|
+
}, {
|
|
2515
|
+
key: 'peek',
|
|
2516
|
+
value: function peek() {
|
|
2517
|
+
if (this.empty()) {
|
|
2518
|
+
throw new Error('Stack is empty');
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
return this._array[0];
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Returns true if the queue is empty; otherwise false.
|
|
2526
|
+
*
|
|
2527
|
+
* @public
|
|
2528
|
+
* @returns {boolean}
|
|
2529
|
+
*/
|
|
2530
|
+
|
|
2531
|
+
}, {
|
|
2532
|
+
key: 'empty',
|
|
2533
|
+
value: function empty() {
|
|
2534
|
+
return this._array.length === 0;
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
/**
|
|
2538
|
+
* Runs an action on each item in the stack.
|
|
2539
|
+
*
|
|
2540
|
+
* @public
|
|
2541
|
+
* @param {Function} action - The action to run.
|
|
2542
|
+
*/
|
|
2543
|
+
|
|
2544
|
+
}, {
|
|
2545
|
+
key: 'scan',
|
|
2546
|
+
value: function scan(action) {
|
|
2547
|
+
assert.argumentIsRequired(action, 'action', Function);
|
|
2548
|
+
|
|
2549
|
+
this._array.forEach(function (x) {
|
|
2550
|
+
return action(x);
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
/**
|
|
2555
|
+
* Outputs an array of the stacks's items; without affecting the
|
|
2556
|
+
* queue's internal state;
|
|
2557
|
+
*
|
|
2558
|
+
* @public
|
|
2559
|
+
* @returns {Array}
|
|
2560
|
+
*/
|
|
2561
|
+
|
|
2562
|
+
}, {
|
|
2563
|
+
key: 'toArray',
|
|
2564
|
+
value: function toArray() {
|
|
2565
|
+
return this._array.slice(0);
|
|
2566
|
+
}
|
|
2567
|
+
}, {
|
|
2568
|
+
key: 'toString',
|
|
2569
|
+
value: function toString() {
|
|
2570
|
+
return '[Stack]';
|
|
2571
|
+
}
|
|
2572
|
+
}]);
|
|
2573
|
+
|
|
2574
|
+
return Stack;
|
|
2575
|
+
}();
|
|
2576
|
+
|
|
2577
|
+
return Stack;
|
|
2578
|
+
}();
|
|
2579
|
+
|
|
2580
|
+
},{"./../lang/assert":21}],10:[function(require,module,exports){
|
|
2363
2581
|
'use strict';
|
|
2364
2582
|
|
|
2365
2583
|
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 +2886,7 @@ module.exports = function () {
|
|
|
2668
2886
|
return Tree;
|
|
2669
2887
|
}();
|
|
2670
2888
|
|
|
2671
|
-
},{"./../lang/is":
|
|
2889
|
+
},{"./../lang/is":23}],11:[function(require,module,exports){
|
|
2672
2890
|
'use strict';
|
|
2673
2891
|
|
|
2674
2892
|
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 +3030,7 @@ module.exports = function () {
|
|
|
2812
3030
|
return ComparatorBuilder;
|
|
2813
3031
|
}();
|
|
2814
3032
|
|
|
2815
|
-
},{"./../../lang/assert":
|
|
3033
|
+
},{"./../../lang/assert":21,"./comparators":12}],12:[function(require,module,exports){
|
|
2816
3034
|
'use strict';
|
|
2817
3035
|
|
|
2818
3036
|
var assert = require('./../../lang/assert');
|
|
@@ -2887,7 +3105,115 @@ module.exports = function () {
|
|
|
2887
3105
|
};
|
|
2888
3106
|
}();
|
|
2889
3107
|
|
|
2890
|
-
},{"./../../lang/assert":
|
|
3108
|
+
},{"./../../lang/assert":21}],13:[function(require,module,exports){
|
|
3109
|
+
'use strict';
|
|
3110
|
+
|
|
3111
|
+
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; }; }();
|
|
3112
|
+
|
|
3113
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3114
|
+
|
|
3115
|
+
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; }
|
|
3116
|
+
|
|
3117
|
+
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; }
|
|
3118
|
+
|
|
3119
|
+
var Stack = require('./../Stack');
|
|
3120
|
+
|
|
3121
|
+
var assert = require('./../../lang/assert'),
|
|
3122
|
+
Disposable = require('./../../lang/Disposable'),
|
|
3123
|
+
is = require('./../../lang/is');
|
|
3124
|
+
|
|
3125
|
+
module.exports = function () {
|
|
3126
|
+
'use strict';
|
|
3127
|
+
|
|
3128
|
+
/**
|
|
3129
|
+
* A stack of {@link Disposable} instances which itself inherits {@Disposable}.
|
|
3130
|
+
* When {@link DisposableStack#dispose} is called, then each item in the collection
|
|
3131
|
+
* is disposed in order.
|
|
3132
|
+
*
|
|
3133
|
+
* @public
|
|
3134
|
+
* @extends {Disposable}
|
|
3135
|
+
*/
|
|
3136
|
+
|
|
3137
|
+
var DisposableStack = function (_Disposable) {
|
|
3138
|
+
_inherits(DisposableStack, _Disposable);
|
|
3139
|
+
|
|
3140
|
+
function DisposableStack() {
|
|
3141
|
+
_classCallCheck(this, DisposableStack);
|
|
3142
|
+
|
|
3143
|
+
var _this = _possibleConstructorReturn(this, (DisposableStack.__proto__ || Object.getPrototypeOf(DisposableStack)).call(this));
|
|
3144
|
+
|
|
3145
|
+
_this._stack = new Stack();
|
|
3146
|
+
return _this;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* Adds a new {@link Disposable} instance to the stack.
|
|
3151
|
+
*
|
|
3152
|
+
* @public
|
|
3153
|
+
* @param {Disposable} disposable - The item to add.
|
|
3154
|
+
*/
|
|
3155
|
+
|
|
3156
|
+
|
|
3157
|
+
_createClass(DisposableStack, [{
|
|
3158
|
+
key: 'push',
|
|
3159
|
+
value: function push(disposable) {
|
|
3160
|
+
assert.argumentIsRequired(disposable, 'disposable', Disposable, 'Disposable');
|
|
3161
|
+
|
|
3162
|
+
if (this.getIsDisposed()) {
|
|
3163
|
+
throw new Error('Unable to push item onto DisposableStack because it has been disposed.');
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
this._stack.push(disposable);
|
|
3167
|
+
}
|
|
3168
|
+
}, {
|
|
3169
|
+
key: '_onDispose',
|
|
3170
|
+
value: function _onDispose() {
|
|
3171
|
+
while (!this._stack.empty()) {
|
|
3172
|
+
this._stack.pop().dispose();
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
}], [{
|
|
3176
|
+
key: 'fromArray',
|
|
3177
|
+
value: function fromArray(bindings) {
|
|
3178
|
+
assert.argumentIsArray(bindings, 'bindings', Disposable, 'Disposable');
|
|
3179
|
+
|
|
3180
|
+
var returnRef = new DisposableStack();
|
|
3181
|
+
|
|
3182
|
+
for (var i = 0; i < bindings.length; i++) {
|
|
3183
|
+
returnRef.push(bindings[i]);
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
return returnRef;
|
|
3187
|
+
}
|
|
3188
|
+
}, {
|
|
3189
|
+
key: 'pushPromise',
|
|
3190
|
+
value: function pushPromise(stack, promise) {
|
|
3191
|
+
assert.argumentIsRequired(stack, 'stack', DisposableStack, 'DisposableStack');
|
|
3192
|
+
assert.argumentIsRequired(promise, 'promise');
|
|
3193
|
+
|
|
3194
|
+
return promise.then(function (b) {
|
|
3195
|
+
var bindings = void 0;
|
|
3196
|
+
|
|
3197
|
+
if (is.array(b)) {
|
|
3198
|
+
bindings = b;
|
|
3199
|
+
} else {
|
|
3200
|
+
bindings = [b];
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
bindings.forEach(function (binding) {
|
|
3204
|
+
return stack.push(binding);
|
|
3205
|
+
});
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
}]);
|
|
3209
|
+
|
|
3210
|
+
return DisposableStack;
|
|
3211
|
+
}(Disposable);
|
|
3212
|
+
|
|
3213
|
+
return DisposableStack;
|
|
3214
|
+
}();
|
|
3215
|
+
|
|
3216
|
+
},{"./../../lang/Disposable":17,"./../../lang/assert":21,"./../../lang/is":23,"./../Stack":9}],14:[function(require,module,exports){
|
|
2891
3217
|
'use strict';
|
|
2892
3218
|
|
|
2893
3219
|
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 +3356,7 @@ module.exports = function () {
|
|
|
3030
3356
|
return Currency;
|
|
3031
3357
|
}();
|
|
3032
3358
|
|
|
3033
|
-
},{"./Enum":
|
|
3359
|
+
},{"./Enum":18,"./assert":21,"./is":23}],15:[function(require,module,exports){
|
|
3034
3360
|
'use strict';
|
|
3035
3361
|
|
|
3036
3362
|
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 +3909,7 @@ module.exports = function () {
|
|
|
3583
3909
|
return Day;
|
|
3584
3910
|
}();
|
|
3585
3911
|
|
|
3586
|
-
},{"./../collections/sorting/ComparatorBuilder":
|
|
3912
|
+
},{"./../collections/sorting/ComparatorBuilder":11,"./../collections/sorting/comparators":12,"./assert":21,"./is":23}],16:[function(require,module,exports){
|
|
3587
3913
|
'use strict';
|
|
3588
3914
|
|
|
3589
3915
|
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 +4489,7 @@ module.exports = function () {
|
|
|
4163
4489
|
return Decimal;
|
|
4164
4490
|
}();
|
|
4165
4491
|
|
|
4166
|
-
},{"./Enum":
|
|
4492
|
+
},{"./Enum":18,"./assert":21,"./is":23,"big.js":26}],17:[function(require,module,exports){
|
|
4167
4493
|
'use strict';
|
|
4168
4494
|
|
|
4169
4495
|
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 +4638,7 @@ module.exports = function () {
|
|
|
4312
4638
|
return Disposable;
|
|
4313
4639
|
}();
|
|
4314
4640
|
|
|
4315
|
-
},{"./assert":
|
|
4641
|
+
},{"./assert":21}],18:[function(require,module,exports){
|
|
4316
4642
|
'use strict';
|
|
4317
4643
|
|
|
4318
4644
|
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 +4780,7 @@ module.exports = function () {
|
|
|
4454
4780
|
return Enum;
|
|
4455
4781
|
}();
|
|
4456
4782
|
|
|
4457
|
-
},{"./assert":
|
|
4783
|
+
},{"./assert":21}],19:[function(require,module,exports){
|
|
4458
4784
|
'use strict';
|
|
4459
4785
|
|
|
4460
4786
|
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 +5035,7 @@ module.exports = function () {
|
|
|
4709
5035
|
return Rate;
|
|
4710
5036
|
}();
|
|
4711
5037
|
|
|
4712
|
-
},{"./Currency":
|
|
5038
|
+
},{"./Currency":14,"./Decimal":16,"./assert":21,"./memoize":24}],20:[function(require,module,exports){
|
|
4713
5039
|
'use strict';
|
|
4714
5040
|
|
|
4715
5041
|
var assert = require('./assert'),
|
|
@@ -5090,7 +5416,7 @@ module.exports = function () {
|
|
|
5090
5416
|
};
|
|
5091
5417
|
}();
|
|
5092
5418
|
|
|
5093
|
-
},{"./assert":
|
|
5419
|
+
},{"./assert":21,"./is":23}],21:[function(require,module,exports){
|
|
5094
5420
|
'use strict';
|
|
5095
5421
|
|
|
5096
5422
|
var is = require('./is');
|
|
@@ -5238,7 +5564,7 @@ module.exports = function () {
|
|
|
5238
5564
|
};
|
|
5239
5565
|
}();
|
|
5240
5566
|
|
|
5241
|
-
},{"./is":
|
|
5567
|
+
},{"./is":23}],22:[function(require,module,exports){
|
|
5242
5568
|
'use strict';
|
|
5243
5569
|
|
|
5244
5570
|
module.exports = function () {
|
|
@@ -5303,7 +5629,7 @@ module.exports = function () {
|
|
|
5303
5629
|
};
|
|
5304
5630
|
}();
|
|
5305
5631
|
|
|
5306
|
-
},{}],
|
|
5632
|
+
},{}],23:[function(require,module,exports){
|
|
5307
5633
|
'use strict';
|
|
5308
5634
|
|
|
5309
5635
|
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 +5852,7 @@ module.exports = function () {
|
|
|
5526
5852
|
};
|
|
5527
5853
|
}();
|
|
5528
5854
|
|
|
5529
|
-
},{}],
|
|
5855
|
+
},{}],24:[function(require,module,exports){
|
|
5530
5856
|
'use strict';
|
|
5531
5857
|
|
|
5532
5858
|
var assert = require('./assert'),
|
|
@@ -5599,7 +5925,7 @@ module.exports = function () {
|
|
|
5599
5925
|
};
|
|
5600
5926
|
}();
|
|
5601
5927
|
|
|
5602
|
-
},{"./assert":
|
|
5928
|
+
},{"./assert":21,"./is":23}],25:[function(require,module,exports){
|
|
5603
5929
|
'use strict';
|
|
5604
5930
|
|
|
5605
5931
|
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 +6097,7 @@ module.exports = function () {
|
|
|
5771
6097
|
return Event;
|
|
5772
6098
|
}();
|
|
5773
6099
|
|
|
5774
|
-
},{"./../lang/Disposable":
|
|
6100
|
+
},{"./../lang/Disposable":17,"./../lang/assert":21}],26:[function(require,module,exports){
|
|
5775
6101
|
/*
|
|
5776
6102
|
* big.js v5.0.3
|
|
5777
6103
|
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
|
|
@@ -6712,7 +7038,7 @@ module.exports = function () {
|
|
|
6712
7038
|
}
|
|
6713
7039
|
})(this);
|
|
6714
7040
|
|
|
6715
|
-
},{}],
|
|
7041
|
+
},{}],27:[function(require,module,exports){
|
|
6716
7042
|
const Day = require('@barchart/common-js/lang/Day'),
|
|
6717
7043
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
6718
7044
|
|
|
@@ -7069,7 +7395,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
7069
7395
|
});
|
|
7070
7396
|
});
|
|
7071
7397
|
|
|
7072
|
-
},{"./../../../lib/data/PositionSummaryFrame":2,"./../../../lib/data/TransactionType":3,"@barchart/common-js/lang/Day":
|
|
7398
|
+
},{"./../../../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
7399
|
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
7074
7400
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
7075
7401
|
|
|
@@ -7178,4 +7504,4 @@ describe('When a position container data is gathered', () => {
|
|
|
7178
7504
|
});
|
|
7179
7505
|
});
|
|
7180
7506
|
|
|
7181
|
-
},{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":4,"./../../../lib/processing/definitions/PositionLevelDefinition":7,"./../../../lib/processing/definitions/PositionTreeDefinition":8,"@barchart/common-js/lang/Currency":
|
|
7507
|
+
},{"./../../../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]);
|