@barchart/portfolio-api-common 1.3.9 → 1.3.13
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.
|
@@ -126,6 +126,7 @@ module.exports = (() => {
|
|
|
126
126
|
f.code = t.type.code;
|
|
127
127
|
f.sequence = t.sequence;
|
|
128
128
|
f.position = t.position;
|
|
129
|
+
f.open = t.snapshot.open;
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
const averageCostFormatter = (t, f) => {
|
|
@@ -151,53 +152,87 @@ module.exports = (() => {
|
|
|
151
152
|
};
|
|
152
153
|
|
|
153
154
|
const dividendFormatter = (t, f) => {
|
|
154
|
-
f.shares = t.snapshot.open;
|
|
155
155
|
f.total = t.dividend.amount;
|
|
156
156
|
f.rate = t.dividend.rate;
|
|
157
|
+
|
|
158
|
+
f.shares = t.dividend.amount.divide(t.dividend.rate);
|
|
157
159
|
};
|
|
158
160
|
|
|
159
|
-
const
|
|
160
|
-
f.
|
|
161
|
-
f.
|
|
161
|
+
const distributionCashFormatter = (t, f) => {
|
|
162
|
+
f.total = t.dividend.amount;
|
|
163
|
+
f.rate = t.dividend.rate;
|
|
162
164
|
|
|
163
|
-
|
|
164
|
-
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
165
|
-
f.price = t.dividend.price;
|
|
166
|
-
f.rate = t.dividend.rate;
|
|
167
|
-
}
|
|
165
|
+
f.shares = t.dividend.amount.divide(t.dividend.rate);
|
|
168
166
|
};
|
|
169
167
|
|
|
170
168
|
const dividendReinvestFormatter = (t, f) => {
|
|
171
169
|
f.boughtSold = t.quantity;
|
|
172
|
-
|
|
170
|
+
|
|
171
|
+
if (f.fee && !f.fee.getIsZero()) {
|
|
172
|
+
f.fee = t.fee;
|
|
173
|
+
}
|
|
174
|
+
|
|
173
175
|
f.price = t.dividend.price;
|
|
174
|
-
f.fee = t.fee;
|
|
175
176
|
f.rate = t.dividend.rate;
|
|
177
|
+
|
|
178
|
+
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
176
179
|
};
|
|
177
180
|
|
|
178
|
-
const
|
|
179
|
-
f.
|
|
180
|
-
|
|
181
|
+
const distributionReinvestFormatter = (t, f) => {
|
|
182
|
+
f.boughtSold = t.quantity;
|
|
183
|
+
|
|
184
|
+
if (f.fee && !f.fee.getIsZero()) {
|
|
185
|
+
f.fee = t.fee;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
f.price = t.dividend.price;
|
|
181
189
|
f.rate = t.dividend.rate;
|
|
190
|
+
|
|
191
|
+
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
182
192
|
};
|
|
183
193
|
|
|
184
|
-
const
|
|
185
|
-
f.boughtSold =t.quantity;
|
|
186
|
-
|
|
194
|
+
const dividendStockFormatter = (t, f) => {
|
|
195
|
+
f.boughtSold = t.quantity;
|
|
196
|
+
|
|
197
|
+
if (f.fee && !f.fee.getIsZero()) {
|
|
198
|
+
f.fee = t.fee;
|
|
199
|
+
}
|
|
187
200
|
|
|
188
|
-
if (t.dividend
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
if (t.dividend) {
|
|
202
|
+
if (t.dividend.numerator && t.dividend.denominator) {
|
|
203
|
+
f.rate = t.dividend.numerator.divide(t.dividend.denominator);
|
|
204
|
+
} else if (t.dividend.rate) {
|
|
205
|
+
f.rate = t.dividend.rate;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (t.dividend.price) {
|
|
209
|
+
f.price = t.dividend.price;
|
|
210
|
+
}
|
|
192
211
|
}
|
|
212
|
+
|
|
213
|
+
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
193
214
|
};
|
|
194
215
|
|
|
195
|
-
const
|
|
216
|
+
const distributionFundFormatter = (t, f) => {
|
|
196
217
|
f.boughtSold = t.quantity;
|
|
218
|
+
|
|
219
|
+
if (f.fee && !f.fee.getIsZero()) {
|
|
220
|
+
f.fee = t.fee;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (t.dividend) {
|
|
224
|
+
if (t.dividend.numerator && t.dividend.denominator) {
|
|
225
|
+
f.rate = t.dividend.numerator.divide(t.dividend.denominator);
|
|
226
|
+
} else if (t.dividend.rate) {
|
|
227
|
+
f.rate = t.dividend.rate;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (t.dividend.price) {
|
|
231
|
+
f.price = t.dividend.price;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
197
235
|
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
198
|
-
f.price = t.dividend.price;
|
|
199
|
-
f.fee = t.fee;
|
|
200
|
-
f.rate = t.dividend.rate;
|
|
201
236
|
};
|
|
202
237
|
|
|
203
238
|
const incomeFormatter = (t, f) => {
|
|
@@ -214,8 +249,11 @@ module.exports = (() => {
|
|
|
214
249
|
};
|
|
215
250
|
|
|
216
251
|
const splitFormatter = (t, f) => {
|
|
217
|
-
f.
|
|
252
|
+
f.boughtSold = t.quantity;
|
|
253
|
+
|
|
218
254
|
f.rate = t.split.numerator.divide(t.split.denominator);
|
|
255
|
+
|
|
256
|
+
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
219
257
|
};
|
|
220
258
|
|
|
221
259
|
const valuationFormatter = (t, f) => {
|
|
@@ -1,148 +1,148 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
-
|
|
2
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
3
3
|
|
|
4
4
|
module.exports = (() => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
* Action type for deleting position.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
* @static
|
|
117
|
+
* @returns {WebsocketActionType}
|
|
118
|
+
*/
|
|
119
|
+
static get POSITION_DELETE() {
|
|
120
|
+
return positionDelete;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Action type for updating position.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
* @static
|
|
128
|
+
* @returns {WebsocketActionType}
|
|
129
|
+
*/
|
|
130
|
+
static get POSITION_UPDATE() {
|
|
131
|
+
return positionUpdate;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const portfolioCreate = new WebsocketActionType('PORTFOLIO_CREATE', 'Create portfolio action', 'portfolio/create');
|
|
136
|
+
const portfolioDelete = new WebsocketActionType('PORTFOLIO_DELETE', 'Delete portfolio action', 'portfolio/delete');
|
|
137
|
+
const portfolioUpdate = new WebsocketActionType('PORTFOLIO_UPDATE', 'Update portfolio action', 'portfolio/update');
|
|
138
|
+
|
|
139
|
+
const transactionCreate = new WebsocketActionType('TRANSACTION_CREATE', 'Create transaction action', 'transaction/create');
|
|
140
|
+
const transactionDelete = new WebsocketActionType('TRANSACTION_DELETE', 'Delete transaction action', 'transaction/delete');
|
|
141
|
+
const transactionEdit = new WebsocketActionType('TRANSACTION_EDIT', 'Edit transaction action', 'transaction/edit');
|
|
142
|
+
const transactionBatch = new WebsocketActionType('TRANSACTION_BATCH', 'Batch transaction action', 'transaction/batch');
|
|
143
|
+
|
|
144
|
+
const positionDelete = new WebsocketActionType('POSITION_DELETE', 'Delete position action', 'position/delete');
|
|
145
|
+
const positionUpdate = new WebsocketActionType('POSITION_UPDATE', 'Update position action', 'position/update');
|
|
146
|
+
|
|
147
|
+
return WebsocketActionType;
|
|
148
148
|
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -5888,8 +5888,7 @@ module.exports = (() => {
|
|
|
5888
5888
|
})();
|
|
5889
5889
|
|
|
5890
5890
|
},{"./../../lang/Disposable":23,"./../../lang/assert":29,"./../../lang/is":33,"./../Stack":14}],19:[function(require,module,exports){
|
|
5891
|
-
const assert = require('./assert')
|
|
5892
|
-
is = require('./is');
|
|
5891
|
+
const assert = require('./assert');
|
|
5893
5892
|
|
|
5894
5893
|
module.exports = (() => {
|
|
5895
5894
|
'use strict';
|
|
@@ -5952,7 +5951,7 @@ module.exports = (() => {
|
|
|
5952
5951
|
return AdHoc;
|
|
5953
5952
|
})();
|
|
5954
5953
|
|
|
5955
|
-
},{"./assert":29
|
|
5954
|
+
},{"./assert":29}],20:[function(require,module,exports){
|
|
5956
5955
|
const assert = require('./assert'),
|
|
5957
5956
|
Enum = require('./Enum'),
|
|
5958
5957
|
is = require('./is');
|
|
@@ -8856,8 +8855,7 @@ module.exports = (() => {
|
|
|
8856
8855
|
})();
|
|
8857
8856
|
|
|
8858
8857
|
},{}],34:[function(require,module,exports){
|
|
8859
|
-
const assert = require('./assert')
|
|
8860
|
-
is = require('./is');
|
|
8858
|
+
const assert = require('./assert');
|
|
8861
8859
|
|
|
8862
8860
|
module.exports = (() => {
|
|
8863
8861
|
'use strict';
|
|
@@ -8925,7 +8923,7 @@ module.exports = (() => {
|
|
|
8925
8923
|
};
|
|
8926
8924
|
})();
|
|
8927
8925
|
|
|
8928
|
-
},{"./assert":29
|
|
8926
|
+
},{"./assert":29}],35:[function(require,module,exports){
|
|
8929
8927
|
const assert = require('./../lang/assert'),
|
|
8930
8928
|
Disposable = require('./../lang/Disposable');
|
|
8931
8929
|
|