@barchart/portfolio-api-common 1.3.14 → 1.3.18
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.
|
@@ -285,14 +285,14 @@ module.exports = (() => {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
const portfolioUpdateFailedNoPortfolio = new FailureType('PORTFOLIO_UPDATE_FAILED_NO_PORTFOLIO', 'Unable to update portfolio. The portfolio does not exist, has it been deleted?');
|
|
289
|
-
const portfolioDeleteFailedNoPortfolio = new FailureType('PORTFOLIO_DELETE_FAILED_NO_PORTFOLIO', 'Unable to delete portfolio. The portfolio does not exist, has it already been deleted?');
|
|
288
|
+
const portfolioUpdateFailedNoPortfolio = new FailureType('PORTFOLIO_UPDATE_FAILED_NO_PORTFOLIO', 'Unable to update portfolio. The portfolio does not exist, has it been deleted?', false);
|
|
289
|
+
const portfolioDeleteFailedNoPortfolio = new FailureType('PORTFOLIO_DELETE_FAILED_NO_PORTFOLIO', 'Unable to delete portfolio. The portfolio does not exist, has it already been deleted?', false);
|
|
290
290
|
|
|
291
|
-
const positionCreateFailedNoPortfolio = new FailureType('POSITION_CREATE_FAILED_NO_PORTFOLIO', 'Unable to create transaction. The portfolio does not exist, has it been deleted?');
|
|
292
|
-
const positionUpdateFailedNoPosition = new FailureType('POSITION_UPDATE_FAILED_NO_POSITION', 'Unable to update preferences for position. The position does not exist, has it been deleted?');
|
|
291
|
+
const positionCreateFailedNoPortfolio = new FailureType('POSITION_CREATE_FAILED_NO_PORTFOLIO', 'Unable to create transaction. The portfolio does not exist, has it been deleted?', false);
|
|
292
|
+
const positionUpdateFailedNoPosition = new FailureType('POSITION_UPDATE_FAILED_NO_POSITION', 'Unable to update preferences for position. The position does not exist, has it been deleted?', false);
|
|
293
293
|
const positionDeleteFailedPositionLocked = new FailureType('POSITION_DELETE_FAILED_POSITION_LOCKED', 'Unable to delete position, your {L|description} history is being recalculated. Please wait a minute or two and retry.');
|
|
294
294
|
|
|
295
|
-
const transactionCreateFailedNoPosition = new FailureType('TRANSACTION_CREATE_FAILED_NO_POSITION', 'Unable to create transaction. The referenced position does not exist. Has it been deleted?');
|
|
295
|
+
const transactionCreateFailedNoPosition = new FailureType('TRANSACTION_CREATE_FAILED_NO_POSITION', 'Unable to create transaction. The referenced position does not exist. Has it been deleted?', false);
|
|
296
296
|
const transactionCreateFailedOutOfSequence = new FailureType('TRANSACTION_CREATE_FAILED_OUT_OF_SEQUENCE', 'Unable to process transaction, because the transaction date is out-of-sequence. In other words, it would occur before an existing transaction. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
|
|
297
297
|
const transactionCreateFailedInvalidDate = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_DATE', 'Unable to process transaction with given date.');
|
|
298
298
|
const transactionCreateFailedTypeInvalidForInstrument = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_INVALID_FOR_INSTRUMENT', 'Unable to process transaction, {L|transactionType.description} transactions cannot be used with {L|instrumentType.description} positions.');
|
|
@@ -155,14 +155,30 @@ module.exports = (() => {
|
|
|
155
155
|
f.total = t.dividend.amount;
|
|
156
156
|
f.rate = t.dividend.rate;
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
let shares;
|
|
159
|
+
|
|
160
|
+
if (!t.dividend.rate.getIsZero()) {
|
|
161
|
+
shares = t.dividend.amount.divide(t.dividend.rate);
|
|
162
|
+
} else {
|
|
163
|
+
shares = '';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
f.shares = shares;
|
|
159
167
|
};
|
|
160
168
|
|
|
161
169
|
const distributionCashFormatter = (t, f) => {
|
|
162
170
|
f.total = t.dividend.amount;
|
|
163
171
|
f.rate = t.dividend.rate;
|
|
164
172
|
|
|
165
|
-
|
|
173
|
+
let shares;
|
|
174
|
+
|
|
175
|
+
if (!t.dividend.rate.getIsZero()) {
|
|
176
|
+
shares = t.dividend.amount.divide(t.dividend.rate);
|
|
177
|
+
} else {
|
|
178
|
+
shares = '';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
f.shares = shares;
|
|
166
182
|
};
|
|
167
183
|
|
|
168
184
|
const dividendReinvestFormatter = (t, f) => {
|
|
@@ -199,12 +215,20 @@ module.exports = (() => {
|
|
|
199
215
|
}
|
|
200
216
|
|
|
201
217
|
if (t.dividend) {
|
|
218
|
+
let rate;
|
|
219
|
+
|
|
202
220
|
if (t.dividend.numerator && t.dividend.denominator) {
|
|
203
|
-
|
|
221
|
+
if (!t.dividend.denominator.getIsZero()) {
|
|
222
|
+
rate = t.dividend.numerator.divide(t.dividend.denominator);
|
|
223
|
+
} else {
|
|
224
|
+
rate = '';
|
|
225
|
+
}
|
|
204
226
|
} else if (t.dividend.rate) {
|
|
205
|
-
|
|
227
|
+
rate = t.dividend.rate;
|
|
206
228
|
}
|
|
207
229
|
|
|
230
|
+
f.rate = rate;
|
|
231
|
+
|
|
208
232
|
if (t.dividend.price) {
|
|
209
233
|
f.price = t.dividend.price;
|
|
210
234
|
}
|
|
@@ -221,12 +245,20 @@ module.exports = (() => {
|
|
|
221
245
|
}
|
|
222
246
|
|
|
223
247
|
if (t.dividend) {
|
|
248
|
+
let rate;
|
|
249
|
+
|
|
224
250
|
if (t.dividend.numerator && t.dividend.denominator) {
|
|
225
|
-
|
|
251
|
+
if (!t.dividend.denominator.getIsZero()) {
|
|
252
|
+
rate = t.dividend.numerator.divide(t.dividend.denominator);
|
|
253
|
+
} else {
|
|
254
|
+
rate = '';
|
|
255
|
+
}
|
|
226
256
|
} else if (t.dividend.rate) {
|
|
227
|
-
|
|
257
|
+
rate = t.dividend.rate;
|
|
228
258
|
}
|
|
229
259
|
|
|
260
|
+
f.rate = rate;
|
|
261
|
+
|
|
230
262
|
if (t.dividend.price) {
|
|
231
263
|
f.price = t.dividend.price;
|
|
232
264
|
}
|
|
@@ -251,7 +283,15 @@ module.exports = (() => {
|
|
|
251
283
|
const splitFormatter = (t, f) => {
|
|
252
284
|
f.boughtSold = t.quantity;
|
|
253
285
|
|
|
254
|
-
|
|
286
|
+
let rate;
|
|
287
|
+
|
|
288
|
+
if (!t.split.denominator.getIsZero()) {
|
|
289
|
+
rate = t.split.numerator.divide(t.split.denominator);
|
|
290
|
+
} else {
|
|
291
|
+
rate = '';
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
f.rate = rate;
|
|
255
295
|
|
|
256
296
|
f.shares = t.snapshot.open.subtract(t.quantity);
|
|
257
297
|
};
|
|
@@ -264,7 +304,11 @@ module.exports = (() => {
|
|
|
264
304
|
} else if (t.snapshot.open.getIsZero()) {
|
|
265
305
|
rate = null;
|
|
266
306
|
} else {
|
|
267
|
-
|
|
307
|
+
if (!t.snapshot.open.getIsZero()) {
|
|
308
|
+
rate = t.valuation.value.divide(t.snapshot.open);
|
|
309
|
+
} else {
|
|
310
|
+
rate = '';
|
|
311
|
+
}
|
|
268
312
|
}
|
|
269
313
|
|
|
270
314
|
f.price = rate;
|
|
@@ -54,6 +54,18 @@ module.exports = (() => {
|
|
|
54
54
|
return client;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Reduced schema that only includes frames and dates -- allowing consumer
|
|
59
|
+
* to detect existence (or non-existence) of summary.
|
|
60
|
+
*
|
|
61
|
+
* @static
|
|
62
|
+
* @public
|
|
63
|
+
* @returns {PositionSummarySchema}
|
|
64
|
+
*/
|
|
65
|
+
static get EXISTS() {
|
|
66
|
+
return exists;
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
toString() {
|
|
58
70
|
return '[PositionSummarySchema]';
|
|
59
71
|
}
|
|
@@ -111,5 +123,15 @@ module.exports = (() => {
|
|
|
111
123
|
.schema
|
|
112
124
|
);
|
|
113
125
|
|
|
126
|
+
const exists = new PositionSummarySchema(SchemaBuilder.withName('complete')
|
|
127
|
+
.withField('user', DataType.STRING)
|
|
128
|
+
.withField('portfolio', DataType.STRING)
|
|
129
|
+
.withField('position', DataType.STRING)
|
|
130
|
+
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
131
|
+
.withField('start.date', DataType.DAY)
|
|
132
|
+
.withField('end.date', DataType.DAY)
|
|
133
|
+
.schema
|
|
134
|
+
);
|
|
135
|
+
|
|
114
136
|
return PositionSummarySchema;
|
|
115
137
|
})();
|