@barchart/portfolio-api-common 1.0.72 → 1.0.76
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.
|
@@ -13,15 +13,23 @@ module.exports = (() => {
|
|
|
13
13
|
* @param {String} alternateDescription
|
|
14
14
|
* @param {String} code
|
|
15
15
|
* @param {Boolean} canReinvest
|
|
16
|
+
* @param {Boolean} usesSymbols
|
|
16
17
|
*/
|
|
17
18
|
class InstrumentType extends Enum {
|
|
18
|
-
constructor(code, description, alternateDescription, canReinvest) {
|
|
19
|
+
constructor(code, description, alternateDescription, canReinvest, usesSymbols) {
|
|
19
20
|
super(code, description);
|
|
20
21
|
|
|
21
22
|
this._alternateDescription = alternateDescription;
|
|
22
23
|
this._canReinvest = canReinvest;
|
|
24
|
+
this._usesSymbols = usesSymbols;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* A human-readable description.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @return {String}
|
|
32
|
+
*/
|
|
25
33
|
get alternateDescription() {
|
|
26
34
|
return this._alternateDescription;
|
|
27
35
|
}
|
|
@@ -29,16 +37,28 @@ module.exports = (() => {
|
|
|
29
37
|
/**
|
|
30
38
|
* Indicates if the instrument type allows automatic reinvestment.
|
|
31
39
|
*
|
|
40
|
+
* @public
|
|
32
41
|
* @returns {Boolean}
|
|
33
42
|
*/
|
|
34
43
|
get canReinvest() {
|
|
35
44
|
return this._canReinvest;
|
|
36
45
|
}
|
|
37
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Indicates if an instrument of this type can be represented by a symbol.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @returns {Boolean}
|
|
52
|
+
*/
|
|
53
|
+
get usesSymbols() {
|
|
54
|
+
return this._usesSymbols;
|
|
55
|
+
}
|
|
56
|
+
|
|
38
57
|
/**
|
|
39
58
|
* Cash.
|
|
40
59
|
*
|
|
41
60
|
* @public
|
|
61
|
+
* @static
|
|
42
62
|
* @returns {InstrumentType}
|
|
43
63
|
*/
|
|
44
64
|
static get CASH() {
|
|
@@ -49,6 +69,7 @@ module.exports = (() => {
|
|
|
49
69
|
* An equity issue.
|
|
50
70
|
*
|
|
51
71
|
* @public
|
|
72
|
+
* @static
|
|
52
73
|
* @returns {InstrumentType}
|
|
53
74
|
*/
|
|
54
75
|
static get EQUITY() {
|
|
@@ -59,6 +80,7 @@ module.exports = (() => {
|
|
|
59
80
|
* A mutual fund.
|
|
60
81
|
*
|
|
61
82
|
* @public
|
|
83
|
+
* @static
|
|
62
84
|
* @returns {InstrumentType}
|
|
63
85
|
*/
|
|
64
86
|
static get FUND() {
|
|
@@ -69,6 +91,7 @@ module.exports = (() => {
|
|
|
69
91
|
* An undefined asset (e.g. a house, or a collectible, or a salvaged alien spaceship).
|
|
70
92
|
*
|
|
71
93
|
* @public
|
|
94
|
+
* @static
|
|
72
95
|
* @returns {InstrumentType}
|
|
73
96
|
*/
|
|
74
97
|
static get OTHER() {
|
|
@@ -80,10 +103,10 @@ module.exports = (() => {
|
|
|
80
103
|
}
|
|
81
104
|
}
|
|
82
105
|
|
|
83
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false);
|
|
84
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true);
|
|
85
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true);
|
|
86
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false);
|
|
106
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false);
|
|
107
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true);
|
|
108
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, true);
|
|
109
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false);
|
|
87
110
|
|
|
88
111
|
return InstrumentType;
|
|
89
112
|
})();
|
|
@@ -249,7 +249,6 @@ module.exports = (() => {
|
|
|
249
249
|
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
250
250
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
251
251
|
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
252
|
-
.withField('currency', DataType.forEnum(Currency, 'Currency'))
|
|
253
252
|
.withField('date', DataType.DAY)
|
|
254
253
|
.withField('price', DataType.DECIMAL)
|
|
255
254
|
.withField('quantity', DataType.DECIMAL)
|
|
@@ -388,11 +387,8 @@ module.exports = (() => {
|
|
|
388
387
|
.withField('portfolio', DataType.STRING)
|
|
389
388
|
.withField('position', DataType.STRING)
|
|
390
389
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
391
|
-
.withField('instrument.name', DataType.STRING, true)
|
|
392
390
|
.withField('instrument.type', DataType.STRING, true)
|
|
393
391
|
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
394
|
-
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
395
|
-
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
396
392
|
.withField('date', DataType.DAY)
|
|
397
393
|
.withField('amount', DataType.DECIMAL)
|
|
398
394
|
.withField('fee', DataType.DECIMAL, true)
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -14,15 +14,23 @@ module.exports = (() => {
|
|
|
14
14
|
* @param {String} alternateDescription
|
|
15
15
|
* @param {String} code
|
|
16
16
|
* @param {Boolean} canReinvest
|
|
17
|
+
* @param {Boolean} usesSymbols
|
|
17
18
|
*/
|
|
18
19
|
class InstrumentType extends Enum {
|
|
19
|
-
constructor(code, description, alternateDescription, canReinvest) {
|
|
20
|
+
constructor(code, description, alternateDescription, canReinvest, usesSymbols) {
|
|
20
21
|
super(code, description);
|
|
21
22
|
|
|
22
23
|
this._alternateDescription = alternateDescription;
|
|
23
24
|
this._canReinvest = canReinvest;
|
|
25
|
+
this._usesSymbols = usesSymbols;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A human-readable description.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
* @return {String}
|
|
33
|
+
*/
|
|
26
34
|
get alternateDescription() {
|
|
27
35
|
return this._alternateDescription;
|
|
28
36
|
}
|
|
@@ -30,16 +38,28 @@ module.exports = (() => {
|
|
|
30
38
|
/**
|
|
31
39
|
* Indicates if the instrument type allows automatic reinvestment.
|
|
32
40
|
*
|
|
41
|
+
* @public
|
|
33
42
|
* @returns {Boolean}
|
|
34
43
|
*/
|
|
35
44
|
get canReinvest() {
|
|
36
45
|
return this._canReinvest;
|
|
37
46
|
}
|
|
38
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Indicates if an instrument of this type can be represented by a symbol.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
* @returns {Boolean}
|
|
53
|
+
*/
|
|
54
|
+
get usesSymbols() {
|
|
55
|
+
return this._usesSymbols;
|
|
56
|
+
}
|
|
57
|
+
|
|
39
58
|
/**
|
|
40
59
|
* Cash.
|
|
41
60
|
*
|
|
42
61
|
* @public
|
|
62
|
+
* @static
|
|
43
63
|
* @returns {InstrumentType}
|
|
44
64
|
*/
|
|
45
65
|
static get CASH() {
|
|
@@ -50,6 +70,7 @@ module.exports = (() => {
|
|
|
50
70
|
* An equity issue.
|
|
51
71
|
*
|
|
52
72
|
* @public
|
|
73
|
+
* @static
|
|
53
74
|
* @returns {InstrumentType}
|
|
54
75
|
*/
|
|
55
76
|
static get EQUITY() {
|
|
@@ -60,6 +81,7 @@ module.exports = (() => {
|
|
|
60
81
|
* A mutual fund.
|
|
61
82
|
*
|
|
62
83
|
* @public
|
|
84
|
+
* @static
|
|
63
85
|
* @returns {InstrumentType}
|
|
64
86
|
*/
|
|
65
87
|
static get FUND() {
|
|
@@ -70,6 +92,7 @@ module.exports = (() => {
|
|
|
70
92
|
* An undefined asset (e.g. a house, or a collectible, or a salvaged alien spaceship).
|
|
71
93
|
*
|
|
72
94
|
* @public
|
|
95
|
+
* @static
|
|
73
96
|
* @returns {InstrumentType}
|
|
74
97
|
*/
|
|
75
98
|
static get OTHER() {
|
|
@@ -81,10 +104,10 @@ module.exports = (() => {
|
|
|
81
104
|
}
|
|
82
105
|
}
|
|
83
106
|
|
|
84
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false);
|
|
85
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true);
|
|
86
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true);
|
|
87
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false);
|
|
107
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false);
|
|
108
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true);
|
|
109
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, true);
|
|
110
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false);
|
|
88
111
|
|
|
89
112
|
return InstrumentType;
|
|
90
113
|
})();
|
|
@@ -331,7 +354,7 @@ module.exports = (() => {
|
|
|
331
354
|
}
|
|
332
355
|
|
|
333
356
|
function getYearToDateRangeDescription(startDate, endDate) {
|
|
334
|
-
return
|
|
357
|
+
return `${endDate.year.toString()} YTD`;
|
|
335
358
|
}
|
|
336
359
|
|
|
337
360
|
function getFilteredTransactions(transactions) {
|