@@ -1985,7 +1985,7 @@ module.exports = (() => {
19851985 return;
19861986 }
19871987
1988- retrieveProfileExtensions(array.difference(symbols, __completedProfileExtensions), __loginInfo.username, __loginInfo.password ).then(extensions => {
1988+ retrieveProfileExtensions(array.difference(symbols, __completedProfileExtensions)).then(extensions => {
19891989 if (__connectionState !== state.authenticated) {
19901990 return;
19911991 }
@@ -3282,14 +3282,14 @@ module.exports = (() => {
32823282 * @returns {Promise<ProfileExtension[]>}
32833283 */
32843284
3285- function retrieveExtensions(symbols, username, password ) {
3285+ function retrieveExtensions(symbols) {
32863286 return Promise.resolve().then(() => {
32873287 if (logger === null) {
32883288 logger = LoggerFactory.getLogger('@barchart/marketdata-api-js');
32893289 }
32903290
32913291 assert.argumentIsArray(symbols, 'symbols', String);
3292- return Promise.all([retrieveExtensionsForC3(symbols.filter(SymbolParser.getIsC3)), retrieveExtensionsForCmdtyStats(symbols.filter(SymbolParser.getIsCmdtyStats)), retrieveExtensionsForFutures(symbols.filter(SymbolParser.getIsFuture)), retrieveExtensionsForFuturesOptions(symbols.filter(SymbolParser.getIsFutureOption))]).then(results => {
3292+ return Promise.all([retrieveExtensionsForC3(symbols.filter(SymbolParser.getIsC3)), retrieveExtensionsForCmdtyStats(symbols.filter(SymbolParser.getIsCmdtyStats)), retrieveExtensionsForFutures(symbols.filter(SymbolParser.getIsFuture)), retrieveExtensionsForFuturesOptions(symbols.filter(SymbolParser.getIsFutureOption)), retrieveExtensionsForGrainBids(symbols.filter(SymbolParser.getIsGrainBid)) ]).then(results => {
32933293 return array.flatten(results);
32943294 });
32953295 });
@@ -3510,6 +3510,34 @@ module.exports = (() => {
35103510 });
35113511 }
35123512
3513+ function retrieveExtensionsForGrainBids(symbols) {
3514+ return Promise.resolve().then(() => {
3515+ if (symbols.length === 0) {
3516+ return Promise.resolve([]);
3517+ }
3518+
3519+ const options = {
3520+ url: `https://instrument-extensions.aws.barchart.com/v1/grains/meta?&symbols=${encodeURIComponent(symbols.join())}`,
3521+ method: 'GET'
3522+ };
3523+ return Promise.resolve(axios(options)).then(response => {
3524+ if (response.status !== 200) {
3525+ return [];
3526+ }
3527+
3528+ const results = (response.data || []).filter(result => {
3529+ return result.meta !== null;
3530+ });
3531+ return results.map(result => {
3532+ const extension = {};
3533+ extension.symbol = result.symbol;
3534+ extension.grainBid = result.meta;
3535+ return extension;
3536+ });
3537+ });
3538+ });
3539+ }
3540+
35133541 const regex = {};
35143542 regex.dates = {};
35153543 regex.dates.expire = /^([0-9]{4}-[0-9]{2}-[0-9]{2})T/;
@@ -3541,9 +3569,10 @@ module.exports = (() => {
35413569 * @ignore
35423570 * @property {String} symbol
35433571 * @property {String=} expiration
3544- * @property {String=} firstNotice
35453572 * @property {Object=} c3
35463573 * @property {Object=} cmdtyStats
3574+ * @property {String=} firstNotice
3575+ * @property {Object=} grainBid
35473576 * @property {Object=} option
35483577 */
35493578
@@ -4809,6 +4838,10 @@ module.exports = (() => {
48094838 profile.cmdtyStats = extension.cmdtyStats;
48104839 }
48114840
4841+ if (extension.grainBid) {
4842+ profile.grainBid = extension.grainBid;
4843+ }
4844+
48124845 if (extension.option) {
48134846 profile.option = extension.option;
48144847 }
@@ -6109,7 +6142,7 @@ module.exports = (() => {
61096142 'use strict';
61106143
61116144 return {
6112- version: '5.26 .0'
6145+ version: '5.27 .0'
61136146 };
61146147})();
61156148
@@ -8091,7 +8124,7 @@ module.exports = (() => {
80918124 return is.string(symbol) && types.indicies.external.test(symbol);
80928125 }
80938126 /**
8094- * Returns true if the symbol represents an Barchart sector (i.e. a type
8127+ * Returns true if the symbol represents a Barchart sector (i.e. a type
80958128 * of index calculated by Barchart).
80968129 *
80978130 * @public
@@ -8244,6 +8277,19 @@ module.exports = (() => {
82448277 static getIsPit(symbol, name) {
82458278 return is.string(symbol) && is.string(name) && predicates.pit.test(name);
82468279 }
8280+ /**
8281+ * Returns true if the symbol represents a grain bid instrument.
8282+ *
8283+ * @public
8284+ * @static
8285+ * @param {String} symbol
8286+ * @returns {Boolean}
8287+ */
8288+
8289+
8290+ static getIsGrainBid(symbol) {
8291+ return is.string(symbol) && types.bids.test(symbol);
8292+ }
82478293 /**
82488294 * Returns a simple instrument definition containing information which
82498295 * can be inferred from the symbol. A null value is returned if nothing
@@ -8412,6 +8458,7 @@ module.exports = (() => {
84128458 predicates.percent = /(\.RT)$/;
84138459 predicates.pit = /\(P(it)?\)/;
84148460 const types = {};
8461+ types.bids = /^([A-Z]{2})([B|P])([A-Z\d]{3,4})-(\d+)-(\d+)(\.CM)$/i;
84158462 types.c3 = {};
84168463 types.c3.alias = /^(C3:)(.*)$/i;
84178464 types.c3.concrete = /(\.C3)$/i;
0 commit comments