@barchart/portfolio-api-common 1.29.0 → 1.29.2
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.
|
@@ -463,10 +463,17 @@ module.exports = (() => {
|
|
|
463
463
|
*
|
|
464
464
|
* @public
|
|
465
465
|
* @param {Boolean} display - If true, all "display" symbols are returned; otherwise Barchart symbols are returned.
|
|
466
|
+
* @param {Boolean} excludeExpired - If true, only non-expired symbols are filtered.
|
|
466
467
|
* @returns {String[]}
|
|
467
468
|
*/
|
|
468
|
-
getPositionSymbols(display) {
|
|
469
|
-
|
|
469
|
+
getPositionSymbols(display, excludeExpired) {
|
|
470
|
+
let items = this._items;
|
|
471
|
+
|
|
472
|
+
if (excludeExpired) {
|
|
473
|
+
items = items.filter(item => !item.data.expired);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const symbols = items.reduce((symbols, item) => {
|
|
470
477
|
const position = item.position;
|
|
471
478
|
|
|
472
479
|
let symbol;
|
|
@@ -12,15 +12,19 @@ const EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointB
|
|
|
12
12
|
module.exports = (() => {
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const DEFAULT_MAXIMUM_WAIT_BEFORE_TIMEOUT_IN_MILLISECONDS = 3 * 1000;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* A utility that downloads instrument metadata (i.e. instrument "profile" data).
|
|
19
19
|
*
|
|
20
20
|
* @public
|
|
21
|
+
* @param {Number=} waitInMilliseconds - The maximum amount of time to wait for the response from server.
|
|
21
22
|
*/
|
|
22
23
|
class InstrumentProvider {
|
|
23
|
-
constructor() {
|
|
24
|
+
constructor(waitInMilliseconds) {
|
|
25
|
+
assert.argumentIsOptional(waitInMilliseconds, 'waitInMillis', Number);
|
|
26
|
+
|
|
27
|
+
this._waitInMilliseconds = waitInMilliseconds || DEFAULT_MAXIMUM_WAIT_BEFORE_TIMEOUT_IN_MILLISECONDS;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -37,7 +41,7 @@ module.exports = (() => {
|
|
|
37
41
|
.then(() => {
|
|
38
42
|
assert.argumentIsRequired(symbol, 'symbol', String);
|
|
39
43
|
|
|
40
|
-
return promise.timeout(Gateway.invoke(instrumentLookupEndpoint, { symbol }),
|
|
44
|
+
return promise.timeout(Gateway.invoke(instrumentLookupEndpoint, { symbol }), this._waitInMilliseconds, 'instrument lookup')
|
|
41
45
|
.catch((e) => {
|
|
42
46
|
let message;
|
|
43
47
|
|