@barchart/portfolio-api-common 1.3.7 → 1.3.8
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 +1 -1
- package/lib/processing/PositionContainer.js +2 -3
- package/lib/processing/definitions/PositionLevelDefinition.js +4 -4
- package/lib/processing/definitions/PositionLevelType.js +30 -0
- package/lib/processing/definitions/PositionTreeDefinition.js +2 -2
- package/lib/websockets/WebsocketActionType.js +123 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +39 -10
|
@@ -41,8 +41,8 @@ module.exports = (() => {
|
|
|
41
41
|
* @public
|
|
42
42
|
* @param {PositionTreeDefinition[]} definitions
|
|
43
43
|
* @param {Object[]} portfolios - The portfolios.
|
|
44
|
-
* @param {Object[]} positions - The positions (for all of
|
|
45
|
-
* @param {Object[]} summaries - The positions summaries (for all of
|
|
44
|
+
* @param {Object[]} positions - The positions (for all of portfolios).
|
|
45
|
+
* @param {Object[]} summaries - The positions summaries (for all of positions).
|
|
46
46
|
* @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
|
|
47
47
|
* @param {Day=} reportDate - The end date for the report frame.
|
|
48
48
|
*/
|
|
@@ -933,7 +933,6 @@ module.exports = (() => {
|
|
|
933
933
|
});
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
-
|
|
937
936
|
function updateEmptyPortfolioGroups(portfolio) {
|
|
938
937
|
Object.keys(this._trees).forEach((key) => {
|
|
939
938
|
this._trees[key].walk((group) => {
|
|
@@ -74,7 +74,7 @@ module.exports = (() => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* A function, when given a {@link PositionItem} returns a string that is used
|
|
77
|
+
* A function, when given a {@link PositionItem}, returns a string that is used
|
|
78
78
|
* to group {@link PositionItem} instances into different groups.
|
|
79
79
|
*
|
|
80
80
|
* @public
|
|
@@ -85,7 +85,7 @@ module.exports = (() => {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* A function, when given a {@link PositionItem} returns a string used to describe the
|
|
88
|
+
* A function, when given a {@link PositionItem}, returns a string used to describe the
|
|
89
89
|
* group.
|
|
90
90
|
*
|
|
91
91
|
* @public
|
|
@@ -96,7 +96,7 @@ module.exports = (() => {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* A function, when given a {@link PositionItem} returns the {@link Currency} used to
|
|
99
|
+
* A function, when given a {@link PositionItem}, returns the {@link Currency} used to
|
|
100
100
|
* display values for the group.
|
|
101
101
|
*
|
|
102
102
|
* @public
|
|
@@ -111,7 +111,7 @@ module.exports = (() => {
|
|
|
111
111
|
* groups.
|
|
112
112
|
*
|
|
113
113
|
* @public
|
|
114
|
-
* @returns {
|
|
114
|
+
* @returns {String[]}
|
|
115
115
|
*/
|
|
116
116
|
get requiredGroups() {
|
|
117
117
|
return this._requiredGroups;
|
|
@@ -3,19 +3,49 @@ const Enum = require('@barchart/common-js/lang/Enum');
|
|
|
3
3
|
module.exports = (() => {
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Describes the contents of a grouping level within a tree of positions.
|
|
8
|
+
* This is an attribute of a {@link PositionLevelDefinition}.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @extends {Enum}
|
|
12
|
+
*/
|
|
6
13
|
class PositionLevelType extends Enum {
|
|
7
14
|
constructor(code) {
|
|
8
15
|
super(code, code);
|
|
9
16
|
}
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A level of grouping that represents an entire portfolio's contents.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
* @static
|
|
23
|
+
* @returns {PositionLevelType}
|
|
24
|
+
*/
|
|
11
25
|
static get PORTFOLIO() {
|
|
12
26
|
return portfolio;
|
|
13
27
|
}
|
|
14
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A level of grouping that represents a single positions (i.e. guaranteed to
|
|
31
|
+
* be a leaf node in a grouping tree).
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @static
|
|
35
|
+
* @return {PositionLevelType}
|
|
36
|
+
*/
|
|
15
37
|
static get POSITION() {
|
|
16
38
|
return position;
|
|
17
39
|
}
|
|
18
40
|
|
|
41
|
+
/**
|
|
42
|
+
* A level of grouping that is neither a portfolio or a position. This could be an
|
|
43
|
+
* intermediate level of grouping (e.g. an asset class within a portfolio).
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
* @static
|
|
47
|
+
* @return {PositionLevelType}
|
|
48
|
+
*/
|
|
19
49
|
static get OTHER() {
|
|
20
50
|
return other;
|
|
21
51
|
}
|
|
@@ -11,7 +11,7 @@ module.exports = (() => {
|
|
|
11
11
|
* @public
|
|
12
12
|
* @param {String} name
|
|
13
13
|
* @param {PositionLevelDefinition[]} definitions
|
|
14
|
-
* @
|
|
14
|
+
* @param {String[]=} exclusionDependencies
|
|
15
15
|
*/
|
|
16
16
|
class PositionTreeDefinitions {
|
|
17
17
|
constructor(name, definitions, exclusionDependencies) {
|
|
@@ -44,7 +44,7 @@ module.exports = (() => {
|
|
|
44
44
|
* bottom-most level of the tree (i.e. leaf nodes).
|
|
45
45
|
*
|
|
46
46
|
* @public
|
|
47
|
-
* @returns {PositionLevelDefinitions
|
|
47
|
+
* @returns {PositionLevelDefinitions[]}
|
|
48
48
|
*/
|
|
49
49
|
get definitions() {
|
|
50
50
|
return this._definitions;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
3
|
+
|
|
4
|
+
module.exports = (() => {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types of websocket response actions.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @extends {Enum}
|
|
12
|
+
* @param {String} code
|
|
13
|
+
* @param {String} description
|
|
14
|
+
* @param {String} action
|
|
15
|
+
*/
|
|
16
|
+
class WebsocketActionType extends Enum {
|
|
17
|
+
constructor(code, description, action) {
|
|
18
|
+
super(code, description);
|
|
19
|
+
|
|
20
|
+
assert.argumentIsRequired(action, 'action', String);
|
|
21
|
+
|
|
22
|
+
this._action = action;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An action of websocket response
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @returns {String}
|
|
30
|
+
*/
|
|
31
|
+
get action() {
|
|
32
|
+
return this._action;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Action type for creating new portfolio.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @static
|
|
40
|
+
* @returns {WebsocketActionType}
|
|
41
|
+
*/
|
|
42
|
+
static get PORTFOLIO_CREATE() {
|
|
43
|
+
return portfolioCreate;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Action type for deleting portfolio.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
* @static
|
|
51
|
+
* @returns {WebsocketActionType}
|
|
52
|
+
*/
|
|
53
|
+
static get PORTFOLIO_DELETE() {
|
|
54
|
+
return portfolioDelete;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Action type for updating new portfolio.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @static
|
|
62
|
+
* @returns {WebsocketActionType}
|
|
63
|
+
*/
|
|
64
|
+
static get PORTFOLIO_UPDATE() {
|
|
65
|
+
return portfolioUpdate;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Action type for creating new transaction.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
* @static
|
|
73
|
+
* @returns {WebsocketActionType}
|
|
74
|
+
*/
|
|
75
|
+
static get TRANSACTION_CREATE() {
|
|
76
|
+
return transactionCreate;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Action type for deleting transaction.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
* @static
|
|
84
|
+
* @returns {WebsocketActionType}
|
|
85
|
+
*/
|
|
86
|
+
static get TRANSACTION_DELETE() {
|
|
87
|
+
return transactionDelete;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Action type for editing transaction.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @static
|
|
95
|
+
* @returns {WebsocketActionType}
|
|
96
|
+
*/
|
|
97
|
+
static get TRANSACTION_EDIT() {
|
|
98
|
+
return transactionEdit;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Action type for batching transaction.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @static
|
|
106
|
+
* @returns {WebsocketActionType}
|
|
107
|
+
*/
|
|
108
|
+
static get TRANSACTION_BATCH() {
|
|
109
|
+
return transactionBatch;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const portfolioCreate = new WebsocketActionType('PORTFOLIO_CREATE', 'Create portfolio action', 'portfolio/create');
|
|
114
|
+
const portfolioDelete = new WebsocketActionType('PORTFOLIO_DELETE', 'Delete portfolio action', 'portfolio/delete');
|
|
115
|
+
const portfolioUpdate = new WebsocketActionType('PORTFOLIO_UPDATE', 'Update portfolio action', 'portfolio/update');
|
|
116
|
+
|
|
117
|
+
const transactionCreate = new WebsocketActionType('TRANSACTION_CREATE', 'Create transaction action', 'transaction/create');
|
|
118
|
+
const transactionDelete = new WebsocketActionType('TRANSACTION_DELETE', 'Delete transaction action', 'transaction/delete');
|
|
119
|
+
const transactionEdit = new WebsocketActionType('TRANSACTION_EDIT', 'Edit transaction action', 'transaction/edit');
|
|
120
|
+
const transactionBatch = new WebsocketActionType('TRANSACTION_BATCH', 'Batch transaction action', 'transaction/batch');
|
|
121
|
+
|
|
122
|
+
return WebsocketActionType;
|
|
123
|
+
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -237,7 +237,7 @@ module.exports = (() => {
|
|
|
237
237
|
*
|
|
238
238
|
* @public
|
|
239
239
|
* @static
|
|
240
|
-
* @param code
|
|
240
|
+
* @param {Number} code
|
|
241
241
|
* @returns {InstrumentType}
|
|
242
242
|
*/
|
|
243
243
|
static fromSymbolType(code) {
|
|
@@ -1527,8 +1527,8 @@ module.exports = (() => {
|
|
|
1527
1527
|
* @public
|
|
1528
1528
|
* @param {PositionTreeDefinition[]} definitions
|
|
1529
1529
|
* @param {Object[]} portfolios - The portfolios.
|
|
1530
|
-
* @param {Object[]} positions - The positions (for all of
|
|
1531
|
-
* @param {Object[]} summaries - The positions summaries (for all of
|
|
1530
|
+
* @param {Object[]} positions - The positions (for all of portfolios).
|
|
1531
|
+
* @param {Object[]} summaries - The positions summaries (for all of positions).
|
|
1532
1532
|
* @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
|
|
1533
1533
|
* @param {Day=} reportDate - The end date for the report frame.
|
|
1534
1534
|
*/
|
|
@@ -2419,7 +2419,6 @@ module.exports = (() => {
|
|
|
2419
2419
|
});
|
|
2420
2420
|
}
|
|
2421
2421
|
|
|
2422
|
-
|
|
2423
2422
|
function updateEmptyPortfolioGroups(portfolio) {
|
|
2424
2423
|
Object.keys(this._trees).forEach((key) => {
|
|
2425
2424
|
this._trees[key].walk((group) => {
|
|
@@ -4400,7 +4399,7 @@ module.exports = (() => {
|
|
|
4400
4399
|
}
|
|
4401
4400
|
|
|
4402
4401
|
/**
|
|
4403
|
-
* A function, when given a {@link PositionItem} returns a string that is used
|
|
4402
|
+
* A function, when given a {@link PositionItem}, returns a string that is used
|
|
4404
4403
|
* to group {@link PositionItem} instances into different groups.
|
|
4405
4404
|
*
|
|
4406
4405
|
* @public
|
|
@@ -4411,7 +4410,7 @@ module.exports = (() => {
|
|
|
4411
4410
|
}
|
|
4412
4411
|
|
|
4413
4412
|
/**
|
|
4414
|
-
* A function, when given a {@link PositionItem} returns a string used to describe the
|
|
4413
|
+
* A function, when given a {@link PositionItem}, returns a string used to describe the
|
|
4415
4414
|
* group.
|
|
4416
4415
|
*
|
|
4417
4416
|
* @public
|
|
@@ -4422,7 +4421,7 @@ module.exports = (() => {
|
|
|
4422
4421
|
}
|
|
4423
4422
|
|
|
4424
4423
|
/**
|
|
4425
|
-
* A function, when given a {@link PositionItem} returns the {@link Currency} used to
|
|
4424
|
+
* A function, when given a {@link PositionItem}, returns the {@link Currency} used to
|
|
4426
4425
|
* display values for the group.
|
|
4427
4426
|
*
|
|
4428
4427
|
* @public
|
|
@@ -4437,7 +4436,7 @@ module.exports = (() => {
|
|
|
4437
4436
|
* groups.
|
|
4438
4437
|
*
|
|
4439
4438
|
* @public
|
|
4440
|
-
* @returns {
|
|
4439
|
+
* @returns {String[]}
|
|
4441
4440
|
*/
|
|
4442
4441
|
get requiredGroups() {
|
|
4443
4442
|
return this._requiredGroups;
|
|
@@ -4613,19 +4612,49 @@ const Enum = require('@barchart/common-js/lang/Enum');
|
|
|
4613
4612
|
module.exports = (() => {
|
|
4614
4613
|
'use strict';
|
|
4615
4614
|
|
|
4615
|
+
/**
|
|
4616
|
+
* Describes the contents of a grouping level within a tree of positions.
|
|
4617
|
+
* This is an attribute of a {@link PositionLevelDefinition}.
|
|
4618
|
+
*
|
|
4619
|
+
* @public
|
|
4620
|
+
* @extends {Enum}
|
|
4621
|
+
*/
|
|
4616
4622
|
class PositionLevelType extends Enum {
|
|
4617
4623
|
constructor(code) {
|
|
4618
4624
|
super(code, code);
|
|
4619
4625
|
}
|
|
4620
4626
|
|
|
4627
|
+
/**
|
|
4628
|
+
* A level of grouping that represents an entire portfolio's contents.
|
|
4629
|
+
*
|
|
4630
|
+
* @public
|
|
4631
|
+
* @static
|
|
4632
|
+
* @returns {PositionLevelType}
|
|
4633
|
+
*/
|
|
4621
4634
|
static get PORTFOLIO() {
|
|
4622
4635
|
return portfolio;
|
|
4623
4636
|
}
|
|
4624
4637
|
|
|
4638
|
+
/**
|
|
4639
|
+
* A level of grouping that represents a single positions (i.e. guaranteed to
|
|
4640
|
+
* be a leaf node in a grouping tree).
|
|
4641
|
+
*
|
|
4642
|
+
* @public
|
|
4643
|
+
* @static
|
|
4644
|
+
* @return {PositionLevelType}
|
|
4645
|
+
*/
|
|
4625
4646
|
static get POSITION() {
|
|
4626
4647
|
return position;
|
|
4627
4648
|
}
|
|
4628
4649
|
|
|
4650
|
+
/**
|
|
4651
|
+
* A level of grouping that is neither a portfolio or a position. This could be an
|
|
4652
|
+
* intermediate level of grouping (e.g. an asset class within a portfolio).
|
|
4653
|
+
*
|
|
4654
|
+
* @public
|
|
4655
|
+
* @static
|
|
4656
|
+
* @return {PositionLevelType}
|
|
4657
|
+
*/
|
|
4629
4658
|
static get OTHER() {
|
|
4630
4659
|
return other;
|
|
4631
4660
|
}
|
|
@@ -4652,7 +4681,7 @@ module.exports = (() => {
|
|
|
4652
4681
|
* @public
|
|
4653
4682
|
* @param {String} name
|
|
4654
4683
|
* @param {PositionLevelDefinition[]} definitions
|
|
4655
|
-
* @
|
|
4684
|
+
* @param {String[]=} exclusionDependencies
|
|
4656
4685
|
*/
|
|
4657
4686
|
class PositionTreeDefinitions {
|
|
4658
4687
|
constructor(name, definitions, exclusionDependencies) {
|
|
@@ -4685,7 +4714,7 @@ module.exports = (() => {
|
|
|
4685
4714
|
* bottom-most level of the tree (i.e. leaf nodes).
|
|
4686
4715
|
*
|
|
4687
4716
|
* @public
|
|
4688
|
-
* @returns {PositionLevelDefinitions
|
|
4717
|
+
* @returns {PositionLevelDefinitions[]}
|
|
4689
4718
|
*/
|
|
4690
4719
|
get definitions() {
|
|
4691
4720
|
return this._definitions;
|