@barchart/portfolio-api-common 1.0.161 → 1.0.162
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.
|
@@ -292,6 +292,22 @@ module.exports = (() => {
|
|
|
292
292
|
}, { });
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
addPortfolio(portfolio) {
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
removePortfolio(portfolio) {
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
mutatePosition(position, summary) {
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
removePosition(position) {
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
295
311
|
/**
|
|
296
312
|
* Returns a distinct list of all symbols used by the positions
|
|
297
313
|
* within the container.
|
|
@@ -294,6 +294,16 @@ module.exports = (() => {
|
|
|
294
294
|
return this._excluded;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
addItems(items) {
|
|
298
|
+
|
|
299
|
+
this.refresh();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
removeItems(items) {
|
|
303
|
+
|
|
304
|
+
this.refresh();
|
|
305
|
+
}
|
|
306
|
+
|
|
297
307
|
/**
|
|
298
308
|
* Sets the list of items which are excluded from group aggregation calculations.
|
|
299
309
|
*
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2
3
|
is = require('@barchart/common-js/lang/is');
|
|
3
4
|
|
|
5
|
+
const InstrumentType = require('./../../data/InstrumentType');
|
|
6
|
+
|
|
4
7
|
module.exports = (() => {
|
|
5
8
|
'use strict';
|
|
6
9
|
|
|
@@ -15,7 +18,6 @@ module.exports = (() => {
|
|
|
15
18
|
* @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
|
|
16
19
|
* @param {PositionLevelDefinition~currencySelector} currencySelector
|
|
17
20
|
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
18
|
-
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
19
21
|
* @param {Boolean=} single
|
|
20
22
|
* @param {Boolean=} aggregateCash
|
|
21
23
|
*/
|
|
@@ -118,6 +120,67 @@ module.exports = (() => {
|
|
|
118
120
|
return this._aggregateCash;
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Builds a {@link PositionLevelDefinition~RequiredGroup} for a portfolio.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
* @static
|
|
128
|
+
* @param {Object} portfolio
|
|
129
|
+
* @return {PositionLevelDefinition~RequiredGroup}
|
|
130
|
+
*/
|
|
131
|
+
static buildRequiredGroupForPortfolio(portfolio) {
|
|
132
|
+
return {
|
|
133
|
+
key: PositionLevelDefinition.getKeyForPortfolioGroup(portfolio),
|
|
134
|
+
description: PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio),
|
|
135
|
+
currency: Currency.CAD
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
static getKeyForPortfolioGroup(portfolio) {
|
|
141
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
142
|
+
|
|
143
|
+
return portfolio.portfolio;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static getDescriptionForPortfolioGroup(portfolio) {
|
|
147
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
148
|
+
|
|
149
|
+
return portfolio.name;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Builds a {@link PositionLevelDefinition~RequiredGroup} for an asset class.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
* @static
|
|
157
|
+
* @param {InstrumentType} type
|
|
158
|
+
* @param {Currency} currency
|
|
159
|
+
* @return {PositionLevelDefinition~RequiredGroup}
|
|
160
|
+
*/
|
|
161
|
+
static buildRequiredGroupForAssetClass(type, currency) {
|
|
162
|
+
return {
|
|
163
|
+
key: PositionLevelDefinition.getKeyForAssetClassGroup(type, currency),
|
|
164
|
+
description: PositionLevelDefinition.getDescriptionForAssetClassGroup(type, currency),
|
|
165
|
+
currency: currency
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
static getKeyForAssetClassGroup(type, currency) {
|
|
171
|
+
assert.argumentIsRequired(type, 'type', InstrumentType, 'InstrumentType');
|
|
172
|
+
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
173
|
+
|
|
174
|
+
return `${type.code}|${currency.code}`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static getDescriptionForAssetClassGroup(type, currency) {
|
|
178
|
+
assert.argumentIsRequired(type, 'type', InstrumentType, 'InstrumentType');
|
|
179
|
+
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
180
|
+
|
|
181
|
+
return `${type.alternateDescription}${currency.code === 'CAD' ? '' : ` (${currency.alternateDescription})`}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
121
184
|
toString() {
|
|
122
185
|
return '[PositionLevelDefinition]';
|
|
123
186
|
}
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1008,6 +1008,22 @@ module.exports = (() => {
|
|
|
1008
1008
|
}, { });
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
|
+
addPortfolio(portfolio) {
|
|
1012
|
+
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
removePortfolio(portfolio) {
|
|
1016
|
+
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
mutatePosition(position, summary) {
|
|
1020
|
+
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
removePosition(position) {
|
|
1024
|
+
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1011
1027
|
/**
|
|
1012
1028
|
* Returns a distinct list of all symbols used by the positions
|
|
1013
1029
|
* within the container.
|
|
@@ -1539,6 +1555,16 @@ module.exports = (() => {
|
|
|
1539
1555
|
return this._excluded;
|
|
1540
1556
|
}
|
|
1541
1557
|
|
|
1558
|
+
addItems(items) {
|
|
1559
|
+
|
|
1560
|
+
this.refresh();
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
removeItems(items) {
|
|
1564
|
+
|
|
1565
|
+
this.refresh();
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1542
1568
|
/**
|
|
1543
1569
|
* Sets the list of items which are excluded from group aggregation calculations.
|
|
1544
1570
|
*
|
|
@@ -2295,8 +2321,11 @@ module.exports = (() => {
|
|
|
2295
2321
|
|
|
2296
2322
|
},{"./../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){
|
|
2297
2323
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2324
|
+
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2298
2325
|
is = require('@barchart/common-js/lang/is');
|
|
2299
2326
|
|
|
2327
|
+
const InstrumentType = require('./../../data/InstrumentType');
|
|
2328
|
+
|
|
2300
2329
|
module.exports = (() => {
|
|
2301
2330
|
'use strict';
|
|
2302
2331
|
|
|
@@ -2311,7 +2340,6 @@ module.exports = (() => {
|
|
|
2311
2340
|
* @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
|
|
2312
2341
|
* @param {PositionLevelDefinition~currencySelector} currencySelector
|
|
2313
2342
|
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
2314
|
-
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
2315
2343
|
* @param {Boolean=} single
|
|
2316
2344
|
* @param {Boolean=} aggregateCash
|
|
2317
2345
|
*/
|
|
@@ -2414,6 +2442,67 @@ module.exports = (() => {
|
|
|
2414
2442
|
return this._aggregateCash;
|
|
2415
2443
|
}
|
|
2416
2444
|
|
|
2445
|
+
/**
|
|
2446
|
+
* Builds a {@link PositionLevelDefinition~RequiredGroup} for a portfolio.
|
|
2447
|
+
*
|
|
2448
|
+
* @public
|
|
2449
|
+
* @static
|
|
2450
|
+
* @param {Object} portfolio
|
|
2451
|
+
* @return {PositionLevelDefinition~RequiredGroup}
|
|
2452
|
+
*/
|
|
2453
|
+
static buildRequiredGroupForPortfolio(portfolio) {
|
|
2454
|
+
return {
|
|
2455
|
+
key: PositionLevelDefinition.getKeyForPortfolioGroup(portfolio),
|
|
2456
|
+
description: PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio),
|
|
2457
|
+
currency: Currency.CAD
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
|
|
2462
|
+
static getKeyForPortfolioGroup(portfolio) {
|
|
2463
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
2464
|
+
|
|
2465
|
+
return portfolio.portfolio;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
static getDescriptionForPortfolioGroup(portfolio) {
|
|
2469
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
2470
|
+
|
|
2471
|
+
return portfolio.name;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
/**
|
|
2475
|
+
* Builds a {@link PositionLevelDefinition~RequiredGroup} for an asset class.
|
|
2476
|
+
*
|
|
2477
|
+
* @public
|
|
2478
|
+
* @static
|
|
2479
|
+
* @param {InstrumentType} type
|
|
2480
|
+
* @param {Currency} currency
|
|
2481
|
+
* @return {PositionLevelDefinition~RequiredGroup}
|
|
2482
|
+
*/
|
|
2483
|
+
static buildRequiredGroupForAssetClass(type, currency) {
|
|
2484
|
+
return {
|
|
2485
|
+
key: PositionLevelDefinition.getKeyForAssetClassGroup(type, currency),
|
|
2486
|
+
description: PositionLevelDefinition.getDescriptionForAssetClassGroup(type, currency),
|
|
2487
|
+
currency: currency
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
static getKeyForAssetClassGroup(type, currency) {
|
|
2493
|
+
assert.argumentIsRequired(type, 'type', InstrumentType, 'InstrumentType');
|
|
2494
|
+
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
2495
|
+
|
|
2496
|
+
return `${type.code}|${currency.code}`;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
static getDescriptionForAssetClassGroup(type, currency) {
|
|
2500
|
+
assert.argumentIsRequired(type, 'type', InstrumentType, 'InstrumentType');
|
|
2501
|
+
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
2502
|
+
|
|
2503
|
+
return `${type.alternateDescription}${currency.code === 'CAD' ? '' : ` (${currency.alternateDescription})`}`;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2417
2506
|
toString() {
|
|
2418
2507
|
return '[PositionLevelDefinition]';
|
|
2419
2508
|
}
|
|
@@ -2463,7 +2552,7 @@ module.exports = (() => {
|
|
|
2463
2552
|
return PositionLevelDefinition;
|
|
2464
2553
|
})();
|
|
2465
2554
|
|
|
2466
|
-
},{"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],8:[function(require,module,exports){
|
|
2555
|
+
},{"./../../data/InstrumentType":1,"@barchart/common-js/lang/Currency":14,"@barchart/common-js/lang/assert":21,"@barchart/common-js/lang/is":23}],8:[function(require,module,exports){
|
|
2467
2556
|
const assert = require('@barchart/common-js/lang/assert');
|
|
2468
2557
|
|
|
2469
2558
|
const PositionLevelDefinition = require('./PositionLevelDefinition');
|