@barchart/portfolio-api-common 1.2.136 → 1.2.140
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.
|
@@ -176,7 +176,18 @@ module.exports = (() => {
|
|
|
176
176
|
static get TRANSACTION_CREATE_FAILED_POSITION_LOCKED() {
|
|
177
177
|
return transactionCreateFailedPositionLocked;
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The transaction failed because corporate action history is corrupt.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
* @static
|
|
185
|
+
* @returns {FailureType}
|
|
186
|
+
*/
|
|
187
|
+
static get TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT() {
|
|
188
|
+
return transactionCreateFailedInstrumentCorrupt;
|
|
189
|
+
}
|
|
190
|
+
|
|
180
191
|
/**
|
|
181
192
|
* The transaction (of this type) cannot be deleted by a user, instead,
|
|
182
193
|
* it is created and managed by the system (e.g. dividends).
|
|
@@ -292,6 +303,7 @@ module.exports = (() => {
|
|
|
292
303
|
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.');
|
|
293
304
|
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.');
|
|
294
305
|
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.');
|
|
306
|
+
const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located.');
|
|
295
307
|
|
|
296
308
|
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).');
|
|
297
309
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
|
|
@@ -571,11 +571,11 @@ module.exports = (() => {
|
|
|
571
571
|
const direction = summaries.reduce((accumulator, summary) => {
|
|
572
572
|
let returnRef = accumulator;
|
|
573
573
|
|
|
574
|
-
if (summary
|
|
574
|
+
if (summary !== null && summary.start.direction !== PositionDirection.EVEN) {
|
|
575
575
|
returnRef = summary.start.direction;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
if (summary
|
|
578
|
+
if (summary !== null && summary.end.direction !== PositionDirection.EVEN) {
|
|
579
579
|
returnRef = summary.end.direction;
|
|
580
580
|
}
|
|
581
581
|
|
|
@@ -589,31 +589,27 @@ module.exports = (() => {
|
|
|
589
589
|
let returnRef;
|
|
590
590
|
|
|
591
591
|
if (currentSummary) {
|
|
592
|
-
|
|
593
|
-
let startValue;
|
|
592
|
+
let startValue;
|
|
594
593
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
let endValue;
|
|
602
|
-
|
|
603
|
-
if (overridePrice) {
|
|
604
|
-
endValue = currentSummary.end.open.multiply(overridePrice);
|
|
605
|
-
} else {
|
|
606
|
-
endValue = currentSummary.end.value;
|
|
607
|
-
}
|
|
594
|
+
if (previousSummary) {
|
|
595
|
+
startValue = previousSummary.end.value;
|
|
596
|
+
} else {
|
|
597
|
+
startValue = Decimal.ZERO;
|
|
598
|
+
}
|
|
608
599
|
|
|
609
|
-
|
|
610
|
-
const tradeChange = currentSummary.period.sells.subtract(currentSummary.period.buys.opposite());
|
|
611
|
-
const incomeChange = currentSummary.period.income;
|
|
600
|
+
let endValue;
|
|
612
601
|
|
|
613
|
-
|
|
602
|
+
if (overridePrice) {
|
|
603
|
+
endValue = currentSummary.end.open.multiply(overridePrice);
|
|
614
604
|
} else {
|
|
615
|
-
|
|
605
|
+
endValue = currentSummary.end.value;
|
|
616
606
|
}
|
|
607
|
+
|
|
608
|
+
const valueChange = endValue.subtract(startValue);
|
|
609
|
+
const tradeChange = currentSummary.period.sells.subtract(currentSummary.period.buys.opposite());
|
|
610
|
+
const incomeChange = currentSummary.period.income;
|
|
611
|
+
|
|
612
|
+
returnRef = valueChange.add(tradeChange).add(incomeChange);
|
|
617
613
|
} else {
|
|
618
614
|
returnRef = Decimal.ZERO;
|
|
619
615
|
}
|
|
@@ -625,18 +621,18 @@ module.exports = (() => {
|
|
|
625
621
|
let returnRef;
|
|
626
622
|
|
|
627
623
|
if (currentSummary) {
|
|
628
|
-
|
|
629
|
-
let startValue;
|
|
624
|
+
let startValue;
|
|
630
625
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
626
|
+
if (previousSummary) {
|
|
627
|
+
startValue = previousSummary.end.value;
|
|
628
|
+
} else {
|
|
629
|
+
startValue = Decimal.ZERO;
|
|
630
|
+
}
|
|
636
631
|
|
|
637
|
-
|
|
632
|
+
if (direction === PositionDirection.SHORT) {
|
|
633
|
+
returnRef = startValue.opposite().add(currentSummary.period.sells);
|
|
638
634
|
} else {
|
|
639
|
-
returnRef =
|
|
635
|
+
returnRef = startValue.add(currentSummary.period.buys.opposite());
|
|
640
636
|
}
|
|
641
637
|
} else {
|
|
642
638
|
returnRef = Decimal.ZERO;
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -4077,11 +4077,11 @@ module.exports = (() => {
|
|
|
4077
4077
|
const direction = summaries.reduce((accumulator, summary) => {
|
|
4078
4078
|
let returnRef = accumulator;
|
|
4079
4079
|
|
|
4080
|
-
if (summary
|
|
4080
|
+
if (summary !== null && summary.start.direction !== PositionDirection.EVEN) {
|
|
4081
4081
|
returnRef = summary.start.direction;
|
|
4082
4082
|
}
|
|
4083
4083
|
|
|
4084
|
-
if (summary
|
|
4084
|
+
if (summary !== null && summary.end.direction !== PositionDirection.EVEN) {
|
|
4085
4085
|
returnRef = summary.end.direction;
|
|
4086
4086
|
}
|
|
4087
4087
|
|
|
@@ -4095,31 +4095,27 @@ module.exports = (() => {
|
|
|
4095
4095
|
let returnRef;
|
|
4096
4096
|
|
|
4097
4097
|
if (currentSummary) {
|
|
4098
|
-
|
|
4099
|
-
let startValue;
|
|
4098
|
+
let startValue;
|
|
4100
4099
|
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
let endValue;
|
|
4108
|
-
|
|
4109
|
-
if (overridePrice) {
|
|
4110
|
-
endValue = currentSummary.end.open.multiply(overridePrice);
|
|
4111
|
-
} else {
|
|
4112
|
-
endValue = currentSummary.end.value;
|
|
4113
|
-
}
|
|
4100
|
+
if (previousSummary) {
|
|
4101
|
+
startValue = previousSummary.end.value;
|
|
4102
|
+
} else {
|
|
4103
|
+
startValue = Decimal.ZERO;
|
|
4104
|
+
}
|
|
4114
4105
|
|
|
4115
|
-
|
|
4116
|
-
const tradeChange = currentSummary.period.sells.subtract(currentSummary.period.buys.opposite());
|
|
4117
|
-
const incomeChange = currentSummary.period.income;
|
|
4106
|
+
let endValue;
|
|
4118
4107
|
|
|
4119
|
-
|
|
4108
|
+
if (overridePrice) {
|
|
4109
|
+
endValue = currentSummary.end.open.multiply(overridePrice);
|
|
4120
4110
|
} else {
|
|
4121
|
-
|
|
4111
|
+
endValue = currentSummary.end.value;
|
|
4122
4112
|
}
|
|
4113
|
+
|
|
4114
|
+
const valueChange = endValue.subtract(startValue);
|
|
4115
|
+
const tradeChange = currentSummary.period.sells.subtract(currentSummary.period.buys.opposite());
|
|
4116
|
+
const incomeChange = currentSummary.period.income;
|
|
4117
|
+
|
|
4118
|
+
returnRef = valueChange.add(tradeChange).add(incomeChange);
|
|
4123
4119
|
} else {
|
|
4124
4120
|
returnRef = Decimal.ZERO;
|
|
4125
4121
|
}
|
|
@@ -4131,18 +4127,18 @@ module.exports = (() => {
|
|
|
4131
4127
|
let returnRef;
|
|
4132
4128
|
|
|
4133
4129
|
if (currentSummary) {
|
|
4134
|
-
|
|
4135
|
-
let startValue;
|
|
4130
|
+
let startValue;
|
|
4136
4131
|
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4132
|
+
if (previousSummary) {
|
|
4133
|
+
startValue = previousSummary.end.value;
|
|
4134
|
+
} else {
|
|
4135
|
+
startValue = Decimal.ZERO;
|
|
4136
|
+
}
|
|
4142
4137
|
|
|
4143
|
-
|
|
4138
|
+
if (direction === PositionDirection.SHORT) {
|
|
4139
|
+
returnRef = startValue.opposite().add(currentSummary.period.sells);
|
|
4144
4140
|
} else {
|
|
4145
|
-
returnRef =
|
|
4141
|
+
returnRef = startValue.add(currentSummary.period.buys.opposite());
|
|
4146
4142
|
}
|
|
4147
4143
|
} else {
|
|
4148
4144
|
returnRef = Decimal.ZERO;
|