@barchart/portfolio-api-common 1.0.258 → 1.0.262
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.
|
@@ -18,9 +18,10 @@ module.exports = (() => {
|
|
|
18
18
|
* @param {Boolean} opening
|
|
19
19
|
* @param {Boolean} closing
|
|
20
20
|
* @param {Boolean} fee
|
|
21
|
+
* @param {Boolean} corporateAction
|
|
21
22
|
*/
|
|
22
23
|
class TransactionType extends Enum {
|
|
23
|
-
constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
|
|
24
|
+
constructor(code, description, display, purchase, sale, income, opening, closing, fee, corporateAction) {
|
|
24
25
|
super(code, description);
|
|
25
26
|
|
|
26
27
|
assert.argumentIsRequired(display, 'display', String);
|
|
@@ -30,6 +31,7 @@ module.exports = (() => {
|
|
|
30
31
|
assert.argumentIsRequired(opening, 'opening', Boolean);
|
|
31
32
|
assert.argumentIsRequired(closing, 'closing', Boolean);
|
|
32
33
|
assert.argumentIsRequired(fee, 'fee', Boolean);
|
|
34
|
+
assert.argumentIsRequired(corporateAction, 'corporateAction', Boolean);
|
|
33
35
|
|
|
34
36
|
this._display = display;
|
|
35
37
|
this._purchase = purchase;
|
|
@@ -38,6 +40,7 @@ module.exports = (() => {
|
|
|
38
40
|
this._opening = opening;
|
|
39
41
|
this._closing = closing;
|
|
40
42
|
this._fee = fee;
|
|
43
|
+
this._corporateAction = corporateAction;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -123,6 +126,16 @@ module.exports = (() => {
|
|
|
123
126
|
return this._fee;
|
|
124
127
|
}
|
|
125
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Indicates if the transaction is a corporate action.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
* @returns {Boolean}
|
|
134
|
+
*/
|
|
135
|
+
get corporateAction() {
|
|
136
|
+
return this._corporateAction;
|
|
137
|
+
}
|
|
138
|
+
|
|
126
139
|
/**
|
|
127
140
|
* A purchase.
|
|
128
141
|
*
|
|
@@ -326,27 +339,27 @@ module.exports = (() => {
|
|
|
326
339
|
}
|
|
327
340
|
}
|
|
328
341
|
|
|
329
|
-
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
|
|
330
|
-
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
|
|
331
|
-
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
|
|
332
|
-
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
|
|
333
|
-
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
|
|
334
|
-
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
335
|
-
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
336
|
-
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
|
|
337
|
-
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
|
|
338
|
-
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
339
|
-
|
|
340
|
-
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
341
|
-
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
|
|
342
|
-
|
|
343
|
-
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
|
|
344
|
-
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
|
|
345
|
-
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
|
|
346
|
-
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
|
|
347
|
-
|
|
348
|
-
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
|
|
349
|
-
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
|
|
342
|
+
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false, false);
|
|
343
|
+
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false, false);
|
|
344
|
+
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false, false);
|
|
345
|
+
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false, false);
|
|
346
|
+
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false, true);
|
|
347
|
+
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false, true);
|
|
348
|
+
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false, true);
|
|
349
|
+
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false, true);
|
|
350
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true, false);
|
|
351
|
+
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
|
|
352
|
+
|
|
353
|
+
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
|
|
354
|
+
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
|
|
355
|
+
|
|
356
|
+
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
|
|
357
|
+
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false, false);
|
|
358
|
+
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false, false);
|
|
359
|
+
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false, false);
|
|
360
|
+
|
|
361
|
+
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false, false);
|
|
362
|
+
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false, false);
|
|
350
363
|
|
|
351
364
|
return TransactionType;
|
|
352
365
|
})();
|
|
@@ -123,7 +123,7 @@ module.exports = (() => {
|
|
|
123
123
|
|
|
124
124
|
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
125
125
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
126
|
-
symbols.push(`^${
|
|
126
|
+
symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
return symbols;
|
|
@@ -677,7 +677,7 @@ module.exports = (() => {
|
|
|
677
677
|
actual.cashTotal = updates.cashTotal;
|
|
678
678
|
|
|
679
679
|
format.basis = formatCurrency(actual.basis, currency);
|
|
680
|
-
format.realized = formatCurrency(actual.
|
|
680
|
+
format.realized = formatCurrency(actual.realized, currency);
|
|
681
681
|
format.unrealized = formatCurrency(actual.unrealized, currency);
|
|
682
682
|
format.income = formatCurrency(actual.income, currency);
|
|
683
683
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|
|
@@ -233,7 +233,6 @@ module.exports = (() => {
|
|
|
233
233
|
.withField('dividend.effective', DataType.DAY, true)
|
|
234
234
|
.withField('dividend.price', DataType.DECIMAL, true)
|
|
235
235
|
.withField('dividend.amount', DataType.DECIMAL, true)
|
|
236
|
-
.withField('dividend.reference', DataType.STRING, true)
|
|
237
236
|
.withField('split.numerator', DataType.DECIMAL, true)
|
|
238
237
|
.withField('split.denominator', DataType.DECIMAL, true)
|
|
239
238
|
.withField('split.effective', DataType.DAY, true)
|
|
@@ -283,6 +282,7 @@ module.exports = (() => {
|
|
|
283
282
|
.withField('quantity', DataType.DECIMAL)
|
|
284
283
|
.withField('fee', DataType.DECIMAL, true)
|
|
285
284
|
.withField('force', DataType.BOOLEAN, true)
|
|
285
|
+
.withField('force', DataType.BOOLEAN, true)
|
|
286
286
|
.schema
|
|
287
287
|
);
|
|
288
288
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -463,9 +463,10 @@ module.exports = (() => {
|
|
|
463
463
|
* @param {Boolean} opening
|
|
464
464
|
* @param {Boolean} closing
|
|
465
465
|
* @param {Boolean} fee
|
|
466
|
+
* @param {Boolean} corporateAction
|
|
466
467
|
*/
|
|
467
468
|
class TransactionType extends Enum {
|
|
468
|
-
constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
|
|
469
|
+
constructor(code, description, display, purchase, sale, income, opening, closing, fee, corporateAction) {
|
|
469
470
|
super(code, description);
|
|
470
471
|
|
|
471
472
|
assert.argumentIsRequired(display, 'display', String);
|
|
@@ -475,6 +476,7 @@ module.exports = (() => {
|
|
|
475
476
|
assert.argumentIsRequired(opening, 'opening', Boolean);
|
|
476
477
|
assert.argumentIsRequired(closing, 'closing', Boolean);
|
|
477
478
|
assert.argumentIsRequired(fee, 'fee', Boolean);
|
|
479
|
+
assert.argumentIsRequired(corporateAction, 'corporateAction', Boolean);
|
|
478
480
|
|
|
479
481
|
this._display = display;
|
|
480
482
|
this._purchase = purchase;
|
|
@@ -483,6 +485,7 @@ module.exports = (() => {
|
|
|
483
485
|
this._opening = opening;
|
|
484
486
|
this._closing = closing;
|
|
485
487
|
this._fee = fee;
|
|
488
|
+
this._corporateAction = corporateAction;
|
|
486
489
|
}
|
|
487
490
|
|
|
488
491
|
/**
|
|
@@ -568,6 +571,16 @@ module.exports = (() => {
|
|
|
568
571
|
return this._fee;
|
|
569
572
|
}
|
|
570
573
|
|
|
574
|
+
/**
|
|
575
|
+
* Indicates if the transaction is a corporate action.
|
|
576
|
+
*
|
|
577
|
+
* @public
|
|
578
|
+
* @returns {Boolean}
|
|
579
|
+
*/
|
|
580
|
+
get corporateAction() {
|
|
581
|
+
return this._corporateAction;
|
|
582
|
+
}
|
|
583
|
+
|
|
571
584
|
/**
|
|
572
585
|
* A purchase.
|
|
573
586
|
*
|
|
@@ -771,27 +784,27 @@ module.exports = (() => {
|
|
|
771
784
|
}
|
|
772
785
|
}
|
|
773
786
|
|
|
774
|
-
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
|
|
775
|
-
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
|
|
776
|
-
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
|
|
777
|
-
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
|
|
778
|
-
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
|
|
779
|
-
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
780
|
-
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
781
|
-
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
|
|
782
|
-
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
|
|
783
|
-
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
787
|
+
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false, false);
|
|
788
|
+
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false, false);
|
|
789
|
+
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false, false);
|
|
790
|
+
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false, false);
|
|
791
|
+
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false, true);
|
|
792
|
+
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false, true);
|
|
793
|
+
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false, true);
|
|
794
|
+
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false, true);
|
|
795
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true, false);
|
|
796
|
+
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
|
|
784
797
|
|
|
785
|
-
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
786
|
-
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
|
|
798
|
+
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
|
|
799
|
+
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
|
|
787
800
|
|
|
788
|
-
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
|
|
789
|
-
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
|
|
790
|
-
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
|
|
791
|
-
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
|
|
801
|
+
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
|
|
802
|
+
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false, false);
|
|
803
|
+
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false, false);
|
|
804
|
+
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false, false);
|
|
792
805
|
|
|
793
|
-
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
|
|
794
|
-
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
|
|
806
|
+
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false, false);
|
|
807
|
+
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false, false);
|
|
795
808
|
|
|
796
809
|
return TransactionType;
|
|
797
810
|
})();
|
|
@@ -922,7 +935,7 @@ module.exports = (() => {
|
|
|
922
935
|
|
|
923
936
|
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
924
937
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
925
|
-
symbols.push(`^${
|
|
938
|
+
symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
|
|
926
939
|
}
|
|
927
940
|
|
|
928
941
|
return symbols;
|
|
@@ -2434,7 +2447,7 @@ module.exports = (() => {
|
|
|
2434
2447
|
actual.cashTotal = updates.cashTotal;
|
|
2435
2448
|
|
|
2436
2449
|
format.basis = formatCurrency(actual.basis, currency);
|
|
2437
|
-
format.realized = formatCurrency(actual.
|
|
2450
|
+
format.realized = formatCurrency(actual.realized, currency);
|
|
2438
2451
|
format.unrealized = formatCurrency(actual.unrealized, currency);
|
|
2439
2452
|
format.income = formatCurrency(actual.income, currency);
|
|
2440
2453
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|