@barchart/portfolio-api-common 1.0.193 → 1.0.197
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.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const FailureType = require('@barchart/common-js/api/failures/FailureType');
|
|
2
|
+
|
|
3
|
+
module.exports = (() => {
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A static container for portfolio-specific {@link FailureType} items.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class PortfolioFailureType {
|
|
12
|
+
constructor() {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The transaction would occur before an existing transaction.
|
|
17
|
+
*
|
|
18
|
+
* @static
|
|
19
|
+
* @returns {FailureType}
|
|
20
|
+
*/
|
|
21
|
+
static get TRANSACTION_CREATE_FAILED_OUT_OF_SEQUENCE() {
|
|
22
|
+
return transactionCreateFailedOutOfSequence;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toString() {
|
|
26
|
+
return '[PortfolioFailureType]';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const transactionCreateFailedOutOfSequence = new FailureType('TRANSACTION_CREATE_FAILED_OUT_OF_SEQUENCE', 'Unable to create transaction, the transaction date is out-of-sequence (i.e. it would occur before an existing transaction). Please confirm your intent to re-write transaction history.');
|
|
31
|
+
|
|
32
|
+
return PortfolioFailureType;
|
|
33
|
+
})();
|
|
@@ -24,6 +24,11 @@ module.exports = (() => {
|
|
|
24
24
|
|
|
25
25
|
const DEFAULT_CURRENCY = Currency.CAD;
|
|
26
26
|
|
|
27
|
+
const REQUIRED_CURRENCIES = [
|
|
28
|
+
Currency.CAD,
|
|
29
|
+
Currency.USD
|
|
30
|
+
];
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
33
|
* A container for positions which groups the positions into one or more
|
|
29
34
|
* trees for aggregation and display purposes. For example, positions could be
|
|
@@ -114,7 +119,9 @@ module.exports = (() => {
|
|
|
114
119
|
return map;
|
|
115
120
|
}, { });
|
|
116
121
|
|
|
117
|
-
|
|
122
|
+
const forexCurrencyCodes = array.unique(Object.keys(this._currencies).concat(REQUIRED_CURRENCIES.map(c => c.code)));
|
|
123
|
+
|
|
124
|
+
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
118
125
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
119
126
|
symbols.push(`^${DEFAULT_CURRENCY.code}${code}`);
|
|
120
127
|
}
|
|
@@ -290,7 +297,7 @@ module.exports = (() => {
|
|
|
290
297
|
|
|
291
298
|
const addedBarchartSymbol = extractSymbolForBarchart(item.position);
|
|
292
299
|
|
|
293
|
-
if (!existingBarchartSymbols.some(existingBarchartSymbol => existingBarchartSymbol === addedBarchartSymbol)) {
|
|
300
|
+
if (addedBarchartSymbol !== null && !existingBarchartSymbols.some(existingBarchartSymbol => existingBarchartSymbol === addedBarchartSymbol)) {
|
|
294
301
|
this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
|
|
295
302
|
}
|
|
296
303
|
});
|
|
@@ -562,7 +569,7 @@ module.exports = (() => {
|
|
|
562
569
|
* @param {Function} handler
|
|
563
570
|
* @returns {Disposable}
|
|
564
571
|
*/
|
|
565
|
-
|
|
572
|
+
registerPositionSymbolRemovedHandler(handler) {
|
|
566
573
|
return this._positionSymbolRemovedEvent.register(handler);
|
|
567
574
|
}
|
|
568
575
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -740,6 +740,11 @@ module.exports = (() => {
|
|
|
740
740
|
|
|
741
741
|
const DEFAULT_CURRENCY = Currency.CAD;
|
|
742
742
|
|
|
743
|
+
const REQUIRED_CURRENCIES = [
|
|
744
|
+
Currency.CAD,
|
|
745
|
+
Currency.USD
|
|
746
|
+
];
|
|
747
|
+
|
|
743
748
|
/**
|
|
744
749
|
* A container for positions which groups the positions into one or more
|
|
745
750
|
* trees for aggregation and display purposes. For example, positions could be
|
|
@@ -830,7 +835,9 @@ module.exports = (() => {
|
|
|
830
835
|
return map;
|
|
831
836
|
}, { });
|
|
832
837
|
|
|
833
|
-
|
|
838
|
+
const forexCurrencyCodes = array.unique(Object.keys(this._currencies).concat(REQUIRED_CURRENCIES.map(c => c.code)));
|
|
839
|
+
|
|
840
|
+
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
834
841
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
835
842
|
symbols.push(`^${DEFAULT_CURRENCY.code}${code}`);
|
|
836
843
|
}
|
|
@@ -1006,7 +1013,7 @@ module.exports = (() => {
|
|
|
1006
1013
|
|
|
1007
1014
|
const addedBarchartSymbol = extractSymbolForBarchart(item.position);
|
|
1008
1015
|
|
|
1009
|
-
if (!existingBarchartSymbols.some(existingBarchartSymbol => existingBarchartSymbol === addedBarchartSymbol)) {
|
|
1016
|
+
if (addedBarchartSymbol !== null && !existingBarchartSymbols.some(existingBarchartSymbol => existingBarchartSymbol === addedBarchartSymbol)) {
|
|
1010
1017
|
this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
|
|
1011
1018
|
}
|
|
1012
1019
|
});
|
|
@@ -1278,7 +1285,7 @@ module.exports = (() => {
|
|
|
1278
1285
|
* @param {Function} handler
|
|
1279
1286
|
* @returns {Disposable}
|
|
1280
1287
|
*/
|
|
1281
|
-
|
|
1288
|
+
registerPositionSymbolRemovedHandler(handler) {
|
|
1282
1289
|
return this._positionSymbolRemovedEvent.register(handler);
|
|
1283
1290
|
}
|
|
1284
1291
|
|