@barchart/portfolio-api-common 1.0.47 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/formatters/TransactionFormatter.js +2 -2
- package/lib/processing/PositionContainer.js +38 -5
- package/lib/processing/PositionGroup.js +43 -19
- package/lib/processing/PositionGroupDefinition.js +6 -1
- package/lib/processing/PositionItem.js +13 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +336 -51
- package/test/specs/processing/PositionContainerSpec.js +8 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
2
|
is = require('@barchart/common-js/lang/is'),
|
|
3
|
-
|
|
3
|
+
formatter = require('@barchart/common-js/lang/formatter');
|
|
4
4
|
|
|
5
5
|
const TransactionType = require('./../data/TransactionType');
|
|
6
6
|
|
|
@@ -51,7 +51,7 @@ module.exports = (() => {
|
|
|
51
51
|
if (!is.undefined(formattedTransaction[key]) && is.fn(formattedTransaction[key].toFloat)) {
|
|
52
52
|
const precision = transaction.instrument.currency.precision;
|
|
53
53
|
|
|
54
|
-
formattedTransaction[key] =
|
|
54
|
+
formattedTransaction[key] = formatter.numberToString(formattedTransaction[key].toFloat(), precision, ',');
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
const array = require('@barchart/common-js/lang/array'),
|
|
2
|
+
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
3
|
+
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
4
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2
5
|
assert = require('@barchart/common-js/lang/assert'),
|
|
3
6
|
is = require('@barchart/common-js/lang/is'),
|
|
4
7
|
Tree = require('@barchart/common-js/collections/Tree');
|
|
@@ -49,8 +52,8 @@ module.exports = (() => {
|
|
|
49
52
|
let position = item.position;
|
|
50
53
|
let symbol = null;
|
|
51
54
|
|
|
52
|
-
if (position.instrument && position.instrument.symbol && position.instrument.barchart) {
|
|
53
|
-
symbol = position.instrument.barchart;
|
|
55
|
+
if (position.instrument && position.instrument.symbol && position.instrument.symbol.barchart) {
|
|
56
|
+
symbol = position.instrument.symbol.barchart;
|
|
54
57
|
|
|
55
58
|
if (!map.hasOwnProperty(symbol)) {
|
|
56
59
|
map[symbol] = [ ];
|
|
@@ -62,7 +65,7 @@ module.exports = (() => {
|
|
|
62
65
|
return map;
|
|
63
66
|
}, { });
|
|
64
67
|
|
|
65
|
-
this._definitions = definitions
|
|
68
|
+
this._definitions = definitions;
|
|
66
69
|
|
|
67
70
|
this._tree = new Tree();
|
|
68
71
|
|
|
@@ -77,17 +80,47 @@ module.exports = (() => {
|
|
|
77
80
|
const populatedGroups = array.batchBy(items, currentDefinition.keySelector).map((items) => {
|
|
78
81
|
const first = items[0];
|
|
79
82
|
|
|
80
|
-
return new PositionGroup(items, currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
|
|
83
|
+
return new PositionGroup(items, currentDefinition.currencySelector(first), currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
|
|
81
84
|
});
|
|
82
85
|
|
|
83
86
|
const missingGroups = array.difference(currentDefinition.requiredGroups, populatedGroups.map(group => group.description));
|
|
84
87
|
|
|
85
88
|
const empty = missingGroups.map((description) => {
|
|
86
|
-
return new PositionGroup(
|
|
89
|
+
return new PositionGroup([ ], Currency.USD, description);
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
const compositeGroups = populatedGroups.concat(empty);
|
|
90
93
|
|
|
94
|
+
let builder;
|
|
95
|
+
|
|
96
|
+
if (currentDefinition.requiredGroups.length !== 0) {
|
|
97
|
+
const ordering = currentDefinition.requiredGroups.reduce((map, group, index) => {
|
|
98
|
+
map[group] = index;
|
|
99
|
+
|
|
100
|
+
return map;
|
|
101
|
+
}, { });
|
|
102
|
+
|
|
103
|
+
const getIndex = (description) => {
|
|
104
|
+
if (ordering.hasOwnProperty(description)) {
|
|
105
|
+
return ordering[description];
|
|
106
|
+
} else {
|
|
107
|
+
return Number.MAX_VALUE;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
builder = ComparatorBuilder.startWith((a, b) => {
|
|
112
|
+
return comparators.compareNumbers(getIndex(a.description), getIndex(b.description));
|
|
113
|
+
}).thenBy((a, b) => {
|
|
114
|
+
return comparators.compareStrings(a.description, b.description);
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
builder = ComparatorBuilder.startWith((a, b) => {
|
|
118
|
+
return comparators.compareStrings(a.description, b.description);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
compositeGroups.sort(builder.toComparator());
|
|
123
|
+
|
|
91
124
|
compositeGroups.forEach((group) => {
|
|
92
125
|
const child = tree.addChild(group);
|
|
93
126
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2
3
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
4
|
+
formatter = require('@barchart/common-js/lang/formatter'),
|
|
3
5
|
is = require('@barchart/common-js/lang/is');
|
|
4
6
|
|
|
5
7
|
module.exports = (() => {
|
|
@@ -9,47 +11,62 @@ module.exports = (() => {
|
|
|
9
11
|
* @public
|
|
10
12
|
*/
|
|
11
13
|
class PositionGroup {
|
|
12
|
-
constructor(items, description, single) {
|
|
13
|
-
this._description = description;
|
|
14
|
+
constructor(items, currency, description, single) {
|
|
14
15
|
this._items = items;
|
|
16
|
+
this._currency = currency;
|
|
17
|
+
|
|
18
|
+
this._description = description;
|
|
15
19
|
|
|
16
20
|
this._single = is.boolean(single) && single;
|
|
17
21
|
|
|
18
|
-
this.
|
|
22
|
+
this._dataFormat = { };
|
|
23
|
+
this._dataRaw = { };
|
|
24
|
+
|
|
25
|
+
this._dataFormat.description = this._description;
|
|
19
26
|
|
|
20
|
-
this.
|
|
27
|
+
this._dataRaw.current = null;
|
|
28
|
+
this._dataRaw.previous = null;
|
|
21
29
|
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
30
|
+
this._dataFormat.current = null;
|
|
31
|
+
this._dataFormat.previous = null;
|
|
24
32
|
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
33
|
+
this._dataRaw.basis = null;
|
|
34
|
+
this._dataRaw.market = null;
|
|
35
|
+
|
|
36
|
+
this._dataFormat.basis = null;
|
|
37
|
+
this._dataFormat.market = null;
|
|
27
38
|
|
|
28
39
|
this._items.forEach((item) => {
|
|
29
40
|
item.registerPriceChangeHandler((data, sender) => {
|
|
30
41
|
if (this._single) {
|
|
31
|
-
|
|
42
|
+
this._dataRaw.current = data.current;
|
|
43
|
+
this._dataFormat.current = format(data.current, sender.position.instrument.currency);
|
|
32
44
|
} else {
|
|
33
|
-
|
|
45
|
+
this._dataRaw.current = null;
|
|
46
|
+
this._dataFormat.current = null;
|
|
34
47
|
}
|
|
35
48
|
|
|
36
|
-
calculateVariablePriceData(this, item
|
|
49
|
+
calculateVariablePriceData(this, item);
|
|
37
50
|
});
|
|
38
51
|
});
|
|
39
52
|
|
|
40
53
|
calculateStaticData(this);
|
|
41
54
|
}
|
|
42
55
|
|
|
56
|
+
get items() {
|
|
57
|
+
return this._items;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get currency() {
|
|
61
|
+
return this._currency;
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
get description() {
|
|
44
65
|
return this._description;
|
|
45
66
|
}
|
|
46
67
|
|
|
47
68
|
get data() {
|
|
48
|
-
return this.
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get items() {
|
|
52
|
-
return this._items;
|
|
69
|
+
return this._dataFormat;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
get single() {
|
|
@@ -61,9 +78,15 @@ module.exports = (() => {
|
|
|
61
78
|
}
|
|
62
79
|
}
|
|
63
80
|
|
|
81
|
+
function format(decimal, currency) {
|
|
82
|
+
return formatter.numberToString(decimal.toFloat(), currency.precision, ',', false);
|
|
83
|
+
}
|
|
84
|
+
|
|
64
85
|
function calculateStaticData(group) {
|
|
65
86
|
const items = group._items;
|
|
66
|
-
|
|
87
|
+
|
|
88
|
+
const raw = group._dataRaw;
|
|
89
|
+
const formatted = group._dataFormat;
|
|
67
90
|
|
|
68
91
|
let updates;
|
|
69
92
|
|
|
@@ -84,10 +107,11 @@ module.exports = (() => {
|
|
|
84
107
|
});
|
|
85
108
|
}
|
|
86
109
|
|
|
87
|
-
|
|
110
|
+
raw.basis = updates.basis;
|
|
111
|
+
formatted.basis = format(updates.basis, Currency.USD);
|
|
88
112
|
}
|
|
89
113
|
|
|
90
|
-
function calculateVariablePriceData(group, item
|
|
114
|
+
function calculateVariablePriceData(group, item) {
|
|
91
115
|
|
|
92
116
|
}
|
|
93
117
|
|
|
@@ -8,11 +8,12 @@ module.exports = (() => {
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
class PositionGroupDefinition {
|
|
11
|
-
constructor(name, keySelector, descriptionSelector, requiredGroups, single) {
|
|
11
|
+
constructor(name, keySelector, descriptionSelector, currencySelector, requiredGroups, single) {
|
|
12
12
|
this._name = name;
|
|
13
13
|
|
|
14
14
|
this._keySelector = keySelector;
|
|
15
15
|
this._descriptionSelector = descriptionSelector;
|
|
16
|
+
this._currencySelector = currencySelector;
|
|
16
17
|
|
|
17
18
|
this._requiredGroups = requiredGroups || [ ];
|
|
18
19
|
this._single = is.boolean(single) && single;
|
|
@@ -30,6 +31,10 @@ module.exports = (() => {
|
|
|
30
31
|
return this._descriptionSelector;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
get currencySelector() {
|
|
35
|
+
return this._currencySelector;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
get requiredGroups() {
|
|
34
39
|
return this._requiredGroups;
|
|
35
40
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
2
3
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
3
4
|
is = require('@barchart/common-js/lang/is');
|
|
4
5
|
|
|
@@ -21,6 +22,18 @@ module.exports = (() => {
|
|
|
21
22
|
|
|
22
23
|
const snapshot = this._position.snapshot;
|
|
23
24
|
|
|
25
|
+
this._data.basis = snapshot.basis || Decimal.ZERO;
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
let market;
|
|
29
|
+
|
|
30
|
+
if (position.previous) {
|
|
31
|
+
market = snapshot.open.multiply(position.previous);
|
|
32
|
+
} else {
|
|
33
|
+
market = snapshot.value;
|
|
34
|
+
}
|
|
35
|
+
*/
|
|
36
|
+
|
|
24
37
|
this._priceChangeEvent = new Event(this);
|
|
25
38
|
}
|
|
26
39
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -185,7 +185,7 @@ module.exports = (() => {
|
|
|
185
185
|
return PositionSummaryFrame;
|
|
186
186
|
})();
|
|
187
187
|
|
|
188
|
-
},{"@barchart/common-js/lang/Day":
|
|
188
|
+
},{"@barchart/common-js/lang/Day":11,"@barchart/common-js/lang/Enum":14,"@barchart/common-js/lang/array":15,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],2:[function(require,module,exports){
|
|
189
189
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
190
190
|
Enum = require('@barchart/common-js/lang/Enum');
|
|
191
191
|
|
|
@@ -512,8 +512,11 @@ module.exports = (() => {
|
|
|
512
512
|
return TransactionType;
|
|
513
513
|
})();
|
|
514
514
|
|
|
515
|
-
},{"@barchart/common-js/lang/Enum":
|
|
515
|
+
},{"@barchart/common-js/lang/Enum":14,"@barchart/common-js/lang/assert":16}],3:[function(require,module,exports){
|
|
516
516
|
const array = require('@barchart/common-js/lang/array'),
|
|
517
|
+
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
518
|
+
comparators = require('@barchart/common-js/collections/sorting/comparators'),
|
|
519
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
517
520
|
assert = require('@barchart/common-js/lang/assert'),
|
|
518
521
|
is = require('@barchart/common-js/lang/is'),
|
|
519
522
|
Tree = require('@barchart/common-js/collections/Tree');
|
|
@@ -564,8 +567,8 @@ module.exports = (() => {
|
|
|
564
567
|
let position = item.position;
|
|
565
568
|
let symbol = null;
|
|
566
569
|
|
|
567
|
-
if (position.instrument && position.instrument.symbol && position.instrument.barchart) {
|
|
568
|
-
symbol = position.instrument.barchart;
|
|
570
|
+
if (position.instrument && position.instrument.symbol && position.instrument.symbol.barchart) {
|
|
571
|
+
symbol = position.instrument.symbol.barchart;
|
|
569
572
|
|
|
570
573
|
if (!map.hasOwnProperty(symbol)) {
|
|
571
574
|
map[symbol] = [ ];
|
|
@@ -577,7 +580,7 @@ module.exports = (() => {
|
|
|
577
580
|
return map;
|
|
578
581
|
}, { });
|
|
579
582
|
|
|
580
|
-
this._definitions = definitions
|
|
583
|
+
this._definitions = definitions;
|
|
581
584
|
|
|
582
585
|
this._tree = new Tree();
|
|
583
586
|
|
|
@@ -592,17 +595,47 @@ module.exports = (() => {
|
|
|
592
595
|
const populatedGroups = array.batchBy(items, currentDefinition.keySelector).map((items) => {
|
|
593
596
|
const first = items[0];
|
|
594
597
|
|
|
595
|
-
return new PositionGroup(items, currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
|
|
598
|
+
return new PositionGroup(items, currentDefinition.currencySelector(first), currentDefinition.descriptionSelector(first), currentDefinition.single && items.length === 1);
|
|
596
599
|
});
|
|
597
600
|
|
|
598
601
|
const missingGroups = array.difference(currentDefinition.requiredGroups, populatedGroups.map(group => group.description));
|
|
599
602
|
|
|
600
603
|
const empty = missingGroups.map((description) => {
|
|
601
|
-
return new PositionGroup(
|
|
604
|
+
return new PositionGroup([ ], Currency.USD, description);
|
|
602
605
|
});
|
|
603
606
|
|
|
604
607
|
const compositeGroups = populatedGroups.concat(empty);
|
|
605
608
|
|
|
609
|
+
let builder;
|
|
610
|
+
|
|
611
|
+
if (currentDefinition.requiredGroups.length !== 0) {
|
|
612
|
+
const ordering = currentDefinition.requiredGroups.reduce((map, group, index) => {
|
|
613
|
+
map[group] = index;
|
|
614
|
+
|
|
615
|
+
return map;
|
|
616
|
+
}, { });
|
|
617
|
+
|
|
618
|
+
const getIndex = (description) => {
|
|
619
|
+
if (ordering.hasOwnProperty(description)) {
|
|
620
|
+
return ordering[description];
|
|
621
|
+
} else {
|
|
622
|
+
return Number.MAX_VALUE;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
builder = ComparatorBuilder.startWith((a, b) => {
|
|
627
|
+
return comparators.compareNumbers(getIndex(a.description), getIndex(b.description));
|
|
628
|
+
}).thenBy((a, b) => {
|
|
629
|
+
return comparators.compareStrings(a.description, b.description);
|
|
630
|
+
});
|
|
631
|
+
} else {
|
|
632
|
+
builder = ComparatorBuilder.startWith((a, b) => {
|
|
633
|
+
return comparators.compareStrings(a.description, b.description);
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
compositeGroups.sort(builder.toComparator());
|
|
638
|
+
|
|
606
639
|
compositeGroups.forEach((group) => {
|
|
607
640
|
const child = tree.addChild(group);
|
|
608
641
|
|
|
@@ -651,9 +684,11 @@ module.exports = (() => {
|
|
|
651
684
|
return PositionContainer;
|
|
652
685
|
})();
|
|
653
686
|
|
|
654
|
-
},{"./PositionGroup":4,"./PositionGroupDefinition":5,"./PositionItem":6,"@barchart/common-js/collections/Tree":7,"@barchart/common-js/lang/array":
|
|
687
|
+
},{"./PositionGroup":4,"./PositionGroupDefinition":5,"./PositionItem":6,"@barchart/common-js/collections/Tree":7,"@barchart/common-js/collections/sorting/ComparatorBuilder":8,"@barchart/common-js/collections/sorting/comparators":9,"@barchart/common-js/lang/Currency":10,"@barchart/common-js/lang/array":15,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],4:[function(require,module,exports){
|
|
655
688
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
689
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
656
690
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
691
|
+
formatter = require('@barchart/common-js/lang/formatter'),
|
|
657
692
|
is = require('@barchart/common-js/lang/is');
|
|
658
693
|
|
|
659
694
|
module.exports = (() => {
|
|
@@ -663,47 +698,62 @@ module.exports = (() => {
|
|
|
663
698
|
* @public
|
|
664
699
|
*/
|
|
665
700
|
class PositionGroup {
|
|
666
|
-
constructor(items, description, single) {
|
|
667
|
-
this._description = description;
|
|
701
|
+
constructor(items, currency, description, single) {
|
|
668
702
|
this._items = items;
|
|
703
|
+
this._currency = currency;
|
|
704
|
+
|
|
705
|
+
this._description = description;
|
|
669
706
|
|
|
670
707
|
this._single = is.boolean(single) && single;
|
|
671
708
|
|
|
672
|
-
this.
|
|
709
|
+
this._dataFormat = { };
|
|
710
|
+
this._dataRaw = { };
|
|
711
|
+
|
|
712
|
+
this._dataFormat.description = this._description;
|
|
673
713
|
|
|
674
|
-
this.
|
|
714
|
+
this._dataRaw.current = null;
|
|
715
|
+
this._dataRaw.previous = null;
|
|
675
716
|
|
|
676
|
-
this.
|
|
677
|
-
this.
|
|
717
|
+
this._dataFormat.current = null;
|
|
718
|
+
this._dataFormat.previous = null;
|
|
719
|
+
|
|
720
|
+
this._dataRaw.basis = null;
|
|
721
|
+
this._dataRaw.market = null;
|
|
678
722
|
|
|
679
|
-
this.
|
|
680
|
-
this.
|
|
723
|
+
this._dataFormat.basis = null;
|
|
724
|
+
this._dataFormat.market = null;
|
|
681
725
|
|
|
682
726
|
this._items.forEach((item) => {
|
|
683
727
|
item.registerPriceChangeHandler((data, sender) => {
|
|
684
728
|
if (this._single) {
|
|
685
|
-
|
|
729
|
+
this._dataRaw.current = data.current;
|
|
730
|
+
this._dataFormat.current = format(data.current, sender.position.instrument.currency);
|
|
686
731
|
} else {
|
|
687
|
-
|
|
732
|
+
this._dataRaw.current = null;
|
|
733
|
+
this._dataFormat.current = null;
|
|
688
734
|
}
|
|
689
735
|
|
|
690
|
-
calculateVariablePriceData(this, item
|
|
736
|
+
calculateVariablePriceData(this, item);
|
|
691
737
|
});
|
|
692
738
|
});
|
|
693
739
|
|
|
694
740
|
calculateStaticData(this);
|
|
695
741
|
}
|
|
696
742
|
|
|
743
|
+
get items() {
|
|
744
|
+
return this._items;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
get currency() {
|
|
748
|
+
return this._currency;
|
|
749
|
+
}
|
|
750
|
+
|
|
697
751
|
get description() {
|
|
698
752
|
return this._description;
|
|
699
753
|
}
|
|
700
754
|
|
|
701
755
|
get data() {
|
|
702
|
-
return this.
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
get items() {
|
|
706
|
-
return this._items;
|
|
756
|
+
return this._dataFormat;
|
|
707
757
|
}
|
|
708
758
|
|
|
709
759
|
get single() {
|
|
@@ -715,9 +765,15 @@ module.exports = (() => {
|
|
|
715
765
|
}
|
|
716
766
|
}
|
|
717
767
|
|
|
768
|
+
function format(decimal, currency) {
|
|
769
|
+
return formatter.numberToString(decimal.toFloat(), currency.precision, ',', false);
|
|
770
|
+
}
|
|
771
|
+
|
|
718
772
|
function calculateStaticData(group) {
|
|
719
773
|
const items = group._items;
|
|
720
|
-
|
|
774
|
+
|
|
775
|
+
const raw = group._dataRaw;
|
|
776
|
+
const formatted = group._dataFormat;
|
|
721
777
|
|
|
722
778
|
let updates;
|
|
723
779
|
|
|
@@ -738,17 +794,18 @@ module.exports = (() => {
|
|
|
738
794
|
});
|
|
739
795
|
}
|
|
740
796
|
|
|
741
|
-
|
|
797
|
+
raw.basis = updates.basis;
|
|
798
|
+
formatted.basis = format(updates.basis, Currency.USD);
|
|
742
799
|
}
|
|
743
800
|
|
|
744
|
-
function calculateVariablePriceData(group, item
|
|
801
|
+
function calculateVariablePriceData(group, item) {
|
|
745
802
|
|
|
746
803
|
}
|
|
747
804
|
|
|
748
805
|
return PositionGroup;
|
|
749
806
|
})();
|
|
750
807
|
|
|
751
|
-
},{"@barchart/common-js/lang/Decimal":
|
|
808
|
+
},{"@barchart/common-js/lang/Currency":10,"@barchart/common-js/lang/Decimal":12,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/formatter":17,"@barchart/common-js/lang/is":18}],5:[function(require,module,exports){
|
|
752
809
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
753
810
|
is = require('@barchart/common-js/lang/is');
|
|
754
811
|
|
|
@@ -759,11 +816,12 @@ module.exports = (() => {
|
|
|
759
816
|
* @public
|
|
760
817
|
*/
|
|
761
818
|
class PositionGroupDefinition {
|
|
762
|
-
constructor(name, keySelector, descriptionSelector, requiredGroups, single) {
|
|
819
|
+
constructor(name, keySelector, descriptionSelector, currencySelector, requiredGroups, single) {
|
|
763
820
|
this._name = name;
|
|
764
821
|
|
|
765
822
|
this._keySelector = keySelector;
|
|
766
823
|
this._descriptionSelector = descriptionSelector;
|
|
824
|
+
this._currencySelector = currencySelector;
|
|
767
825
|
|
|
768
826
|
this._requiredGroups = requiredGroups || [ ];
|
|
769
827
|
this._single = is.boolean(single) && single;
|
|
@@ -781,6 +839,10 @@ module.exports = (() => {
|
|
|
781
839
|
return this._descriptionSelector;
|
|
782
840
|
}
|
|
783
841
|
|
|
842
|
+
get currencySelector() {
|
|
843
|
+
return this._currencySelector;
|
|
844
|
+
}
|
|
845
|
+
|
|
784
846
|
get requiredGroups() {
|
|
785
847
|
return this._requiredGroups;
|
|
786
848
|
}
|
|
@@ -793,8 +855,9 @@ module.exports = (() => {
|
|
|
793
855
|
return PositionGroupDefinition;
|
|
794
856
|
})();
|
|
795
857
|
|
|
796
|
-
},{"@barchart/common-js/lang/assert":
|
|
858
|
+
},{"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18}],6:[function(require,module,exports){
|
|
797
859
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
860
|
+
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
798
861
|
Event = require('@barchart/common-js/messaging/Event'),
|
|
799
862
|
is = require('@barchart/common-js/lang/is');
|
|
800
863
|
|
|
@@ -817,6 +880,18 @@ module.exports = (() => {
|
|
|
817
880
|
|
|
818
881
|
const snapshot = this._position.snapshot;
|
|
819
882
|
|
|
883
|
+
this._data.basis = snapshot.basis || Decimal.ZERO;
|
|
884
|
+
|
|
885
|
+
/*
|
|
886
|
+
let market;
|
|
887
|
+
|
|
888
|
+
if (position.previous) {
|
|
889
|
+
market = snapshot.open.multiply(position.previous);
|
|
890
|
+
} else {
|
|
891
|
+
market = snapshot.value;
|
|
892
|
+
}
|
|
893
|
+
*/
|
|
894
|
+
|
|
820
895
|
this._priceChangeEvent = new Event(this);
|
|
821
896
|
}
|
|
822
897
|
|
|
@@ -854,7 +929,7 @@ module.exports = (() => {
|
|
|
854
929
|
return PositionItem;
|
|
855
930
|
})();
|
|
856
931
|
|
|
857
|
-
},{"@barchart/common-js/lang/assert":
|
|
932
|
+
},{"@barchart/common-js/lang/Decimal":12,"@barchart/common-js/lang/assert":16,"@barchart/common-js/lang/is":18,"@barchart/common-js/messaging/Event":19}],7:[function(require,module,exports){
|
|
858
933
|
'use strict';
|
|
859
934
|
|
|
860
935
|
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; }; }();
|
|
@@ -1163,7 +1238,7 @@ module.exports = function () {
|
|
|
1163
1238
|
return Tree;
|
|
1164
1239
|
}();
|
|
1165
1240
|
|
|
1166
|
-
},{"./../lang/is":
|
|
1241
|
+
},{"./../lang/is":18}],8:[function(require,module,exports){
|
|
1167
1242
|
'use strict';
|
|
1168
1243
|
|
|
1169
1244
|
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; }; }();
|
|
@@ -1307,7 +1382,7 @@ module.exports = function () {
|
|
|
1307
1382
|
return ComparatorBuilder;
|
|
1308
1383
|
}();
|
|
1309
1384
|
|
|
1310
|
-
},{"./../../lang/assert":
|
|
1385
|
+
},{"./../../lang/assert":16,"./comparators":9}],9:[function(require,module,exports){
|
|
1311
1386
|
'use strict';
|
|
1312
1387
|
|
|
1313
1388
|
var assert = require('./../../lang/assert');
|
|
@@ -1382,7 +1457,150 @@ module.exports = function () {
|
|
|
1382
1457
|
};
|
|
1383
1458
|
}();
|
|
1384
1459
|
|
|
1385
|
-
},{"./../../lang/assert":
|
|
1460
|
+
},{"./../../lang/assert":16}],10:[function(require,module,exports){
|
|
1461
|
+
'use strict';
|
|
1462
|
+
|
|
1463
|
+
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; }; }();
|
|
1464
|
+
|
|
1465
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1466
|
+
|
|
1467
|
+
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; }
|
|
1468
|
+
|
|
1469
|
+
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; }
|
|
1470
|
+
|
|
1471
|
+
var assert = require('./assert'),
|
|
1472
|
+
Enum = require('./Enum'),
|
|
1473
|
+
is = require('./is');
|
|
1474
|
+
|
|
1475
|
+
module.exports = function () {
|
|
1476
|
+
'use strict';
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* An enumeration for currency types.
|
|
1480
|
+
*
|
|
1481
|
+
* @public
|
|
1482
|
+
* @param {String} code - Currency code (e.g. "USD")
|
|
1483
|
+
* @param {String} description - The description (e.g. "US Dollar")
|
|
1484
|
+
* @param {Number} precision - The number of decimal places possible for by a real world transaction.
|
|
1485
|
+
* @extends {Enum}
|
|
1486
|
+
*/
|
|
1487
|
+
|
|
1488
|
+
var Currency = function (_Enum) {
|
|
1489
|
+
_inherits(Currency, _Enum);
|
|
1490
|
+
|
|
1491
|
+
function Currency(code, description, precision, alternateDescription) {
|
|
1492
|
+
_classCallCheck(this, Currency);
|
|
1493
|
+
|
|
1494
|
+
var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
|
|
1495
|
+
|
|
1496
|
+
assert.argumentIsRequired(precision, 'precision', Number);
|
|
1497
|
+
assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
|
|
1498
|
+
|
|
1499
|
+
assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
|
|
1500
|
+
|
|
1501
|
+
_this._precision = precision;
|
|
1502
|
+
|
|
1503
|
+
_this._alternateDescription = alternateDescription || description;
|
|
1504
|
+
return _this;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* The maximum number of decimal places supported by a real world transaction.
|
|
1509
|
+
*
|
|
1510
|
+
* @public
|
|
1511
|
+
* @returns {Number}
|
|
1512
|
+
*/
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
_createClass(Currency, [{
|
|
1516
|
+
key: 'toString',
|
|
1517
|
+
value: function toString() {
|
|
1518
|
+
return '[Currency (code=' + this.code + ')]';
|
|
1519
|
+
}
|
|
1520
|
+
}, {
|
|
1521
|
+
key: 'precision',
|
|
1522
|
+
get: function get() {
|
|
1523
|
+
return this._precision;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* An alternate human-readable description.
|
|
1528
|
+
*
|
|
1529
|
+
* @public
|
|
1530
|
+
* @returns {String}
|
|
1531
|
+
*/
|
|
1532
|
+
|
|
1533
|
+
}, {
|
|
1534
|
+
key: 'alternateDescription',
|
|
1535
|
+
get: function get() {
|
|
1536
|
+
return this._alternateDescription;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
/**
|
|
1540
|
+
* Given a code, returns the enumeration item.
|
|
1541
|
+
*
|
|
1542
|
+
* @public
|
|
1543
|
+
* @param {String} code
|
|
1544
|
+
* @returns {Currency|null}
|
|
1545
|
+
*/
|
|
1546
|
+
|
|
1547
|
+
}], [{
|
|
1548
|
+
key: 'parse',
|
|
1549
|
+
value: function parse(code) {
|
|
1550
|
+
return Enum.fromCode(Currency, code);
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* The Canadian Dollar.
|
|
1555
|
+
*
|
|
1556
|
+
* @public
|
|
1557
|
+
* @returns {Currency}
|
|
1558
|
+
*/
|
|
1559
|
+
|
|
1560
|
+
}, {
|
|
1561
|
+
key: 'CAD',
|
|
1562
|
+
get: function get() {
|
|
1563
|
+
return cad;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* The Euro.
|
|
1568
|
+
*
|
|
1569
|
+
* @public
|
|
1570
|
+
* @returns {Currency}
|
|
1571
|
+
*/
|
|
1572
|
+
|
|
1573
|
+
}, {
|
|
1574
|
+
key: 'EUR',
|
|
1575
|
+
get: function get() {
|
|
1576
|
+
return eur;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* The US Dollar.
|
|
1581
|
+
*
|
|
1582
|
+
* @public
|
|
1583
|
+
* @returns {Currency}
|
|
1584
|
+
*/
|
|
1585
|
+
|
|
1586
|
+
}, {
|
|
1587
|
+
key: 'USD',
|
|
1588
|
+
get: function get() {
|
|
1589
|
+
return usd;
|
|
1590
|
+
}
|
|
1591
|
+
}]);
|
|
1592
|
+
|
|
1593
|
+
return Currency;
|
|
1594
|
+
}(Enum);
|
|
1595
|
+
|
|
1596
|
+
var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
|
|
1597
|
+
var eur = new Currency('EUR', 'Euro', 2, 'EUR');
|
|
1598
|
+
var usd = new Currency('USD', 'US Dollar', 2, 'US$');
|
|
1599
|
+
|
|
1600
|
+
return Currency;
|
|
1601
|
+
}();
|
|
1602
|
+
|
|
1603
|
+
},{"./Enum":14,"./assert":16,"./is":18}],11:[function(require,module,exports){
|
|
1386
1604
|
'use strict';
|
|
1387
1605
|
|
|
1388
1606
|
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; }; }();
|
|
@@ -1935,7 +2153,7 @@ module.exports = function () {
|
|
|
1935
2153
|
return Day;
|
|
1936
2154
|
}();
|
|
1937
2155
|
|
|
1938
|
-
},{"./../collections/sorting/ComparatorBuilder":8,"./../collections/sorting/comparators":9,"./assert":
|
|
2156
|
+
},{"./../collections/sorting/ComparatorBuilder":8,"./../collections/sorting/comparators":9,"./assert":16,"./is":18}],12:[function(require,module,exports){
|
|
1939
2157
|
'use strict';
|
|
1940
2158
|
|
|
1941
2159
|
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; }; }();
|
|
@@ -2515,7 +2733,7 @@ module.exports = function () {
|
|
|
2515
2733
|
return Decimal;
|
|
2516
2734
|
}();
|
|
2517
2735
|
|
|
2518
|
-
},{"./Enum":
|
|
2736
|
+
},{"./Enum":14,"./assert":16,"./is":18,"big.js":20}],13:[function(require,module,exports){
|
|
2519
2737
|
'use strict';
|
|
2520
2738
|
|
|
2521
2739
|
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; }; }();
|
|
@@ -2664,7 +2882,7 @@ module.exports = function () {
|
|
|
2664
2882
|
return Disposable;
|
|
2665
2883
|
}();
|
|
2666
2884
|
|
|
2667
|
-
},{"./assert":
|
|
2885
|
+
},{"./assert":16}],14:[function(require,module,exports){
|
|
2668
2886
|
'use strict';
|
|
2669
2887
|
|
|
2670
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; }; }();
|
|
@@ -2806,7 +3024,7 @@ module.exports = function () {
|
|
|
2806
3024
|
return Enum;
|
|
2807
3025
|
}();
|
|
2808
3026
|
|
|
2809
|
-
},{"./assert":
|
|
3027
|
+
},{"./assert":16}],15:[function(require,module,exports){
|
|
2810
3028
|
'use strict';
|
|
2811
3029
|
|
|
2812
3030
|
var assert = require('./assert'),
|
|
@@ -3187,7 +3405,7 @@ module.exports = function () {
|
|
|
3187
3405
|
};
|
|
3188
3406
|
}();
|
|
3189
3407
|
|
|
3190
|
-
},{"./assert":
|
|
3408
|
+
},{"./assert":16,"./is":18}],16:[function(require,module,exports){
|
|
3191
3409
|
'use strict';
|
|
3192
3410
|
|
|
3193
3411
|
var is = require('./is');
|
|
@@ -3335,7 +3553,72 @@ module.exports = function () {
|
|
|
3335
3553
|
};
|
|
3336
3554
|
}();
|
|
3337
3555
|
|
|
3338
|
-
},{"./is":
|
|
3556
|
+
},{"./is":18}],17:[function(require,module,exports){
|
|
3557
|
+
'use strict';
|
|
3558
|
+
|
|
3559
|
+
module.exports = function () {
|
|
3560
|
+
'use strict';
|
|
3561
|
+
|
|
3562
|
+
return {
|
|
3563
|
+
/**
|
|
3564
|
+
* Formats a number into a string for display purposes.
|
|
3565
|
+
*/
|
|
3566
|
+
numberToString: function numberToString(value, digits, thousandsSeparator, useParenthesis) {
|
|
3567
|
+
if (value === '' || value === undefined || value === null || isNaN(value)) {
|
|
3568
|
+
return '';
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
var applyParenthesis = value < 0 && useParenthesis === true;
|
|
3572
|
+
|
|
3573
|
+
if (applyParenthesis) {
|
|
3574
|
+
value = 0 - value;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
var returnRef = value.toFixed(digits);
|
|
3578
|
+
|
|
3579
|
+
if (thousandsSeparator && !(value > -1000 && value < 1000)) {
|
|
3580
|
+
var length = returnRef.length;
|
|
3581
|
+
var negative = value < 0;
|
|
3582
|
+
|
|
3583
|
+
var found = digits === 0;
|
|
3584
|
+
var counter = 0;
|
|
3585
|
+
|
|
3586
|
+
var buffer = [];
|
|
3587
|
+
|
|
3588
|
+
for (var i = length - 1; !(i < 0); i--) {
|
|
3589
|
+
if (counter === 3 && !(negative && i === 0)) {
|
|
3590
|
+
buffer.unshift(thousandsSeparator);
|
|
3591
|
+
|
|
3592
|
+
counter = 0;
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
var character = returnRef.charAt(i);
|
|
3596
|
+
|
|
3597
|
+
buffer.unshift(character);
|
|
3598
|
+
|
|
3599
|
+
if (found) {
|
|
3600
|
+
counter = counter + 1;
|
|
3601
|
+
} else if (character === '.') {
|
|
3602
|
+
found = true;
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
if (applyParenthesis) {
|
|
3607
|
+
buffer.unshift('(');
|
|
3608
|
+
buffer.push(')');
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
returnRef = buffer.join('');
|
|
3612
|
+
} else if (applyParenthesis) {
|
|
3613
|
+
returnRef = '(' + returnRef + ')';
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
return returnRef;
|
|
3617
|
+
}
|
|
3618
|
+
};
|
|
3619
|
+
}();
|
|
3620
|
+
|
|
3621
|
+
},{}],18:[function(require,module,exports){
|
|
3339
3622
|
'use strict';
|
|
3340
3623
|
|
|
3341
3624
|
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; };
|
|
@@ -3558,7 +3841,7 @@ module.exports = function () {
|
|
|
3558
3841
|
};
|
|
3559
3842
|
}();
|
|
3560
3843
|
|
|
3561
|
-
},{}],
|
|
3844
|
+
},{}],19:[function(require,module,exports){
|
|
3562
3845
|
'use strict';
|
|
3563
3846
|
|
|
3564
3847
|
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; }; }();
|
|
@@ -3730,7 +4013,7 @@ module.exports = function () {
|
|
|
3730
4013
|
return Event;
|
|
3731
4014
|
}();
|
|
3732
4015
|
|
|
3733
|
-
},{"./../lang/Disposable":
|
|
4016
|
+
},{"./../lang/Disposable":13,"./../lang/assert":16}],20:[function(require,module,exports){
|
|
3734
4017
|
/*
|
|
3735
4018
|
* big.js v5.0.3
|
|
3736
4019
|
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
|
|
@@ -4671,7 +4954,7 @@ module.exports = function () {
|
|
|
4671
4954
|
}
|
|
4672
4955
|
})(this);
|
|
4673
4956
|
|
|
4674
|
-
},{}],
|
|
4957
|
+
},{}],21:[function(require,module,exports){
|
|
4675
4958
|
const Day = require('@barchart/common-js/lang/Day'),
|
|
4676
4959
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
4677
4960
|
|
|
@@ -5028,8 +5311,9 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
5028
5311
|
});
|
|
5029
5312
|
});
|
|
5030
5313
|
|
|
5031
|
-
},{"./../../../lib/data/PositionSummaryFrame":1,"./../../../lib/data/TransactionType":2,"@barchart/common-js/lang/Day":
|
|
5032
|
-
const
|
|
5314
|
+
},{"./../../../lib/data/PositionSummaryFrame":1,"./../../../lib/data/TransactionType":2,"@barchart/common-js/lang/Day":11,"@barchart/common-js/lang/Decimal":12}],22:[function(require,module,exports){
|
|
5315
|
+
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
5316
|
+
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
5033
5317
|
|
|
5034
5318
|
const PositionContainer = require('./../../../lib/processing/PositionContainer'),
|
|
5035
5319
|
PositionGroupDefinition = require('./../../../lib/processing/PositionGroupDefinition');
|
|
@@ -5039,13 +5323,14 @@ describe('When a position container data is gathered', () => {
|
|
|
5039
5323
|
|
|
5040
5324
|
let positionCounter = 0;
|
|
5041
5325
|
|
|
5042
|
-
function getPosition(portfolio, symbol) {
|
|
5326
|
+
function getPosition(portfolio, symbol, currency) {
|
|
5043
5327
|
return {
|
|
5044
5328
|
portfolio: portfolio,
|
|
5045
5329
|
position: (positionCounter++).toString(),
|
|
5046
5330
|
instrument: {
|
|
5047
5331
|
symbol: {
|
|
5048
|
-
barchart: symbol
|
|
5332
|
+
barchart: symbol,
|
|
5333
|
+
currency: currency || Currency.USD
|
|
5049
5334
|
}
|
|
5050
5335
|
},
|
|
5051
5336
|
snapshot: {
|
|
@@ -5085,9 +5370,9 @@ describe('When a position container data is gathered', () => {
|
|
|
5085
5370
|
|
|
5086
5371
|
beforeEach(() => {
|
|
5087
5372
|
definitions = [
|
|
5088
|
-
new PositionGroupDefinition('Total', x => true, x => 'Total'),
|
|
5089
|
-
new PositionGroupDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name),
|
|
5090
|
-
new PositionGroupDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart)
|
|
5373
|
+
new PositionGroupDefinition('Total', x => true, x => 'Total', x => Currency.CAD),
|
|
5374
|
+
new PositionGroupDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
|
|
5375
|
+
new PositionGroupDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
|
|
5091
5376
|
];
|
|
5092
5377
|
|
|
5093
5378
|
try {
|
|
@@ -5124,4 +5409,4 @@ describe('When a position container data is gathered', () => {
|
|
|
5124
5409
|
});
|
|
5125
5410
|
});
|
|
5126
5411
|
|
|
5127
|
-
},{"./../../../lib/processing/PositionContainer":3,"./../../../lib/processing/PositionGroupDefinition":5,"@barchart/common-js/lang/Decimal":
|
|
5412
|
+
},{"./../../../lib/processing/PositionContainer":3,"./../../../lib/processing/PositionGroupDefinition":5,"@barchart/common-js/lang/Currency":10,"@barchart/common-js/lang/Decimal":12}]},{},[21,22]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
2
|
+
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
2
3
|
|
|
3
4
|
const PositionContainer = require('./../../../lib/processing/PositionContainer'),
|
|
4
5
|
PositionGroupDefinition = require('./../../../lib/processing/PositionGroupDefinition');
|
|
@@ -8,13 +9,14 @@ describe('When a position container data is gathered', () => {
|
|
|
8
9
|
|
|
9
10
|
let positionCounter = 0;
|
|
10
11
|
|
|
11
|
-
function getPosition(portfolio, symbol) {
|
|
12
|
+
function getPosition(portfolio, symbol, currency) {
|
|
12
13
|
return {
|
|
13
14
|
portfolio: portfolio,
|
|
14
15
|
position: (positionCounter++).toString(),
|
|
15
16
|
instrument: {
|
|
16
17
|
symbol: {
|
|
17
|
-
barchart: symbol
|
|
18
|
+
barchart: symbol,
|
|
19
|
+
currency: currency || Currency.USD
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
snapshot: {
|
|
@@ -54,9 +56,9 @@ describe('When a position container data is gathered', () => {
|
|
|
54
56
|
|
|
55
57
|
beforeEach(() => {
|
|
56
58
|
definitions = [
|
|
57
|
-
new PositionGroupDefinition('Total', x => true, x => 'Total'),
|
|
58
|
-
new PositionGroupDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name),
|
|
59
|
-
new PositionGroupDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart)
|
|
59
|
+
new PositionGroupDefinition('Total', x => true, x => 'Total', x => Currency.CAD),
|
|
60
|
+
new PositionGroupDefinition('Portfolio', x => x.portfolio.portfolio, x => x.portfolio.name, x => Currency.CAD),
|
|
61
|
+
new PositionGroupDefinition('Position', x => x.position.position, x => x.position.instrument.symbol.barchart, x => x.position.instrument.currency)
|
|
60
62
|
];
|
|
61
63
|
|
|
62
64
|
try {
|