@barchart/portfolio-api-common 1.2.43 → 1.2.47

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('TRANSACTION_CREATE_FAILED_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.');
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.');
@@ -92,7 +92,7 @@ module.exports = (() => {
92
92
  * @public
93
93
  * @param {InstrumentType} instrumentType
94
94
  * @param {Boolean=} userInitiated
95
- * @pararm {PositionDirection=} currentDirection
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;
@@ -182,11 +182,16 @@ module.exports = (() => {
182
182
 
183
183
  formatters.set(TransactionType.DISTRIBUTION_REINVEST, (t) => {
184
184
  return {
185
+ <<<<<<< HEAD
186
+ shares: t.quantity,
187
+ fee: t.fee
188
+ =======
185
189
  boughtSold: t.quantity,
186
190
  shares: t.snapshot.open.subtract(t.quantity),
187
191
  price: t.dividend.price,
188
192
  fee: t.fee,
189
193
  rate: t.dividend.rate
194
+ >>>>>>> ec3861f5eeab5fdbfa9275d5ef3f5b988b90999b
190
195
  };
191
196
  });
192
197
 
@@ -1,5 +1,4 @@
1
- const assert = require('@barchart/common-js/lang/assert'),
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.43",
3
+ "version": "1.2.47",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",