@barchart/portfolio-api-common 1.5.2 → 1.9.0
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 +3 -0
- 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/lib/api/failures/PortfolioFailureType.js +51 -0
- package/lib/data/TransactionValidator.js +1 -2
- package/lib/serialization/TransactionSchema.js +2 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +10 -5
|
@@ -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
|
*
|
|
@@ -326,6 +338,40 @@ module.exports = (() => {
|
|
|
326
338
|
return transactionEditFailedTypeReserved;
|
|
327
339
|
}
|
|
328
340
|
|
|
341
|
+
/**
|
|
342
|
+
* A transaction's type cannot be changed.
|
|
343
|
+
*
|
|
344
|
+
* @public
|
|
345
|
+
* @static
|
|
346
|
+
* @returns {FailureType}
|
|
347
|
+
*/
|
|
348
|
+
static get TRANSACTION_EDIT_FAILED_TYPE_CHANGED() {
|
|
349
|
+
return transactionEditFailedTypeChanged;
|
|
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
|
+
}
|
|
362
|
+
|
|
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
|
+
|
|
329
375
|
toString() {
|
|
330
376
|
return '[PortfolioFailureType]';
|
|
331
377
|
}
|
|
@@ -352,6 +398,7 @@ module.exports = (() => {
|
|
|
352
398
|
|
|
353
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.');
|
|
354
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.');
|
|
355
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.');
|
|
356
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.');
|
|
357
404
|
|
|
@@ -364,6 +411,10 @@ module.exports = (() => {
|
|
|
364
411
|
const transactionEditFailedInvalidDate = new FailureType('TRANSACTION_EDIT_FAILED_INVALID_DATE', 'Unable to edit transaction with given date.');
|
|
365
412
|
const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.', false);
|
|
366
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.');
|
|
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.');
|
|
367
418
|
|
|
368
419
|
return PortfolioFailureType;
|
|
369
420
|
})();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
2
|
array = require('@barchart/common-js/lang/array'),
|
|
3
|
-
is = require('@barchart/common-js/lang/is')
|
|
4
|
-
Day = require('@barchart/common-js/lang/Day');
|
|
3
|
+
is = require('@barchart/common-js/lang/is');
|
|
5
4
|
|
|
6
5
|
const InstrumentType = require('./InstrumentType'),
|
|
7
6
|
PositionDirection = require('./PositionDirection'),
|
|
@@ -250,6 +250,7 @@ module.exports = (() => {
|
|
|
250
250
|
.withField('quantity', DataType.DECIMAL)
|
|
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
|
|
|
@@ -263,6 +264,7 @@ module.exports = (() => {
|
|
|
263
264
|
.withField('quantity', DataType.DECIMAL)
|
|
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
|
@@ -1291,8 +1291,7 @@ module.exports = (() => {
|
|
|
1291
1291
|
},{"@barchart/common-js/lang/Enum":26,"@barchart/common-js/lang/assert":31}],5:[function(require,module,exports){
|
|
1292
1292
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
1293
1293
|
array = require('@barchart/common-js/lang/array'),
|
|
1294
|
-
is = require('@barchart/common-js/lang/is')
|
|
1295
|
-
Day = require('@barchart/common-js/lang/Day');
|
|
1294
|
+
is = require('@barchart/common-js/lang/is');
|
|
1296
1295
|
|
|
1297
1296
|
const InstrumentType = require('./InstrumentType'),
|
|
1298
1297
|
PositionDirection = require('./PositionDirection'),
|
|
@@ -1595,7 +1594,7 @@ module.exports = (() => {
|
|
|
1595
1594
|
return TransactionValidator;
|
|
1596
1595
|
})();
|
|
1597
1596
|
|
|
1598
|
-
},{"./InstrumentType":1,"./PositionDirection":2,"./TransactionType":4,"@barchart/common-js/lang/
|
|
1597
|
+
},{"./InstrumentType":1,"./PositionDirection":2,"./TransactionType":4,"@barchart/common-js/lang/array":30,"@barchart/common-js/lang/assert":31,"@barchart/common-js/lang/is":35}],6:[function(require,module,exports){
|
|
1599
1598
|
const Enum = require('@barchart/common-js/lang/Enum');
|
|
1600
1599
|
|
|
1601
1600
|
module.exports = (() => {
|
|
@@ -5460,6 +5459,7 @@ module.exports = (() => {
|
|
|
5460
5459
|
.withField('quantity', DataType.DECIMAL)
|
|
5461
5460
|
.withField('fee', DataType.DECIMAL, true)
|
|
5462
5461
|
.withField('force', DataType.BOOLEAN, true)
|
|
5462
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
5463
5463
|
.schema
|
|
5464
5464
|
);
|
|
5465
5465
|
|
|
@@ -5473,6 +5473,7 @@ module.exports = (() => {
|
|
|
5473
5473
|
.withField('quantity', DataType.DECIMAL)
|
|
5474
5474
|
.withField('fee', DataType.DECIMAL, true)
|
|
5475
5475
|
.withField('force', DataType.BOOLEAN, true)
|
|
5476
|
+
.withField('close', DataType.BOOLEAN, true)
|
|
5476
5477
|
.schema
|
|
5477
5478
|
);
|
|
5478
5479
|
|
|
@@ -8582,7 +8583,8 @@ module.exports = (() => {
|
|
|
8582
8583
|
},
|
|
8583
8584
|
|
|
8584
8585
|
/**
|
|
8585
|
-
* Set difference operation
|
|
8586
|
+
* Set difference operation, returning any item in "a" that is not
|
|
8587
|
+
* contained in "b" (using strict equality).
|
|
8586
8588
|
*
|
|
8587
8589
|
* @static
|
|
8588
8590
|
* @param {Array} a
|
|
@@ -8594,7 +8596,8 @@ module.exports = (() => {
|
|
|
8594
8596
|
},
|
|
8595
8597
|
|
|
8596
8598
|
/**
|
|
8597
|
-
* 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).
|
|
8598
8601
|
*
|
|
8599
8602
|
* @static
|
|
8600
8603
|
* @param {Array} a
|
|
@@ -9497,6 +9500,7 @@ module.exports = (() => {
|
|
|
9497
9500
|
/**
|
|
9498
9501
|
* An implementation of the observer pattern.
|
|
9499
9502
|
*
|
|
9503
|
+
* @public
|
|
9500
9504
|
* @param {*} sender - The object which owns the event.
|
|
9501
9505
|
* @extends {Disposable}
|
|
9502
9506
|
*/
|
|
@@ -9570,6 +9574,7 @@ module.exports = (() => {
|
|
|
9570
9574
|
/**
|
|
9571
9575
|
* Returns true, if no handlers are currently registered.
|
|
9572
9576
|
*
|
|
9577
|
+
* @public
|
|
9573
9578
|
* @returns {boolean}
|
|
9574
9579
|
*/
|
|
9575
9580
|
|