@barchart/portfolio-api-common 1.2.54 → 1.2.55
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 +20 -5
- package/package.json +1 -1
- package/test/SpecRunner.js +20 -5
|
@@ -19,10 +19,11 @@ module.exports = (() => {
|
|
|
19
19
|
* @param {Boolean} canSwitchDirection
|
|
20
20
|
* @param {Boolean} usesSymbols
|
|
21
21
|
* @param {Boolean} hasCorporateActions
|
|
22
|
+
* @param {Number} closeFractional
|
|
22
23
|
* @param {Function} generator
|
|
23
24
|
*/
|
|
24
25
|
class InstrumentType extends Enum {
|
|
25
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, generator) {
|
|
26
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, generator) {
|
|
26
27
|
super(code, description);
|
|
27
28
|
|
|
28
29
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -31,6 +32,7 @@ module.exports = (() => {
|
|
|
31
32
|
assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
|
|
32
33
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
33
34
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
35
|
+
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
34
36
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
35
37
|
|
|
36
38
|
this._alternateDescription = alternateDescription;
|
|
@@ -39,6 +41,7 @@ module.exports = (() => {
|
|
|
39
41
|
this._canSwitchDirection = canSwitchDirection;
|
|
40
42
|
this._usesSymbols = usesSymbols;
|
|
41
43
|
this._hasCorporateActions = hasCorporateActions;
|
|
44
|
+
this._closeFractional = closeFractional;
|
|
42
45
|
|
|
43
46
|
this._generator = generator;
|
|
44
47
|
}
|
|
@@ -104,6 +107,18 @@ module.exports = (() => {
|
|
|
104
107
|
return this._hasCorporateActions;
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Indicates if fractional shares should be closed when the position
|
|
112
|
+
* size is less than one.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
* @returns {Boolean}
|
|
116
|
+
*/
|
|
117
|
+
get closeFractional() {
|
|
118
|
+
return this._closeFractional;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
107
122
|
/**
|
|
108
123
|
* Generates an identifier for the instrument.
|
|
109
124
|
*
|
|
@@ -201,10 +216,10 @@ module.exports = (() => {
|
|
|
201
216
|
}
|
|
202
217
|
}
|
|
203
218
|
|
|
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()}`);
|
|
219
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
220
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
221
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
222
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
208
223
|
|
|
209
224
|
const map = { };
|
|
210
225
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -20,10 +20,11 @@ module.exports = (() => {
|
|
|
20
20
|
* @param {Boolean} canSwitchDirection
|
|
21
21
|
* @param {Boolean} usesSymbols
|
|
22
22
|
* @param {Boolean} hasCorporateActions
|
|
23
|
+
* @param {Number} closeFractional
|
|
23
24
|
* @param {Function} generator
|
|
24
25
|
*/
|
|
25
26
|
class InstrumentType extends Enum {
|
|
26
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, generator) {
|
|
27
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, generator) {
|
|
27
28
|
super(code, description);
|
|
28
29
|
|
|
29
30
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -32,6 +33,7 @@ module.exports = (() => {
|
|
|
32
33
|
assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
|
|
33
34
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
34
35
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
36
|
+
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
35
37
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
36
38
|
|
|
37
39
|
this._alternateDescription = alternateDescription;
|
|
@@ -40,6 +42,7 @@ module.exports = (() => {
|
|
|
40
42
|
this._canSwitchDirection = canSwitchDirection;
|
|
41
43
|
this._usesSymbols = usesSymbols;
|
|
42
44
|
this._hasCorporateActions = hasCorporateActions;
|
|
45
|
+
this._closeFractional = closeFractional;
|
|
43
46
|
|
|
44
47
|
this._generator = generator;
|
|
45
48
|
}
|
|
@@ -105,6 +108,18 @@ module.exports = (() => {
|
|
|
105
108
|
return this._hasCorporateActions;
|
|
106
109
|
}
|
|
107
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Indicates if fractional shares should be closed when the position
|
|
113
|
+
* size is less than one.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
* @returns {Boolean}
|
|
117
|
+
*/
|
|
118
|
+
get closeFractional() {
|
|
119
|
+
return this._closeFractional;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
108
123
|
/**
|
|
109
124
|
* Generates an identifier for the instrument.
|
|
110
125
|
*
|
|
@@ -202,10 +217,10 @@ module.exports = (() => {
|
|
|
202
217
|
}
|
|
203
218
|
}
|
|
204
219
|
|
|
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()}`);
|
|
220
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
221
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
222
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
223
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
209
224
|
|
|
210
225
|
const map = { };
|
|
211
226
|
|