@barchart/portfolio-api-common 1.2.42 → 1.2.46
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.
|
@@ -131,6 +131,18 @@ module.exports = (() => {
|
|
|
131
131
|
return transactionCreateFailedTypeReserved;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* The transaction failed because a dividend would be reinvested on
|
|
136
|
+
* a day for which no historical price is available.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
* @static
|
|
140
|
+
* @returns {FailureType}
|
|
141
|
+
*/
|
|
142
|
+
static get TRANSACTION_CREATE_FAILED_REINVEST_PRICE_UNAVAILABLE() {
|
|
143
|
+
return transactionCreateFailedReinvestPriceUnavailable;
|
|
144
|
+
}
|
|
145
|
+
|
|
134
146
|
/**
|
|
135
147
|
* Deleting any transaction except for the most recent requires
|
|
136
148
|
* re-writing transaction history.
|
|
@@ -204,8 +216,9 @@ module.exports = (() => {
|
|
|
204
216
|
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.');
|
|
205
217
|
const transactionCreateFailedTypeInvalidForDirection = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_INVALID_FOR_DIRECTION', 'Unable to process transaction, a {L|positionDirection.description} position would be created (i.e. you would have {L|positionDirection.sign} shares/units). {u|instrumentType.description} positions cannot have {L|positionDirection.description} positions.');
|
|
206
218
|
const transactionCreateFailedInvalidDirectionSwitch = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_DIRECTION_SWITCH', 'Unable to process transaction, the transaction would switch the position from {L|currentDirection.description} to {L|proposedDirection.description} (i.e. {L|currentDirection.sign} to {L|proposedDirection.sign} shares/units). This is not allowed. Please close the current position (i.e. zero it out) and then enter a second transaction.');
|
|
207
|
-
const transactionCreateFailedInvalidInitialType = new FailureType('
|
|
219
|
+
const transactionCreateFailedInvalidInitialType = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_INITIAL_TYPE', 'Unable to process operation because the first transaction would to be a {U|transactionType.description}, which is not allowed -- since {U|transactionType.description} transactions cannot open a position.');
|
|
208
220
|
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.');
|
|
221
|
+
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.');
|
|
209
222
|
|
|
210
223
|
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).');
|
|
211
224
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
|
|
@@ -20,7 +20,7 @@ module.exports = (() => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Given
|
|
23
|
+
* Given an array of transactions, ensures that all sequence numbers and dates
|
|
24
24
|
* are properly ordered.
|
|
25
25
|
*
|
|
26
26
|
* @public
|
|
@@ -33,7 +33,7 @@ module.exports = (() => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Given
|
|
36
|
+
* Given an array of transactions, when transaction references are present, ensures
|
|
37
37
|
* that no transactions within the set reference the same transaction.
|
|
38
38
|
*
|
|
39
39
|
* @public
|
|
@@ -71,7 +71,7 @@ module.exports = (() => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Given
|
|
74
|
+
* Given an array of transactions, returns the index of the first transaction that with an invalid
|
|
75
75
|
* sequence number or date.
|
|
76
76
|
*
|
|
77
77
|
* @public
|
|
@@ -92,7 +92,7 @@ module.exports = (() => {
|
|
|
92
92
|
* @public
|
|
93
93
|
* @param {InstrumentType} instrumentType
|
|
94
94
|
* @param {Boolean=} userInitiated
|
|
95
|
-
* @
|
|
95
|
+
* @param {PositionDirection=} currentDirection
|
|
96
96
|
* @returns {Array.<TransactionType>}
|
|
97
97
|
*/
|
|
98
98
|
static getTransactionTypesFor(instrumentType, userInitiated, currentDirection) {
|
|
@@ -156,7 +156,9 @@ module.exports = (() => {
|
|
|
156
156
|
* Determines if a transaction type is valid as the first transaction of
|
|
157
157
|
* a position.
|
|
158
158
|
*
|
|
159
|
+
* @public
|
|
159
160
|
* @param {TransactionType} transactionType
|
|
161
|
+
* @returns {Boolean}
|
|
160
162
|
*/
|
|
161
163
|
static validateInitialTransactionType(transactionType) {
|
|
162
164
|
return transactionType.initial;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
is = require('@barchart/common-js/lang/is'),
|
|
1
|
+
const is = require('@barchart/common-js/lang/is'),
|
|
3
2
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
4
3
|
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
5
4
|
Enum = require('@barchart/common-js/lang/Enum'),
|
|
@@ -211,6 +210,8 @@ module.exports = (() => {
|
|
|
211
210
|
.withField('sequence', DataType.NUMBER, true)
|
|
212
211
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
213
212
|
.withField('instrument.name', DataType.STRING, true)
|
|
213
|
+
.withField('instrument.exchange', DataType.STRING, true)
|
|
214
|
+
.withField('instrument.code', DataType.NUMBER, true)
|
|
214
215
|
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
|
|
215
216
|
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
216
217
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
@@ -257,6 +258,8 @@ module.exports = (() => {
|
|
|
257
258
|
.withField('sequence', DataType.NUMBER, true)
|
|
258
259
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
259
260
|
.withField('instrument.name', DataType.STRING, true)
|
|
261
|
+
.withField('instrument.exchange', DataType.STRING, true)
|
|
262
|
+
.withField('instrument.code', DataType.NUMBER, true)
|
|
260
263
|
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
|
|
261
264
|
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
262
265
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|