@barchart/portfolio-api-common 1.5.0 → 1.7.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.5.1.md +3 -0
- package/.releases/1.5.2.md +4 -0
- package/.releases/1.6.0.md +3 -0
- package/.releases/1.7.0.md +3 -0
- package/lib/api/failures/PortfolioFailureType.js +27 -1
- package/lib/data/TransactionValidator.js +1 -2
- package/lib/formatters/TransactionFormatter.js +1 -0
- package/lib/processing/PositionContainer.js +3 -1
- package/lib/processing/PositionItem.js +4 -4
- package/package.json +1 -1
- package/test/SpecRunner.js +9 -8
|
@@ -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,18 @@ 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
|
+
|
|
329
353
|
toString() {
|
|
330
354
|
return '[PortfolioFailureType]';
|
|
331
355
|
}
|
|
@@ -352,8 +376,9 @@ module.exports = (() => {
|
|
|
352
376
|
|
|
353
377
|
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
378
|
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.');
|
|
379
|
+
const transactionCreateFailedReinvestInvalid = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_INVALID', 'Unable to create transaction, short positions do not allow dividends to be reinvested.');
|
|
355
380
|
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
|
-
const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located.');
|
|
381
|
+
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
382
|
|
|
358
383
|
const transactionDeleteFailedOutOfSequence = new FailureType('TRANSACTION_DELETE_FAILED_OUT_OF_SEQUENCE', 'Deleting any transaction, except for the most recent, will cause transaction history to be re-written. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
|
|
359
384
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.', false);
|
|
@@ -364,6 +389,7 @@ module.exports = (() => {
|
|
|
364
389
|
const transactionEditFailedInvalidDate = new FailureType('TRANSACTION_EDIT_FAILED_INVALID_DATE', 'Unable to edit transaction with given date.');
|
|
365
390
|
const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.', false);
|
|
366
391
|
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.');
|
|
392
|
+
const transactionEditFailedTypeChanged = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_CHANGED', 'Changing a transaction type is forbidden. You must delete the existing transaction then recreate it.');
|
|
367
393
|
|
|
368
394
|
return PortfolioFailureType;
|
|
369
395
|
})();
|
|
@@ -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'),
|
|
@@ -234,7 +234,7 @@ module.exports = (() => {
|
|
|
234
234
|
const key = portfolio.portfolio;
|
|
235
235
|
|
|
236
236
|
if (!this._portfolios.hasOwnProperty(key)) {
|
|
237
|
-
this._portfolios[key]
|
|
237
|
+
this._portfolios = Object.assign({}, this._portfolios, { [key]: portfolio });
|
|
238
238
|
|
|
239
239
|
this._definitions.forEach((treeDefinition) => {
|
|
240
240
|
const tree = this._trees[treeDefinition.name];
|
|
@@ -314,6 +314,8 @@ module.exports = (() => {
|
|
|
314
314
|
|
|
315
315
|
delete this._portfolios[portfolio.portfolio];
|
|
316
316
|
|
|
317
|
+
this._portfolios = Object.assign({}, this._portfolios);
|
|
318
|
+
|
|
317
319
|
Object.keys(this._trees).forEach((key) => {
|
|
318
320
|
this._trees[key].walk((group, groupNode) => {
|
|
319
321
|
if (group.definition.type === PositionLevelType.PORTFOLIO && group.key === PositionLevelDefinition.getKeyForPortfolioGroup(portfolio)) {
|
|
@@ -40,14 +40,14 @@ module.exports = (() => {
|
|
|
40
40
|
|
|
41
41
|
this._reporting = reporting;
|
|
42
42
|
|
|
43
|
-
this._data = { };
|
|
44
|
-
|
|
45
|
-
this._data.basis = null;
|
|
46
|
-
|
|
47
43
|
this._currentQuote = null;
|
|
48
44
|
this._previousQuote = null;
|
|
49
45
|
this._currentPrice = null;
|
|
50
46
|
|
|
47
|
+
this._data = { };
|
|
48
|
+
|
|
49
|
+
this._data.basis = null;
|
|
50
|
+
|
|
51
51
|
this._data.currentPrice = null;
|
|
52
52
|
this._data.currentPricePrevious = null;
|
|
53
53
|
|
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 = (() => {
|
|
@@ -1893,7 +1892,7 @@ module.exports = (() => {
|
|
|
1893
1892
|
const key = portfolio.portfolio;
|
|
1894
1893
|
|
|
1895
1894
|
if (!this._portfolios.hasOwnProperty(key)) {
|
|
1896
|
-
this._portfolios[key]
|
|
1895
|
+
this._portfolios = Object.assign({}, this._portfolios, { [key]: portfolio });
|
|
1897
1896
|
|
|
1898
1897
|
this._definitions.forEach((treeDefinition) => {
|
|
1899
1898
|
const tree = this._trees[treeDefinition.name];
|
|
@@ -1973,6 +1972,8 @@ module.exports = (() => {
|
|
|
1973
1972
|
|
|
1974
1973
|
delete this._portfolios[portfolio.portfolio];
|
|
1975
1974
|
|
|
1975
|
+
this._portfolios = Object.assign({}, this._portfolios);
|
|
1976
|
+
|
|
1976
1977
|
Object.keys(this._trees).forEach((key) => {
|
|
1977
1978
|
this._trees[key].walk((group, groupNode) => {
|
|
1978
1979
|
if (group.definition.type === PositionLevelType.PORTFOLIO && group.key === PositionLevelDefinition.getKeyForPortfolioGroup(portfolio)) {
|
|
@@ -3865,14 +3866,14 @@ module.exports = (() => {
|
|
|
3865
3866
|
|
|
3866
3867
|
this._reporting = reporting;
|
|
3867
3868
|
|
|
3868
|
-
this._data = { };
|
|
3869
|
-
|
|
3870
|
-
this._data.basis = null;
|
|
3871
|
-
|
|
3872
3869
|
this._currentQuote = null;
|
|
3873
3870
|
this._previousQuote = null;
|
|
3874
3871
|
this._currentPrice = null;
|
|
3875
3872
|
|
|
3873
|
+
this._data = { };
|
|
3874
|
+
|
|
3875
|
+
this._data.basis = null;
|
|
3876
|
+
|
|
3876
3877
|
this._data.currentPrice = null;
|
|
3877
3878
|
this._data.currentPricePrevious = null;
|
|
3878
3879
|
|