@barchart/marketdata-api-js
Advanced tools
Comparing version 5.19.1 to 5.20.0
@@ -36,5 +36,5 @@ const axios = require('axios'); | ||
return Promise.all([ | ||
retrieveExtensionsFromExtras(symbols.filter(SymbolParser.getIsFuture)), | ||
retrieveExtensionsFromOnDemand(symbols.filter(SymbolParser.getIsC3), username, password), | ||
retrieveExtensionsFromFundamentals(symbols.filter(SymbolParser.getIsCmdtyStats)) | ||
retrieveExtensionsForC3(symbols.filter(SymbolParser.getIsC3)), | ||
retrieveExtensionsForCmdtyStats(symbols.filter(SymbolParser.getIsCmdtyStats)), | ||
retrieveExtensionsForFutures(symbols.filter(SymbolParser.getIsFuture)) | ||
]).then((results) => { | ||
@@ -46,3 +46,3 @@ return array.flatten(results); | ||
function retrieveExtensionsFromExtras(symbols) { | ||
function retrieveExtensionsForFutures(symbols) { | ||
return Promise.resolve() | ||
@@ -92,3 +92,3 @@ .then(() => { | ||
function retrieveExtensionsFromFundamentals(symbols) { | ||
function retrieveExtensionsForCmdtyStats(symbols) { | ||
return Promise.resolve() | ||
@@ -127,3 +127,3 @@ .then(() => { | ||
function retrieveExtensionsFromOnDemand(symbols, username, password) { | ||
function retrieveExtensionsForC3(symbols) { | ||
return Promise.resolve() | ||
@@ -136,3 +136,3 @@ .then(() => { | ||
const options = { | ||
url: `https://webapp-proxy.aws.barchart.com/v1/proxies/ondemand/getQuote.json?username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}&symbols=${encodeURIComponent(symbols.join())}`, | ||
url: `https://instrument-extensions.aws.barchart.com/v1/c3/meta?symbols=${encodeURIComponent(symbols.join())}`, | ||
method: 'GET' | ||
@@ -143,3 +143,3 @@ }; | ||
.then((response) => { | ||
const results = response.data.results || []; | ||
const results = response.data || []; | ||
@@ -152,16 +152,53 @@ return results.reduce((accumulator, result) => { | ||
if (SymbolParser.getIsC3(extension.symbol)) { | ||
if (SymbolParser.getIsC3(extension.symbol) && is.object(result.meta)) { | ||
const c3 = { }; | ||
c3.area = null; | ||
c3.basis = null; | ||
c3.currency = null; | ||
c3.delivery = null; | ||
c3.description = null; | ||
c3.lot = null; | ||
c3.market = null; | ||
c3.product = null; | ||
c3.terms = null; | ||
if (result.commodityDataCurrency) { | ||
c3.currency = getC3Currency(result.commodityDataCurrency); | ||
const meta = result.meta; | ||
if (meta.area) { | ||
c3.area = meta.area; | ||
} | ||
if (result.commodityDataDelivery) { | ||
c3.delivery = result.commodityDataDelivery; | ||
if (meta.basis) { | ||
c3.basis = meta.basis; | ||
} | ||
if (meta.lot) { | ||
c3.currency = getC3Currency(meta.lot); | ||
} | ||
if (meta.delivery) { | ||
c3.delivery = meta.delivery; | ||
} | ||
if (meta.description) { | ||
c3.description = meta.description; | ||
} | ||
if (meta.lot) { | ||
c3.lot = meta.lot; | ||
} | ||
if (meta.market) { | ||
c3.market = meta.market; | ||
} | ||
if (meta.product) { | ||
c3.product = meta.product; | ||
} | ||
if (meta.terms) { | ||
c3.terms = meta.terms; | ||
} | ||
extension.c3 = c3; | ||
@@ -172,3 +209,3 @@ } | ||
} catch (e) { | ||
logger.warn(`Snapshot: Failed to process symbol [ ${JSON.stringify(result)} ]`); | ||
logger.warn(`Extensions: Failed to process extension [ ${symbols.join()} ]`); | ||
} | ||
@@ -175,0 +212,0 @@ |
@@ -197,3 +197,3 @@ const axios = require('axios'); | ||
} catch (e) { | ||
logger.warn(`Snapshot: Failed to process symbol`); | ||
logger.warn(`Snapshot: Failed to process snapshot [ ${symbols.join()} ]`); | ||
} | ||
@@ -200,0 +200,0 @@ |
@@ -137,3 +137,3 @@ const SymbolParser = require('./../utilities/parsers/SymbolParser'), | ||
/** | ||
* Given a price, returns a the human-readable string representation. | ||
* Given a price, returns the human-readable representation. | ||
* | ||
@@ -140,0 +140,0 @@ * @public |
@@ -5,4 +5,4 @@ module.exports = (() => { | ||
return { | ||
version: '5.19.1' | ||
version: '5.20.0' | ||
}; | ||
})(); |
{ | ||
"name": "@barchart/marketdata-api-js", | ||
"version": "5.19.1", | ||
"version": "5.20.0", | ||
"description": "SDK for streaming market data from Barchart.com", | ||
@@ -5,0 +5,0 @@ "author": { |
250877
7940