@barchart/marketdata-api-js
Advanced tools
Comparing version 3.1.39 to 3.1.40
{ | ||
"name": "barchart-marketdata-api", | ||
"version": "3.1.39", | ||
"version": "3.1.40", | ||
"homepage": "https://github.com/barchart/marketdata-api-js", | ||
@@ -5,0 +5,0 @@ "description": "Barchart Market Data API for JavaScript", |
@@ -42,2 +42,10 @@ const utilities = require('@barchart/marketdata-utilities-js'); | ||
const eventTypes = { | ||
events: { requiresSymbol: false }, | ||
marketDepth: { requiresSymbol: true }, | ||
marketUpdate: { requiresSymbol: true }, | ||
cumulativeVolume: { requiresSymbol: true }, | ||
timestamp: { requiresSymbol: false } | ||
}; | ||
const _RECONNECT_INTERVAL = 5000; | ||
@@ -367,8 +375,23 @@ const _WATCHDOG_INTERVAL = 10000; | ||
if (symbol) { | ||
if (!eventTypes.hasOwnProperty(eventType)) { | ||
console.log('Consumer: Unable to process "on" event, event type is not recognized.'); | ||
return; | ||
} | ||
const eventData = eventTypes[eventType]; | ||
if (eventData.requiresSymbol) { | ||
if (typeof(symbol) !== 'string') { | ||
throw new Error('If provided, the "symbol" argument must be a string.'); | ||
throw new Error(`The "symbol" argument must be a string for [ ${eventType} ] events.`); | ||
} | ||
symbol = symbol.toUpperCase(); | ||
symbol = symbol.toUpperCase().trim(); | ||
if (!symbol) { | ||
console.log('Consumer: Unable to process "on" command, the "symbol" argument is empty.'); | ||
console.trace(); | ||
return; | ||
} | ||
} | ||
@@ -417,6 +440,2 @@ | ||
case 'marketDepth': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "marketDepth" event'); | ||
} | ||
subscribe('MD_GO', 'MD_REFRESH', __listeners.marketDepth, []); | ||
@@ -430,6 +449,2 @@ | ||
case 'marketUpdate': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "marketUpdate" event'); | ||
} | ||
subscribe('MU_GO', 'MU_REFRESH', __listeners.marketUpdate, [__listeners.cumulativeVolume]); | ||
@@ -443,6 +458,2 @@ | ||
case 'cumulativeVolume': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "cumulativeVolume" event'); | ||
} | ||
subscribe('MU_GO', 'MU_REFRESH', __listeners.cumulativeVolume, [__listeners.marketUpdate]); | ||
@@ -480,8 +491,24 @@ | ||
if (symbol) { | ||
if (!eventTypes.hasOwnProperty(eventType)) { | ||
console.log(`Consumer: Unable to process "off" command, event type is not supported [ ${eventType} ].`); | ||
console.trace(); | ||
return; | ||
} | ||
const eventData = eventTypes[eventType]; | ||
if (eventData.requiresSymbol) { | ||
if (typeof(symbol) !== 'string') { | ||
throw new Error('If provided, the "symbol" argument must be a string.'); | ||
throw new Error(`The "symbol" argument must be a string for [ ${eventType} ] events.`); | ||
} | ||
symbol = symbol.toUpperCase(); | ||
symbol = symbol.toUpperCase().trim(); | ||
if (!symbol) { | ||
console.log('Consumer: Unable to process "off" command, the "symbol" argument is empty.'); | ||
console.trace(); | ||
return; | ||
} | ||
} | ||
@@ -525,6 +552,2 @@ | ||
case 'marketDepth': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "marketDepth" event'); | ||
} | ||
unsubscribe('MD_STOP', __listeners.marketDepth, []); | ||
@@ -534,6 +557,2 @@ | ||
case 'marketUpdate': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "marketUpdate" event'); | ||
} | ||
unsubscribe('MU_STOP', __listeners.marketUpdate, [__listeners.cumulativeVolume]); | ||
@@ -543,6 +562,2 @@ | ||
case 'cumulativeVolume': | ||
if (!symbol) { | ||
throw new Error('The "symbol" argument is required when using the "marketUpdate" event'); | ||
} | ||
unsubscribe('MU_STOP', __listeners.cumulativeVolume, [__listeners.marketUpdate]); | ||
@@ -572,4 +587,13 @@ | ||
} | ||
const consumerSymbol = symbol; | ||
const consumerSymbol = symbol.toUpperCase().trim(); | ||
if (!consumerSymbol) { | ||
console.log('Consumer: Unable to process profile request, the "symbol" argument is empty.'); | ||
console.trace(); | ||
return; | ||
} | ||
const producerSymbol = utilities.symbolParser.getProducerSymbol(consumerSymbol); | ||
@@ -1174,3 +1198,3 @@ | ||
}).catch((e) => { | ||
console.log('Snapshots: Out-of-band snapshot request failed', e); | ||
console.log('Snapshots: Out-of-band snapshot request failed.', e); | ||
}); | ||
@@ -1177,0 +1201,0 @@ } |
@@ -20,4 +20,4 @@ const connection = require('./connection/index'), | ||
version: '3.1.39' | ||
version: '3.1.40' | ||
}; | ||
})(); |
{ | ||
"name": "@barchart/marketdata-api-js", | ||
"version": "3.1.39", | ||
"version": "3.1.40", | ||
"description": "Barchart client library for streaming market data from JERQ servers using JavaScript", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
502909
14723