Skip to content

Commit 25871e8

Browse files
committed
Release. Bump version number
1 parent 07afac6 commit 25871e8

File tree

5 files changed

+78
-14
lines changed

5 files changed

+78
-14
lines changed

docs/_coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Barchart Market Data SDK <small>JavaScript 5.23.0</small>
1+
# Barchart Market Data SDK <small>JavaScript 5.24.0</small>
22

33
> Inject real-time market data into your JavaScript applications
44

example/browser/example.js

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ module.exports = (() => {
22862286

22872287

22882288
function getIsExtendedQuoteSymbol(symbol) {
2289-
return SymbolParser.getIsFuture(symbol);
2289+
return SymbolParser.getIsFuture(symbol) || SymbolParser.getIsCmdtyStats(symbol);
22902290
}
22912291
/**
22922292
* Breaks an array of symbols into multiple array, each containing no more
@@ -3622,7 +3622,7 @@ module.exports = (() => {
36223622
const futuresSymbols = array.unique(symbolsToUse.filter(s => SymbolParser.getIsFuture(s) && SymbolParser.getIsConcrete(s)).sort());
36233623

36243624
if (futuresSymbols.length !== 0) {
3625-
promises.push(retrieveFuturesHiLo(futuresSymbols, username, password).then(results => {
3625+
promises.push(retrieveFuturesHiLo(futuresSymbols).then(results => {
36263626
results.forEach(result => {
36273627
if (result.hilo) {
36283628
const extension = getOrCreateExtension(result.symbol);
@@ -3637,6 +3637,29 @@ module.exports = (() => {
36373637
}));
36383638
}
36393639

3640+
const cmdtyStatsSymbols = array.unique(symbolsToUse.filter(s => SymbolParser.getIsCmdtyStats(s)).sort());
3641+
3642+
if (cmdtyStatsSymbols.length !== 0) {
3643+
promises.push(retrieveCmdtyStatsDates(cmdtyStatsSymbols).then(results => {
3644+
results.forEach(result => {
3645+
if (result.quote) {
3646+
const extension = getOrCreateExtension(result.symbol);
3647+
const cmdtyStats = {};
3648+
3649+
if (result.quote.current) {
3650+
cmdtyStats.currentDate = result.quote.current.date;
3651+
}
3652+
3653+
if (result.quote.previous) {
3654+
cmdtyStats.previousDate = result.quote.previous.date;
3655+
}
3656+
3657+
extension.cmdtyStats = cmdtyStats;
3658+
}
3659+
});
3660+
}));
3661+
}
3662+
36403663
if (promises.length === 0) {
36413664
return Promise.resolve([]);
36423665
}
@@ -3650,14 +3673,12 @@ module.exports = (() => {
36503673
* Retrieves all-time highs and lows for specific futures contracts.
36513674
*
36523675
* @private
3653-
* @param symbols
3654-
* @param username
3655-
* @param password
3676+
* @param {String[]} symbols
36563677
* @returns {Promise<Object[]>}
36573678
*/
36583679

36593680

3660-
function retrieveFuturesHiLo(symbols, username, password) {
3681+
function retrieveFuturesHiLo(symbols) {
36613682
return Promise.resolve().then(() => {
36623683
const options = {
36633684
url: `https://instrument-extensions.aws.barchart.com/v1/futures/hilo?&symbols=${encodeURIComponent(symbols.join())}`,
@@ -3668,6 +3689,26 @@ module.exports = (() => {
36683689
});
36693690
});
36703691
}
3692+
/**
3693+
* Retrieves current and previous quote dates for cmdtyStats instruments.
3694+
*
3695+
* @private
3696+
* @param {String[]} symbols
3697+
* @returns {Promise<Object[]>}
3698+
*/
3699+
3700+
3701+
function retrieveCmdtyStatsDates(symbols) {
3702+
return Promise.resolve().then(() => {
3703+
const options = {
3704+
url: `https://instrument-extensions.aws.barchart.com/v1/cmdtyStats/quote?&symbols=${encodeURIComponent(symbols.join())}`,
3705+
method: 'GET'
3706+
};
3707+
return Promise.resolve(axios(options)).then(response => {
3708+
return response.data || [];
3709+
});
3710+
});
3711+
}
36713712
/**
36723713
* Extended quote information.
36733714
*
@@ -3676,6 +3717,7 @@ module.exports = (() => {
36763717
* @ignore
36773718
* @property {String} symbol
36783719
* @property {QuoteExtensionHiLo=} hilo
3720+
* @property {QuoteExtensionCmdtyStatus=} cmdtyStats
36793721
*/
36803722

36813723
/**
@@ -3690,6 +3732,16 @@ module.exports = (() => {
36903732
* @property {Day=} lowDate
36913733
*/
36923734

3735+
/**
3736+
* Extended quote information (for cmdtyStats instruments).
3737+
*
3738+
* @typedef QuoteExtensionCmdtyStats
3739+
* @type {Object}
3740+
* @ignore
3741+
* @property {Day=} currentDate
3742+
* @property {Day=} previousDate
3743+
*/
3744+
36933745

36943746
return retrieveExtensions;
36953747
})();
@@ -4671,9 +4723,9 @@ module.exports = (() => {
46714723
};
46724724

46734725
const _processQuoteExtension = (quote, extension) => {
4674-
if (extension.hilo) {
4675-
const hilo = extension.hilo;
4726+
const hilo = extension.hilo;
46764727

4728+
if (hilo) {
46774729
if (is.number(hilo.highPrice)) {
46784730
quote.recordHighPrice = Math.max(hilo.highPrice, is.number(quote.highPrice) ? quote.highPrice : Number.MIN_SAFE_INTEGER);
46794731
}
@@ -4682,6 +4734,18 @@ module.exports = (() => {
46824734
quote.recordLowPrice = Math.min(hilo.lowPrice, is.number(quote.lowPrice) ? quote.lowPrice : Number.MAX_SAFE_INTEGER);
46834735
}
46844736
}
4737+
4738+
const cmdtyStats = extension.cmdtyStats;
4739+
4740+
if (cmdtyStats) {
4741+
if (cmdtyStats.currentDate) {
4742+
quote.currentDate = cmdtyStats.currentDate;
4743+
}
4744+
4745+
if (cmdtyStats.previousDate) {
4746+
quote.previousDate = cmdtyStats.previousDate;
4747+
}
4748+
}
46854749
};
46864750

46874751
const _getOrCreateQuote = symbol => {
@@ -5983,7 +6047,7 @@ module.exports = (() => {
59836047
'use strict';
59846048

59856049
return {
5986-
version: '5.23.0'
6050+
version: '5.24.0'
59876051
};
59886052
})();
59896053

@@ -7991,7 +8055,7 @@ module.exports = (() => {
79918055
return is.string(symbol) && (types.cmdty.stats.test(symbol) || types.cmdty.internal.test(symbol) || types.cmdty.external.test(symbol));
79928056
}
79938057
/**
7994-
* Returns true if the symbol represents cmdtyStats symbol.
8058+
* Returns true if the symbol represents a cmdtyStats instrument.
79958059
*
79968060
* @public
79978061
* @static

lib/meta.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module.exports = (() => {
22
'use strict';
33

44
return {
5-
version: '5.23.0'
5+
version: '5.24.0'
66
};
77
})();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@barchart/marketdata-api-js",
3-
"version": "5.23.0",
3+
"version": "5.24.0",
44
"description": "SDK for streaming market data from Barchart.com",
55
"author": {
66
"name": "Eero Pikat",

test/dist/barchart-marketdata-api-tests-5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,7 @@ module.exports = (() => {
30923092
return is.string(symbol) && (types.cmdty.stats.test(symbol) || types.cmdty.internal.test(symbol) || types.cmdty.external.test(symbol));
30933093
}
30943094
/**
3095-
* Returns true if the symbol represents cmdtyStats symbol.
3095+
* Returns true if the symbol represents a cmdtyStats instrument.
30963096
*
30973097
* @public
30983098
* @static

0 commit comments

Comments
 (0)