@barchart/portfolio-api-common 1.6.0 → 1.9.1
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/.releases/1.6.0.md +1 -1
- package/.releases/1.7.0.md +3 -0
- package/.releases/1.8.0.md +3 -0
- package/.releases/1.9.0.md +4 -0
- package/.releases/1.9.1.md +4 -0
- package/lib/api/failures/PortfolioFailureType.js +40 -2
- package/lib/serialization/TransactionSchema.js +4 -2
- package/package.json +1 -1
- package/test/SpecRunner.js +43 -6
package/.releases/1.6.0.md
CHANGED
|
@@ -212,6 +212,18 @@ module.exports = (() => {
|
|
|
212
212
|
return transactionCreateFailedReinvestPriceUnavailable;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* The transaction failed because a dividends cannot be re-invested
|
|
217
|
+
* for short positions.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
* @static
|
|
221
|
+
* @returns {FailureType}
|
|
222
|
+
*/
|
|
223
|
+
static get TRANSACTION_CREATE_FAILED_REINVEST_INVALID() {
|
|
224
|
+
return transactionCreateFailedReinvestInvalid;
|
|
225
|
+
}
|
|
226
|
+
|
|
215
227
|
/**
|
|
216
228
|
* The transaction failed because a related position is locked.
|
|
217
229
|
*
|
|
@@ -336,8 +348,30 @@ module.exports = (() => {
|
|
|
336
348
|
static get TRANSACTION_EDIT_FAILED_TYPE_CHANGED() {
|
|
337
349
|
return transactionEditFailedTypeChanged;
|
|
338
350
|
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Conversion of transaction type is unsupported.
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
* @static
|
|
357
|
+
* @returns {FailureType}
|
|
358
|
+
*/
|
|
359
|
+
static get TRANSACTION_SWITCH_FAILED_INVALID_CONVERSION() {
|
|
360
|
+
return transactionSwitchFailedInvalidConversion;
|
|
361
|
+
}
|
|
339
362
|
|
|
340
|
-
|
|
363
|
+
/**
|
|
364
|
+
* Conversion of transaction type is not allowed. Dividends (or distributions)
|
|
365
|
+
* cannot be reinvested when the position is short.
|
|
366
|
+
*
|
|
367
|
+
* @public
|
|
368
|
+
* @static
|
|
369
|
+
* @returns {FailureType}
|
|
370
|
+
*/
|
|
371
|
+
static get TRANSACTION_SWITCH_FAILED_INVALID_REINVEST() {
|
|
372
|
+
return transactionSwitchFailedInvalidReinvest;
|
|
373
|
+
}
|
|
374
|
+
|
|
341
375
|
toString() {
|
|
342
376
|
return '[PortfolioFailureType]';
|
|
343
377
|
}
|
|
@@ -364,6 +398,7 @@ module.exports = (() => {
|
|
|
364
398
|
|
|
365
399
|
const transactionCreateFailedTypeReserved = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_RESERVED', 'Unable to create {U|type.description} transaction, this type of transaction is managed by the system.');
|
|
366
400
|
const transactionCreateFailedReinvestPriceUnavailable = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_PRICE_UNAVAILABLE', 'Unable to create transaction, a dividend was paid on {L|day}; however no historical price is available for this day. To successfully create this transaction, please turn off dividend reinvestment for this position.');
|
|
401
|
+
const transactionCreateFailedReinvestInvalid = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_INVALID', 'Unable to create transaction, short positions do not allow dividends to be reinvested.');
|
|
367
402
|
const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction, your {L|description} history is being recalculated. Please re-enter this transaction in a minute or two.');
|
|
368
403
|
const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located. The issue should be corrected within 24 to 48 hours.');
|
|
369
404
|
|
|
@@ -376,7 +411,10 @@ module.exports = (() => {
|
|
|
376
411
|
const transactionEditFailedInvalidDate = new FailureType('TRANSACTION_EDIT_FAILED_INVALID_DATE', 'Unable to edit transaction with given date.');
|
|
377
412
|
const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.', false);
|
|
378
413
|
const transactionEditFailedTypeReserved = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_RESERVED', 'Unable to edit {U|type.description} transaction, this type of transaction is managed by the system.');
|
|
379
|
-
const transactionEditFailedTypeChanged = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_CHANGED', 'Changing a transaction type is forbidden. You must delete the existing transaction then
|
|
414
|
+
const transactionEditFailedTypeChanged = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_CHANGED', 'Changing a transaction type is forbidden. You must delete the existing transaction and then create a new transaction.');
|
|
415
|
+
|
|
416
|
+
const transactionSwitchFailedInvalidConversion = new FailureType('TRANSACTION_SWITCH_FAILED_INVALID_CONVERSION', 'Unable to convert transaction from {U|existing.description} to {U|desired.description}. This conversion is not supported.');
|
|
417
|
+
const transactionSwitchFailedInvalidReinvest = new FailureType('TRANSACTION_SWITCH_FAILED_INVALID_REINVEST', 'Unable to convert transaction from {U|existing.description} to {U|desired.description}. Reinvestment is not supported for short positions.');
|
|
380
418
|
|
|
381
419
|
return PortfolioFailureType;
|
|
382
420
|
})();
|
|
@@ -247,9 +247,10 @@ module.exports = (() => {
|
|
|
247
247
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
248
248
|
.withField('date', DataType.DAY)
|
|
249
249
|
.withField('price', DataType.DECIMAL, true)
|
|
250
|
-
.withField('quantity', DataType.DECIMAL)
|
|
250
|
+
.withField('quantity', DataType.DECIMAL, true)
|
|
251
251
|
.withField('fee', DataType.DECIMAL, true)
|
|
252
252
|
.withField('force', DataType.BOOLEAN, true)
|
|
253
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
253
254
|
.schema
|
|
254
255
|
);
|
|
255
256
|
|
|
@@ -260,9 +261,10 @@ module.exports = (() => {
|
|
|
260
261
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
261
262
|
.withField('date', DataType.DAY)
|
|
262
263
|
.withField('price', DataType.DECIMAL)
|
|
263
|
-
.withField('quantity', DataType.DECIMAL)
|
|
264
|
+
.withField('quantity', DataType.DECIMAL, true)
|
|
264
265
|
.withField('fee', DataType.DECIMAL, true)
|
|
265
266
|
.withField('force', DataType.BOOLEAN, true)
|
|
267
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
266
268
|
.schema
|
|
267
269
|
);
|
|
268
270
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -5456,9 +5456,10 @@ module.exports = (() => {
|
|
|
5456
5456
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
5457
5457
|
.withField('date', DataType.DAY)
|
|
5458
5458
|
.withField('price', DataType.DECIMAL, true)
|
|
5459
|
-
.withField('quantity', DataType.DECIMAL)
|
|
5459
|
+
.withField('quantity', DataType.DECIMAL, true)
|
|
5460
5460
|
.withField('fee', DataType.DECIMAL, true)
|
|
5461
5461
|
.withField('force', DataType.BOOLEAN, true)
|
|
5462
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
5462
5463
|
.schema
|
|
5463
5464
|
);
|
|
5464
5465
|
|
|
@@ -5469,9 +5470,10 @@ module.exports = (() => {
|
|
|
5469
5470
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
5470
5471
|
.withField('date', DataType.DAY)
|
|
5471
5472
|
.withField('price', DataType.DECIMAL)
|
|
5472
|
-
.withField('quantity', DataType.DECIMAL)
|
|
5473
|
+
.withField('quantity', DataType.DECIMAL, true)
|
|
5473
5474
|
.withField('fee', DataType.DECIMAL, true)
|
|
5474
5475
|
.withField('force', DataType.BOOLEAN, true)
|
|
5476
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
5475
5477
|
.schema
|
|
5476
5478
|
);
|
|
5477
5479
|
|
|
@@ -8203,8 +8205,11 @@ const moment = require('moment-timezone');
|
|
|
8203
8205
|
|
|
8204
8206
|
module.exports = (() => {
|
|
8205
8207
|
'use strict';
|
|
8208
|
+
|
|
8209
|
+
const MILLISECONDS_PER_SECOND = 1000;
|
|
8206
8210
|
/**
|
|
8207
|
-
*
|
|
8211
|
+
* An immutable data structure that encapsulates (and lazy loads)
|
|
8212
|
+
* a moment (see https://momentjs.com/).
|
|
8208
8213
|
*
|
|
8209
8214
|
* @public
|
|
8210
8215
|
* @param {Number} timestamp
|
|
@@ -8220,7 +8225,7 @@ module.exports = (() => {
|
|
|
8220
8225
|
this._moment = null;
|
|
8221
8226
|
}
|
|
8222
8227
|
/**
|
|
8223
|
-
* The timestamp.
|
|
8228
|
+
* The timestamp (milliseconds since epoch).
|
|
8224
8229
|
*
|
|
8225
8230
|
* @public
|
|
8226
8231
|
* @returns {Number}
|
|
@@ -8249,6 +8254,34 @@ module.exports = (() => {
|
|
|
8249
8254
|
|
|
8250
8255
|
return this._moment;
|
|
8251
8256
|
}
|
|
8257
|
+
/**
|
|
8258
|
+
* Returns a new {@link Timestamp} instance shifted forward (or backward)
|
|
8259
|
+
* by a specific number of seconds.
|
|
8260
|
+
*
|
|
8261
|
+
* @public
|
|
8262
|
+
* @param {Number} milliseconds
|
|
8263
|
+
* @returns {Timestamp}
|
|
8264
|
+
*/
|
|
8265
|
+
|
|
8266
|
+
|
|
8267
|
+
add(milliseconds) {
|
|
8268
|
+
assert.argumentIsRequired(milliseconds, 'seconds', Number);
|
|
8269
|
+
return new Timestamp(this._timestamp + milliseconds, this._timezone);
|
|
8270
|
+
}
|
|
8271
|
+
/**
|
|
8272
|
+
* Returns a new {@link Timestamp} instance shifted forward (or backward)
|
|
8273
|
+
* by a specific number of seconds.
|
|
8274
|
+
*
|
|
8275
|
+
* @public
|
|
8276
|
+
* @param {Number} seconds
|
|
8277
|
+
* @returns {Timestamp}
|
|
8278
|
+
*/
|
|
8279
|
+
|
|
8280
|
+
|
|
8281
|
+
addSeconds(seconds) {
|
|
8282
|
+
assert.argumentIsRequired(seconds, 'seconds', Number);
|
|
8283
|
+
return this.add(seconds * MILLISECONDS_PER_SECOND);
|
|
8284
|
+
}
|
|
8252
8285
|
/**
|
|
8253
8286
|
* Returns the JSON representation.
|
|
8254
8287
|
*
|
|
@@ -8550,7 +8583,8 @@ module.exports = (() => {
|
|
|
8550
8583
|
},
|
|
8551
8584
|
|
|
8552
8585
|
/**
|
|
8553
|
-
* Set difference operation
|
|
8586
|
+
* Set difference operation, returning any item in "a" that is not
|
|
8587
|
+
* contained in "b" (using strict equality).
|
|
8554
8588
|
*
|
|
8555
8589
|
* @static
|
|
8556
8590
|
* @param {Array} a
|
|
@@ -8562,7 +8596,8 @@ module.exports = (() => {
|
|
|
8562
8596
|
},
|
|
8563
8597
|
|
|
8564
8598
|
/**
|
|
8565
|
-
* Set difference operation,
|
|
8599
|
+
* Set difference operation, returning any item in "a" that is not
|
|
8600
|
+
* contained in "b" (where the uniqueness is determined by a delegate).
|
|
8566
8601
|
*
|
|
8567
8602
|
* @static
|
|
8568
8603
|
* @param {Array} a
|
|
@@ -9465,6 +9500,7 @@ module.exports = (() => {
|
|
|
9465
9500
|
/**
|
|
9466
9501
|
* An implementation of the observer pattern.
|
|
9467
9502
|
*
|
|
9503
|
+
* @public
|
|
9468
9504
|
* @param {*} sender - The object which owns the event.
|
|
9469
9505
|
* @extends {Disposable}
|
|
9470
9506
|
*/
|
|
@@ -9538,6 +9574,7 @@ module.exports = (() => {
|
|
|
9538
9574
|
/**
|
|
9539
9575
|
* Returns true, if no handlers are currently registered.
|
|
9540
9576
|
*
|
|
9577
|
+
* @public
|
|
9541
9578
|
* @returns {boolean}
|
|
9542
9579
|
*/
|
|
9543
9580
|
|