@barchart/portfolio-api-common 1.4.4 → 1.6.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.0.md +3 -0
- 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/lib/api/failures/PortfolioFailureType.js +14 -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/lib/serialization/PositionSchema.js +23 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +32 -8
|
@@ -326,6 +326,18 @@ module.exports = (() => {
|
|
|
326
326
|
return transactionEditFailedTypeReserved;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* A transaction's type cannot be changed.
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
* @static
|
|
334
|
+
* @returns {FailureType}
|
|
335
|
+
*/
|
|
336
|
+
static get TRANSACTION_EDIT_FAILED_TYPE_CHANGED() {
|
|
337
|
+
return transactionEditFailedTypeChanged;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
329
341
|
toString() {
|
|
330
342
|
return '[PortfolioFailureType]';
|
|
331
343
|
}
|
|
@@ -353,7 +365,7 @@ module.exports = (() => {
|
|
|
353
365
|
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
366
|
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.');
|
|
355
367
|
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.');
|
|
368
|
+
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
369
|
|
|
358
370
|
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
371
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.', false);
|
|
@@ -364,6 +376,7 @@ module.exports = (() => {
|
|
|
364
376
|
const transactionEditFailedInvalidDate = new FailureType('TRANSACTION_EDIT_FAILED_INVALID_DATE', 'Unable to edit transaction with given date.');
|
|
365
377
|
const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.', false);
|
|
366
378
|
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 recreate it.');
|
|
367
380
|
|
|
368
381
|
return PortfolioFailureType;
|
|
369
382
|
})();
|
|
@@ -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
|
|
|
@@ -67,6 +67,17 @@ module.exports = (() => {
|
|
|
67
67
|
return update;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Result item for query of positions by symbol.
|
|
72
|
+
*
|
|
73
|
+
* @static
|
|
74
|
+
* @public
|
|
75
|
+
* @returns {PositionSchema}
|
|
76
|
+
*/
|
|
77
|
+
static get SIMPLE() {
|
|
78
|
+
return simple;
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
toString() {
|
|
71
82
|
return '[PositionSchema]';
|
|
72
83
|
}
|
|
@@ -152,5 +163,17 @@ module.exports = (() => {
|
|
|
152
163
|
.schema
|
|
153
164
|
);
|
|
154
165
|
|
|
166
|
+
const simple = new PositionSchema(SchemaBuilder.withName('simple')
|
|
167
|
+
.withField('user', DataType.STRING)
|
|
168
|
+
.withField('portfolio', DataType.STRING)
|
|
169
|
+
.withField('instrument.id', DataType.STRING)
|
|
170
|
+
.withField('instrument.name', DataType.STRING)
|
|
171
|
+
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
172
|
+
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
173
|
+
.withField('position', DataType.STRING)
|
|
174
|
+
.withField('open', DataType.BOOLEAN, true)
|
|
175
|
+
.schema
|
|
176
|
+
);
|
|
177
|
+
|
|
155
178
|
return PositionSchema;
|
|
156
179
|
})();
|
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
|
|
|
@@ -5094,6 +5095,17 @@ module.exports = (() => {
|
|
|
5094
5095
|
return update;
|
|
5095
5096
|
}
|
|
5096
5097
|
|
|
5098
|
+
/**
|
|
5099
|
+
* Result item for query of positions by symbol.
|
|
5100
|
+
*
|
|
5101
|
+
* @static
|
|
5102
|
+
* @public
|
|
5103
|
+
* @returns {PositionSchema}
|
|
5104
|
+
*/
|
|
5105
|
+
static get SIMPLE() {
|
|
5106
|
+
return simple;
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5097
5109
|
toString() {
|
|
5098
5110
|
return '[PositionSchema]';
|
|
5099
5111
|
}
|
|
@@ -5179,6 +5191,18 @@ module.exports = (() => {
|
|
|
5179
5191
|
.schema
|
|
5180
5192
|
);
|
|
5181
5193
|
|
|
5194
|
+
const simple = new PositionSchema(SchemaBuilder.withName('simple')
|
|
5195
|
+
.withField('user', DataType.STRING)
|
|
5196
|
+
.withField('portfolio', DataType.STRING)
|
|
5197
|
+
.withField('instrument.id', DataType.STRING)
|
|
5198
|
+
.withField('instrument.name', DataType.STRING)
|
|
5199
|
+
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
5200
|
+
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
5201
|
+
.withField('position', DataType.STRING)
|
|
5202
|
+
.withField('open', DataType.BOOLEAN, true)
|
|
5203
|
+
.schema
|
|
5204
|
+
);
|
|
5205
|
+
|
|
5182
5206
|
return PositionSchema;
|
|
5183
5207
|
})();
|
|
5184
5208
|
|