@barchart/portfolio-api-common 1.2.69 → 1.2.73

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.
@@ -230,7 +230,7 @@ module.exports = (() => {
230
230
  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.');
231
231
  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.');
232
232
  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.');
233
- const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction, are being recalculated for this position (or the linked cash position). Please re-enter the transaction in a minute or two.');
233
+ 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.');
234
234
 
235
235
  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).');
236
236
  const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
@@ -104,7 +104,7 @@ module.exports = (() => {
104
104
  assert.argumentIsArray(transactions, 'transactions');
105
105
  assert.argumentIsOptional(strict, 'strict', Boolean);
106
106
 
107
- return transactions.findIndex((t, i, a) => TransactionValidator.getSortSequence(t) !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
107
+ return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
108
108
  }
109
109
 
110
110
  /**
@@ -30,14 +30,12 @@ module.exports = (() => {
30
30
  * @static
31
31
  * @param {Array.<Object>} transactions
32
32
  * @param {Array.<Object>} positions
33
- * @param {Boolean=} mutate
34
33
  * @param {Boolean=} descending
35
34
  * @returns {Array}
36
35
  */
37
- static format(transactions, positions, mutate, descending) {
36
+ static format(transactions, positions, descending) {
38
37
  assert.argumentIsArray(transactions, 'transactions');
39
38
  assert.argumentIsArray(positions, 'positions');
40
- assert.argumentIsOptional(mutate, 'mutate', Boolean);
41
39
  assert.argumentIsOptional(descending, 'descending', Boolean);
42
40
 
43
41
  const instruments = positions.reduce((map, p) => {
@@ -70,17 +68,7 @@ module.exports = (() => {
70
68
  formatted = Object.assign({}, formatted, formattedTransaction);
71
69
  }
72
70
 
73
- let transactionToInsert;
74
-
75
- if (mutate) {
76
- transaction.formatted = formatted;
77
-
78
- transactionToInsert = transaction;
79
- } else {
80
- transactionToInsert = formatted;
81
- }
82
-
83
- list.push(transactionToInsert);
71
+ list.push(formatted);
84
72
  }
85
73
 
86
74
  return list;
@@ -300,7 +288,7 @@ module.exports = (() => {
300
288
  }
301
289
 
302
290
  const comparatorAscending = ComparatorBuilder.startWith((a, b) => Day.compareDays(a.date, b.date))
303
- .thenBy((a, b) => comparators.compareNumbers(getInstrumentTypePriority(a.instrument.type), getInstrumentTypePriority(b.instrument.type))
291
+ .thenBy((a, b) => comparators.compareNumbers(getInstrumentTypePriority(a.instrument.type), getInstrumentTypePriority(b.instrument.type)))
304
292
  .thenBy((a, b) => comparators.compareStrings(a.instrument.id, b.instrument.id))
305
293
  .thenBy((a, b) => comparators.compareNumbers(a.sequence, b.sequence))
306
294
  .toComparator();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.69",
3
+ "version": "1.2.73",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1187,7 +1187,7 @@ module.exports = (() => {
1187
1187
  assert.argumentIsArray(transactions, 'transactions');
1188
1188
  assert.argumentIsOptional(strict, 'strict', Boolean);
1189
1189
 
1190
- return transactions.findIndex((t, i, a) => TransactionValidator.getSortSequence(t) !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1190
+ return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1191
1191
  }
1192
1192
 
1193
1193
  /**
@@ -6282,17 +6282,15 @@ module.exports = function () {
6282
6282
  *
6283
6283
  * @public
6284
6284
  * @param {Boolean=} approximate
6285
- * @param {Number=} places
6286
6285
  * @returns {Boolean}
6287
6286
  */
6288
6287
 
6289
6288
  }, {
6290
6289
  key: 'getIsZero',
6291
- value: function getIsZero(approximate, places) {
6290
+ value: function getIsZero(approximate) {
6292
6291
  assert.argumentIsOptional(approximate, 'approximate', Boolean);
6293
- assert.argumentIsOptional(places, 'places', Number);
6294
6292
 
6295
- return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(places || Big.DP, RoundingMode.NORMAL).getIsZero();
6293
+ return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(20, RoundingMode.NORMAL).getIsZero();
6296
6294
  }
6297
6295
 
6298
6296
  /**
@@ -6391,43 +6389,6 @@ module.exports = function () {
6391
6389
  return this._big.eq(getBig(other));
6392
6390
  }
6393
6391
 
6394
- /**
6395
- * Returns true if the current instance is an integer (i.e. has no decimal
6396
- * component).
6397
- *
6398
- * @public
6399
- * @return {Boolean}
6400
- */
6401
-
6402
- }, {
6403
- key: 'getIsInteger',
6404
- value: function getIsInteger() {
6405
- return this.getIsEqual(this.round(0));
6406
- }
6407
-
6408
- /**
6409
- * Returns the number of decimal places used.
6410
- *
6411
- * @public
6412
- * @returns {Number}
6413
- */
6414
-
6415
- }, {
6416
- key: 'getDecimalPlaces',
6417
- value: function getDecimalPlaces() {
6418
- var matches = this.toFixed().match(/-?\d*\.(\d*)/);
6419
-
6420
- var returnVal = void 0;
6421
-
6422
- if (matches === null) {
6423
- returnVal = 0;
6424
- } else {
6425
- returnVal = matches[1].length;
6426
- }
6427
-
6428
- return returnVal;
6429
- }
6430
-
6431
6392
  /**
6432
6393
  * Emits a floating point value that approximates the value of the current
6433
6394
  * instance.