@barchart/portfolio-api-common 1.0.233 → 1.0.237
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.
- package/lib/api/failures/PortfolioFailureType.js +12 -0
- package/lib/data/TransactionType.js +7 -7
- package/lib/formatters/TransactionFormatter.js +1 -0
- package/lib/processing/PositionContainer.js +1 -1
- package/lib/processing/PositionGroup.js +8 -0
- package/lib/processing/PositionItem.js +18 -3
- package/package.json +1 -1
- package/test/SpecRunner.js +129 -27
- package/package-lock.json +0 -5484
|
@@ -23,6 +23,17 @@ module.exports = (() => {
|
|
|
23
23
|
return positionCreateFailedNoPortfolio;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The referenced position does not exist.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
* @static
|
|
31
|
+
* @returns {FailureType}
|
|
32
|
+
*/
|
|
33
|
+
static get TRANSACTION_CREATE_FAILED_NO_POSITION() {
|
|
34
|
+
return transactionCreateFailedNoPosition;
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
/**
|
|
27
38
|
* The transaction would occur before an existing transaction.
|
|
28
39
|
*
|
|
@@ -94,6 +105,7 @@ module.exports = (() => {
|
|
|
94
105
|
|
|
95
106
|
const positionCreateFailedNoPortfolio = new FailureType('POSITION_CREATE_FAILED_NO_PORTFOLIO', 'Unable to create transaction. The referenced portfolio does not exist. Has it been deleted?');
|
|
96
107
|
|
|
108
|
+
const transactionCreateFailedNoPosition = new FailureType('TRANSACTION_CREATE_FAILED_NO_POSITION', 'Unable to create transaction. The referenced position does not exist. Has it been deleted?');
|
|
97
109
|
const transactionCreateFailedOutOfSequence = new FailureType('TRANSACTION_CREATE_FAILED_OUT_OF_SEQUENCE', 'Unable to process transaction, because the transaction date is out-of-sequence. In other words, it would occur before an existing transaction. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
|
|
98
110
|
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.');
|
|
99
111
|
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.');
|
|
@@ -61,7 +61,7 @@ module.exports = (() => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Indicates if the
|
|
64
|
+
* Indicates if the transaction was a purchase.
|
|
65
65
|
*
|
|
66
66
|
* @public
|
|
67
67
|
* @returns {Boolean}
|
|
@@ -71,7 +71,7 @@ module.exports = (() => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Indicates if the
|
|
74
|
+
* Indicates if the transaction was a sale.
|
|
75
75
|
*
|
|
76
76
|
* @public
|
|
77
77
|
* @returns {Boolean}
|
|
@@ -91,7 +91,7 @@ module.exports = (() => {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* Indicates if the
|
|
94
|
+
* Indicates if the transaction opens the position (i.e. increases its
|
|
95
95
|
* magnitude).
|
|
96
96
|
*
|
|
97
97
|
* @public
|
|
@@ -102,7 +102,7 @@ module.exports = (() => {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Indicates if the
|
|
105
|
+
* Indicates if the transaction closes the position (i.e. decreases its
|
|
106
106
|
* magnitude).
|
|
107
107
|
*
|
|
108
108
|
* @public
|
|
@@ -113,8 +113,8 @@ module.exports = (() => {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
-
* Indicates if the
|
|
117
|
-
* position.
|
|
116
|
+
* Indicates if the transaction is a chart that neither opens nor
|
|
117
|
+
* closes the position.
|
|
118
118
|
*
|
|
119
119
|
* @public
|
|
120
120
|
* @returns {Boolean}
|
|
@@ -334,7 +334,7 @@ module.exports = (() => {
|
|
|
334
334
|
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
335
335
|
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
336
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,
|
|
337
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
|
|
338
338
|
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
339
339
|
|
|
340
340
|
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
@@ -73,7 +73,7 @@ module.exports = (() => {
|
|
|
73
73
|
}, { });
|
|
74
74
|
|
|
75
75
|
this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
|
|
76
|
-
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(
|
|
76
|
+
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(1);
|
|
77
77
|
|
|
78
78
|
this._summariesPrevious = summaries.reduce((map, summary) => {
|
|
79
79
|
addSummaryPrevious(map, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
@@ -127,6 +127,7 @@ module.exports = (() => {
|
|
|
127
127
|
this._dataActual.total = null;
|
|
128
128
|
this._dataActual.summaryTotalCurrent = null;
|
|
129
129
|
this._dataActual.summaryTotalPrevious = null;
|
|
130
|
+
this._dataActual.summaryTotalPrevious2 = null;
|
|
130
131
|
this._dataActual.cashTotal = null;
|
|
131
132
|
|
|
132
133
|
this._dataFormat.currentPrice = null;
|
|
@@ -148,6 +149,8 @@ module.exports = (() => {
|
|
|
148
149
|
this._dataActual.summaryTotalCurrentNegative = false;
|
|
149
150
|
this._dataFormat.summaryTotalPrevious = null;
|
|
150
151
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
152
|
+
this._dataFormat.summaryTotalPrevious2 = null;
|
|
153
|
+
this._dataFormat.summaryTotalPrevious2Negative = false;
|
|
151
154
|
this._dataFormat.cashTotal = null;
|
|
152
155
|
this._dataFormat.portfolioType = null;
|
|
153
156
|
|
|
@@ -595,6 +598,7 @@ module.exports = (() => {
|
|
|
595
598
|
updates.income = updates.income.add(translate(item, item.data.income));
|
|
596
599
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
597
600
|
updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
|
|
601
|
+
updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
|
|
598
602
|
|
|
599
603
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
600
604
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -608,6 +612,7 @@ module.exports = (() => {
|
|
|
608
612
|
income: Decimal.ZERO,
|
|
609
613
|
summaryTotalCurrent: Decimal.ZERO,
|
|
610
614
|
summaryTotalPrevious: Decimal.ZERO,
|
|
615
|
+
summaryTotalPrevious2: Decimal.ZERO,
|
|
611
616
|
cashTotal: Decimal.ZERO
|
|
612
617
|
});
|
|
613
618
|
|
|
@@ -617,6 +622,7 @@ module.exports = (() => {
|
|
|
617
622
|
actual.income = updates.income;
|
|
618
623
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
619
624
|
actual.summaryTotalPrevious = updates.summaryTotalPrevious;
|
|
625
|
+
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
620
626
|
actual.cashTotal = updates.cashTotal;
|
|
621
627
|
|
|
622
628
|
format.basis = formatCurrency(actual.basis, currency);
|
|
@@ -626,6 +632,8 @@ module.exports = (() => {
|
|
|
626
632
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|
|
627
633
|
format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
|
|
628
634
|
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
635
|
+
format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
|
|
636
|
+
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
629
637
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
630
638
|
|
|
631
639
|
calculateUnrealizedPercent(group);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
assert = require('@barchart/common-js/lang/assert'),
|
|
1
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
3
2
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
4
3
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
5
4
|
Disposable = require('@barchart/common-js/lang/Disposable'),
|
|
@@ -59,6 +58,7 @@ module.exports = (() => {
|
|
|
59
58
|
this._data.summaryTotalCurrentChange = null;
|
|
60
59
|
|
|
61
60
|
this._data.summaryTotalPrevious = null;
|
|
61
|
+
this._data.summaryTotalPrevious2 = null;
|
|
62
62
|
|
|
63
63
|
this._data.realized = null;
|
|
64
64
|
this._data.income = null;
|
|
@@ -318,7 +318,8 @@ module.exports = (() => {
|
|
|
318
318
|
data.income = snapshot.income;
|
|
319
319
|
|
|
320
320
|
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
|
|
321
|
-
data.summaryTotalPrevious = calculateSummaryTotal(
|
|
321
|
+
data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1));
|
|
322
|
+
data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2));
|
|
322
323
|
|
|
323
324
|
if (snapshot.open.getIsZero()) {
|
|
324
325
|
data.basisPrice = Decimal.ZERO;
|
|
@@ -439,5 +440,19 @@ module.exports = (() => {
|
|
|
439
440
|
return returnRef;
|
|
440
441
|
}
|
|
441
442
|
|
|
443
|
+
function getPreviousSummary(previousSummaries, count) {
|
|
444
|
+
const index = previousSummaries.length - count;
|
|
445
|
+
|
|
446
|
+
let summary;
|
|
447
|
+
|
|
448
|
+
if (!(index < 0)) {
|
|
449
|
+
summary = previousSummaries[index];
|
|
450
|
+
} else {
|
|
451
|
+
summary = null;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return summary;
|
|
455
|
+
}
|
|
456
|
+
|
|
442
457
|
return PositionItem;
|
|
443
458
|
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){function e
|
|
1
|
+
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
const uuid = require('uuid');
|
|
3
3
|
|
|
4
4
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
@@ -506,7 +506,7 @@ module.exports = (() => {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
|
-
* Indicates if the
|
|
509
|
+
* Indicates if the transaction was a purchase.
|
|
510
510
|
*
|
|
511
511
|
* @public
|
|
512
512
|
* @returns {Boolean}
|
|
@@ -516,7 +516,7 @@ module.exports = (() => {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
/**
|
|
519
|
-
* Indicates if the
|
|
519
|
+
* Indicates if the transaction was a sale.
|
|
520
520
|
*
|
|
521
521
|
* @public
|
|
522
522
|
* @returns {Boolean}
|
|
@@ -536,7 +536,7 @@ module.exports = (() => {
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
/**
|
|
539
|
-
* Indicates if the
|
|
539
|
+
* Indicates if the transaction opens the position (i.e. increases its
|
|
540
540
|
* magnitude).
|
|
541
541
|
*
|
|
542
542
|
* @public
|
|
@@ -547,7 +547,7 @@ module.exports = (() => {
|
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
/**
|
|
550
|
-
* Indicates if the
|
|
550
|
+
* Indicates if the transaction closes the position (i.e. decreases its
|
|
551
551
|
* magnitude).
|
|
552
552
|
*
|
|
553
553
|
* @public
|
|
@@ -558,8 +558,8 @@ module.exports = (() => {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
* Indicates if the
|
|
562
|
-
* position.
|
|
561
|
+
* Indicates if the transaction is a chart that neither opens nor
|
|
562
|
+
* closes the position.
|
|
563
563
|
*
|
|
564
564
|
* @public
|
|
565
565
|
* @returns {Boolean}
|
|
@@ -779,7 +779,7 @@ module.exports = (() => {
|
|
|
779
779
|
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
780
780
|
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
781
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,
|
|
782
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
|
|
783
783
|
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
784
784
|
|
|
785
785
|
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
@@ -872,7 +872,7 @@ module.exports = (() => {
|
|
|
872
872
|
}, { });
|
|
873
873
|
|
|
874
874
|
this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
|
|
875
|
-
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(
|
|
875
|
+
this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(1);
|
|
876
876
|
|
|
877
877
|
this._summariesPrevious = summaries.reduce((map, summary) => {
|
|
878
878
|
addSummaryPrevious(map, summary, this._previousSummaryFrame, this._previousSummaryRanges);
|
|
@@ -1821,6 +1821,7 @@ module.exports = (() => {
|
|
|
1821
1821
|
this._dataActual.total = null;
|
|
1822
1822
|
this._dataActual.summaryTotalCurrent = null;
|
|
1823
1823
|
this._dataActual.summaryTotalPrevious = null;
|
|
1824
|
+
this._dataActual.summaryTotalPrevious2 = null;
|
|
1824
1825
|
this._dataActual.cashTotal = null;
|
|
1825
1826
|
|
|
1826
1827
|
this._dataFormat.currentPrice = null;
|
|
@@ -1842,6 +1843,8 @@ module.exports = (() => {
|
|
|
1842
1843
|
this._dataActual.summaryTotalCurrentNegative = false;
|
|
1843
1844
|
this._dataFormat.summaryTotalPrevious = null;
|
|
1844
1845
|
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
1846
|
+
this._dataFormat.summaryTotalPrevious2 = null;
|
|
1847
|
+
this._dataFormat.summaryTotalPrevious2Negative = false;
|
|
1845
1848
|
this._dataFormat.cashTotal = null;
|
|
1846
1849
|
this._dataFormat.portfolioType = null;
|
|
1847
1850
|
|
|
@@ -2289,6 +2292,7 @@ module.exports = (() => {
|
|
|
2289
2292
|
updates.income = updates.income.add(translate(item, item.data.income));
|
|
2290
2293
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
|
|
2291
2294
|
updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
|
|
2295
|
+
updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
|
|
2292
2296
|
|
|
2293
2297
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
2294
2298
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -2302,6 +2306,7 @@ module.exports = (() => {
|
|
|
2302
2306
|
income: Decimal.ZERO,
|
|
2303
2307
|
summaryTotalCurrent: Decimal.ZERO,
|
|
2304
2308
|
summaryTotalPrevious: Decimal.ZERO,
|
|
2309
|
+
summaryTotalPrevious2: Decimal.ZERO,
|
|
2305
2310
|
cashTotal: Decimal.ZERO
|
|
2306
2311
|
});
|
|
2307
2312
|
|
|
@@ -2311,6 +2316,7 @@ module.exports = (() => {
|
|
|
2311
2316
|
actual.income = updates.income;
|
|
2312
2317
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
2313
2318
|
actual.summaryTotalPrevious = updates.summaryTotalPrevious;
|
|
2319
|
+
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
2314
2320
|
actual.cashTotal = updates.cashTotal;
|
|
2315
2321
|
|
|
2316
2322
|
format.basis = formatCurrency(actual.basis, currency);
|
|
@@ -2320,6 +2326,8 @@ module.exports = (() => {
|
|
|
2320
2326
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|
|
2321
2327
|
format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
|
|
2322
2328
|
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
2329
|
+
format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
|
|
2330
|
+
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
2323
2331
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
2324
2332
|
|
|
2325
2333
|
calculateUnrealizedPercent(group);
|
|
@@ -2503,8 +2511,7 @@ module.exports = (() => {
|
|
|
2503
2511
|
})();
|
|
2504
2512
|
|
|
2505
2513
|
},{"./../data/InstrumentType":1,"./definitions/PositionLevelDefinition":7,"./definitions/PositionLevelType":8,"@barchart/common-js/collections/specialized/DisposableStack":14,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/Rate":20,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/formatter":23,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],6:[function(require,module,exports){
|
|
2506
|
-
const
|
|
2507
|
-
assert = require('@barchart/common-js/lang/assert'),
|
|
2514
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
2508
2515
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2509
2516
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
2510
2517
|
Disposable = require('@barchart/common-js/lang/Disposable'),
|
|
@@ -2564,6 +2571,7 @@ module.exports = (() => {
|
|
|
2564
2571
|
this._data.summaryTotalCurrentChange = null;
|
|
2565
2572
|
|
|
2566
2573
|
this._data.summaryTotalPrevious = null;
|
|
2574
|
+
this._data.summaryTotalPrevious2 = null;
|
|
2567
2575
|
|
|
2568
2576
|
this._data.realized = null;
|
|
2569
2577
|
this._data.income = null;
|
|
@@ -2823,7 +2831,8 @@ module.exports = (() => {
|
|
|
2823
2831
|
data.income = snapshot.income;
|
|
2824
2832
|
|
|
2825
2833
|
data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
|
|
2826
|
-
data.summaryTotalPrevious = calculateSummaryTotal(
|
|
2834
|
+
data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1));
|
|
2835
|
+
data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2));
|
|
2827
2836
|
|
|
2828
2837
|
if (snapshot.open.getIsZero()) {
|
|
2829
2838
|
data.basisPrice = Decimal.ZERO;
|
|
@@ -2944,10 +2953,24 @@ module.exports = (() => {
|
|
|
2944
2953
|
return returnRef;
|
|
2945
2954
|
}
|
|
2946
2955
|
|
|
2956
|
+
function getPreviousSummary(previousSummaries, count) {
|
|
2957
|
+
const index = previousSummaries.length - count;
|
|
2958
|
+
|
|
2959
|
+
let summary;
|
|
2960
|
+
|
|
2961
|
+
if (!(index < 0)) {
|
|
2962
|
+
summary = previousSummaries[index];
|
|
2963
|
+
} else {
|
|
2964
|
+
summary = null;
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
return summary;
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2947
2970
|
return PositionItem;
|
|
2948
2971
|
})();
|
|
2949
2972
|
|
|
2950
|
-
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/
|
|
2973
|
+
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],7:[function(require,module,exports){
|
|
2951
2974
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2952
2975
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2953
2976
|
is = require('@barchart/common-js/lang/is');
|
|
@@ -3493,14 +3516,31 @@ module.exports = function () {
|
|
|
3493
3516
|
}
|
|
3494
3517
|
|
|
3495
3518
|
/**
|
|
3496
|
-
*
|
|
3519
|
+
* Gets the root node.
|
|
3497
3520
|
*
|
|
3498
3521
|
* @public
|
|
3499
|
-
* @returns {Tree
|
|
3522
|
+
* @returns {Tree}
|
|
3500
3523
|
*/
|
|
3501
3524
|
|
|
3502
3525
|
|
|
3503
3526
|
_createClass(Tree, [{
|
|
3527
|
+
key: 'getRoot',
|
|
3528
|
+
value: function getRoot() {
|
|
3529
|
+
if (this.getIsRoot()) {
|
|
3530
|
+
return this;
|
|
3531
|
+
} else {
|
|
3532
|
+
return this._parent.getRoot();
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
/**
|
|
3537
|
+
* Returns the parent node. If this is the root node, a null value is returned.
|
|
3538
|
+
*
|
|
3539
|
+
* @public
|
|
3540
|
+
* @returns {Tree|null}
|
|
3541
|
+
*/
|
|
3542
|
+
|
|
3543
|
+
}, {
|
|
3504
3544
|
key: 'getParent',
|
|
3505
3545
|
value: function getParent() {
|
|
3506
3546
|
return this._parent;
|
|
@@ -3601,6 +3641,23 @@ module.exports = function () {
|
|
|
3601
3641
|
}
|
|
3602
3642
|
}
|
|
3603
3643
|
|
|
3644
|
+
/**
|
|
3645
|
+
* Removes the current node from the parent tree. Use on a root node
|
|
3646
|
+
* has no effect.
|
|
3647
|
+
*
|
|
3648
|
+
* @public
|
|
3649
|
+
*/
|
|
3650
|
+
|
|
3651
|
+
}, {
|
|
3652
|
+
key: 'sever',
|
|
3653
|
+
value: function sever() {
|
|
3654
|
+
if (this.getIsRoot()) {
|
|
3655
|
+
return;
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
this.getParent().removeChild(this);
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3604
3661
|
/**
|
|
3605
3662
|
* Searches the children nodes for the first child node that matches the
|
|
3606
3663
|
* predicate.
|
|
@@ -4995,6 +5052,20 @@ module.exports = function () {
|
|
|
4995
5052
|
return this._big.gt(getBig(other));
|
|
4996
5053
|
}
|
|
4997
5054
|
|
|
5055
|
+
/**
|
|
5056
|
+
* Returns true if the current instance is greater than or equal to the value.
|
|
5057
|
+
*
|
|
5058
|
+
* @public
|
|
5059
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
5060
|
+
* @returns {Boolean}
|
|
5061
|
+
*/
|
|
5062
|
+
|
|
5063
|
+
}, {
|
|
5064
|
+
key: 'getIsGreaterThanOrEqual',
|
|
5065
|
+
value: function getIsGreaterThanOrEqual(other) {
|
|
5066
|
+
return this._big.gte(getBig(other));
|
|
5067
|
+
}
|
|
5068
|
+
|
|
4998
5069
|
/**
|
|
4999
5070
|
* Returns true if the current instance is less than the value.
|
|
5000
5071
|
*
|
|
@@ -5009,6 +5080,20 @@ module.exports = function () {
|
|
|
5009
5080
|
return this._big.lt(getBig(other));
|
|
5010
5081
|
}
|
|
5011
5082
|
|
|
5083
|
+
/**
|
|
5084
|
+
* Returns true if the current instance is less than or equal to the value.
|
|
5085
|
+
*
|
|
5086
|
+
* @public
|
|
5087
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
5088
|
+
* @returns {Boolean}
|
|
5089
|
+
*/
|
|
5090
|
+
|
|
5091
|
+
}, {
|
|
5092
|
+
key: 'getIsLessThanOrEqual',
|
|
5093
|
+
value: function getIsLessThanOrEqual(other) {
|
|
5094
|
+
return this._big.lte(getBig(other));
|
|
5095
|
+
}
|
|
5096
|
+
|
|
5012
5097
|
/**
|
|
5013
5098
|
* Returns true if the current instance is equal to the value.
|
|
5014
5099
|
*
|
|
@@ -5208,9 +5293,9 @@ module.exports = function () {
|
|
|
5208
5293
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
5209
5294
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
5210
5295
|
|
|
5211
|
-
if (a._big.gt(b)) {
|
|
5296
|
+
if (a._big.gt(b._big)) {
|
|
5212
5297
|
return 1;
|
|
5213
|
-
} else if (a._big.lt(b)) {
|
|
5298
|
+
} else if (a._big.lt(b._big)) {
|
|
5214
5299
|
return -1;
|
|
5215
5300
|
} else {
|
|
5216
5301
|
return 0;
|
|
@@ -5671,12 +5756,10 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
5671
5756
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5672
5757
|
|
|
5673
5758
|
var assert = require('./assert'),
|
|
5674
|
-
is = require('./is'),
|
|
5675
5759
|
memoize = require('./memoize');
|
|
5676
5760
|
|
|
5677
5761
|
var Currency = require('./Currency'),
|
|
5678
|
-
Decimal = require('./Decimal')
|
|
5679
|
-
Enum = require('./Enum');
|
|
5762
|
+
Decimal = require('./Decimal');
|
|
5680
5763
|
|
|
5681
5764
|
module.exports = function () {
|
|
5682
5765
|
'use strict';
|
|
@@ -5856,12 +5939,7 @@ module.exports = function () {
|
|
|
5856
5939
|
assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
|
|
5857
5940
|
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
5858
5941
|
assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
|
|
5859
|
-
|
|
5860
|
-
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5861
|
-
rates[_key - 3] = arguments[_key];
|
|
5862
|
-
}
|
|
5863
|
-
|
|
5864
|
-
assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
5942
|
+
//assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
5865
5943
|
|
|
5866
5944
|
var converted = void 0;
|
|
5867
5945
|
|
|
@@ -5871,6 +5949,10 @@ module.exports = function () {
|
|
|
5871
5949
|
var numerator = desiredCurrency;
|
|
5872
5950
|
var denominator = currency;
|
|
5873
5951
|
|
|
5952
|
+
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5953
|
+
rates[_key - 3] = arguments[_key];
|
|
5954
|
+
}
|
|
5955
|
+
|
|
5874
5956
|
var rate = rates.find(function (r) {
|
|
5875
5957
|
return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
|
|
5876
5958
|
});
|
|
@@ -5921,7 +6003,7 @@ module.exports = function () {
|
|
|
5921
6003
|
return Rate;
|
|
5922
6004
|
}();
|
|
5923
6005
|
|
|
5924
|
-
},{"./Currency":15,"./Decimal":17,"./
|
|
6006
|
+
},{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
|
|
5925
6007
|
'use strict';
|
|
5926
6008
|
|
|
5927
6009
|
var assert = require('./assert'),
|
|
@@ -6298,6 +6380,26 @@ module.exports = function () {
|
|
|
6298
6380
|
});
|
|
6299
6381
|
|
|
6300
6382
|
return returnRef;
|
|
6383
|
+
},
|
|
6384
|
+
|
|
6385
|
+
|
|
6386
|
+
/**
|
|
6387
|
+
* Removes the first item from an array which matches a predicate.
|
|
6388
|
+
*
|
|
6389
|
+
* @static
|
|
6390
|
+
* @public
|
|
6391
|
+
* @param {Array} a
|
|
6392
|
+
* @param {Function} predicate
|
|
6393
|
+
*/
|
|
6394
|
+
remove: function remove(a, predicate) {
|
|
6395
|
+
assert.argumentIsArray(a, 'a');
|
|
6396
|
+
assert.argumentIsRequired(predicate, 'predicate', Function);
|
|
6397
|
+
|
|
6398
|
+
var index = a.findIndex(predicate);
|
|
6399
|
+
|
|
6400
|
+
if (!(index < 0)) {
|
|
6401
|
+
a.splice(index, 1);
|
|
6402
|
+
}
|
|
6301
6403
|
}
|
|
6302
6404
|
};
|
|
6303
6405
|
}();
|