@barchart/portfolio-api-common 1.2.21 → 1.2.22
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/data/InstrumentType.js +19 -6
- package/package.json +1 -1
- package/test/SpecRunner.js +19 -6
|
@@ -18,10 +18,11 @@ module.exports = (() => {
|
|
|
18
18
|
* @param {Boolean} canShort
|
|
19
19
|
* @param {Boolean} canSwitchDirection
|
|
20
20
|
* @param {Boolean} usesSymbols
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {Boolean} hasCorporateActions
|
|
22
|
+
* @param {Function} generator
|
|
22
23
|
*/
|
|
23
24
|
class InstrumentType extends Enum {
|
|
24
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, generator) {
|
|
25
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, generator) {
|
|
25
26
|
super(code, description);
|
|
26
27
|
|
|
27
28
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -29,6 +30,7 @@ module.exports = (() => {
|
|
|
29
30
|
assert.argumentIsRequired(canShort, 'canShort', Boolean);
|
|
30
31
|
assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
|
|
31
32
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
33
|
+
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
32
34
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
33
35
|
|
|
34
36
|
this._alternateDescription = alternateDescription;
|
|
@@ -36,6 +38,7 @@ module.exports = (() => {
|
|
|
36
38
|
this._canShort = canShort;
|
|
37
39
|
this._canSwitchDirection = canSwitchDirection;
|
|
38
40
|
this._usesSymbols = usesSymbols;
|
|
41
|
+
this._hasCorporateActions = hasCorporateActions;
|
|
39
42
|
|
|
40
43
|
this._generator = generator;
|
|
41
44
|
}
|
|
@@ -91,6 +94,16 @@ module.exports = (() => {
|
|
|
91
94
|
return this._usesSymbols;
|
|
92
95
|
}
|
|
93
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Indicates if corporate actions are possible for this type of instrument.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
* @returns {Boolean}
|
|
102
|
+
*/
|
|
103
|
+
get hasCorporateActions() {
|
|
104
|
+
return this._hasCorporateActions;
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
/**
|
|
95
108
|
* Generates an identifier for the instrument.
|
|
96
109
|
*
|
|
@@ -188,10 +201,10 @@ module.exports = (() => {
|
|
|
188
201
|
}
|
|
189
202
|
}
|
|
190
203
|
|
|
191
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
192
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
193
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
194
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
204
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
205
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
206
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
207
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
195
208
|
|
|
196
209
|
const map = { };
|
|
197
210
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -19,10 +19,11 @@ module.exports = (() => {
|
|
|
19
19
|
* @param {Boolean} canShort
|
|
20
20
|
* @param {Boolean} canSwitchDirection
|
|
21
21
|
* @param {Boolean} usesSymbols
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {Boolean} hasCorporateActions
|
|
23
|
+
* @param {Function} generator
|
|
23
24
|
*/
|
|
24
25
|
class InstrumentType extends Enum {
|
|
25
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, generator) {
|
|
26
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, generator) {
|
|
26
27
|
super(code, description);
|
|
27
28
|
|
|
28
29
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -30,6 +31,7 @@ module.exports = (() => {
|
|
|
30
31
|
assert.argumentIsRequired(canShort, 'canShort', Boolean);
|
|
31
32
|
assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
|
|
32
33
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
34
|
+
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
33
35
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
34
36
|
|
|
35
37
|
this._alternateDescription = alternateDescription;
|
|
@@ -37,6 +39,7 @@ module.exports = (() => {
|
|
|
37
39
|
this._canShort = canShort;
|
|
38
40
|
this._canSwitchDirection = canSwitchDirection;
|
|
39
41
|
this._usesSymbols = usesSymbols;
|
|
42
|
+
this._hasCorporateActions = hasCorporateActions;
|
|
40
43
|
|
|
41
44
|
this._generator = generator;
|
|
42
45
|
}
|
|
@@ -92,6 +95,16 @@ module.exports = (() => {
|
|
|
92
95
|
return this._usesSymbols;
|
|
93
96
|
}
|
|
94
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Indicates if corporate actions are possible for this type of instrument.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
* @returns {Boolean}
|
|
103
|
+
*/
|
|
104
|
+
get hasCorporateActions() {
|
|
105
|
+
return this._hasCorporateActions;
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
/**
|
|
96
109
|
* Generates an identifier for the instrument.
|
|
97
110
|
*
|
|
@@ -189,10 +202,10 @@ module.exports = (() => {
|
|
|
189
202
|
}
|
|
190
203
|
}
|
|
191
204
|
|
|
192
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
193
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
194
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
195
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
205
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
206
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
207
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
208
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
196
209
|
|
|
197
210
|
const map = { };
|
|
198
211
|
|