@barchart/marketdata-api-js
Advanced tools
Comparing version 5.16.4 to 5.17.0
@@ -831,3 +831,3 @@ const array = require('@barchart/common-js/lang/array'), | ||
if (lines.some(line => line == '+++')) { | ||
if (lines.some(line => line === '+++')) { | ||
__connectionState = state.authenticating; | ||
@@ -1077,3 +1077,3 @@ | ||
if (msgType == 1) { | ||
if (msgType === 1) { | ||
if (s.length < idx + suffixLength + 1) { | ||
@@ -1088,3 +1088,3 @@ if (__marketMessages.length > 0) | ||
skip = true; | ||
} else if (s.substr(idx + 1, 1) == ascii.dc4) { | ||
} else if (s.substr(idx + 1, 1) === ascii.dc4) { | ||
epos += suffixLength + 1; | ||
@@ -1096,3 +1096,3 @@ } | ||
let s2 = s.substring(0, epos); | ||
if (msgType == 2) { | ||
if (msgType === 2) { | ||
s2 = s2.trim(); | ||
@@ -1099,0 +1099,0 @@ } else { |
@@ -274,3 +274,3 @@ const is = require('@barchart/common-js/lang/is'), | ||
if (message.type == 'REFRESH_CUMULATIVE_VOLUME') { | ||
if (message.type === 'REFRESH_CUMULATIVE_VOLUME') { | ||
let cv = _getOrCreateCumulativeVolume(symbol); | ||
@@ -421,2 +421,32 @@ let container = cv.container; | ||
break; | ||
case 'OHLC': | ||
q.message = message; | ||
q.flag = undefined; | ||
if (is.number(message.openPrice)) { | ||
q.openPrice = message.openPrice; | ||
} | ||
if (is.number(message.highPrice)) { | ||
q.highPrice = message.highPrice; | ||
} | ||
if (is.number(message.lowPrice)) { | ||
q.lowPrice = message.lowPrice; | ||
} | ||
if (is.number(message.lastPrice)) { | ||
q.lastPrice = message.lastPrice; | ||
} | ||
if (is.number(message.volume)) { | ||
q.volume = message.volume; | ||
} | ||
_derivePriceChange(q); | ||
_deriveRecordHighPrice(q); | ||
_deriveRecordLowPrice(q); | ||
break; | ||
case 'OPEN_INTEREST': | ||
@@ -477,3 +507,3 @@ q.message = message; | ||
q.settlementPrice = undefined; | ||
if (q.flag == 's') { | ||
if (q.flag === 's') { | ||
q.flag = undefined; | ||
@@ -494,3 +524,3 @@ } | ||
} | ||
if (message.subrecord == '1') { | ||
if (message.subrecord === '1') { | ||
q.lastUpdate = message.time; | ||
@@ -497,0 +527,0 @@ q.lastUpdateUtc = _getUtcTimestamp(symbol, message.time); |
@@ -5,4 +5,4 @@ module.exports = (() => { | ||
return { | ||
version: '5.16.4' | ||
version: '5.17.0' | ||
}; | ||
})(); |
@@ -27,3 +27,3 @@ const is = require('@barchart/common-js/lang/is'); | ||
return String.fromCharCode(ASCII_ONE + d - 1); | ||
} else if (d == 10) { | ||
} else if (d === 10) { | ||
return '0'; | ||
@@ -30,0 +30,0 @@ } else { |
@@ -152,3 +152,3 @@ const xmlDom = require('@xmldom/xmldom'); | ||
for (let j = 0; j < node.childNodes.length; j++) { | ||
if (node.childNodes[j].nodeName == 'SESSION') { | ||
if (node.childNodes[j].nodeName === 'SESSION') { | ||
const s = {}; | ||
@@ -375,2 +375,3 @@ const attributes = node.childNodes[j].attributes; | ||
message.timestamp = new Date(parseInt(msg.substr(2, 4)), parseInt(msg.substr(6, 2)) - 1, parseInt(msg.substr(8, 2)), parseInt(msg.substr(10, 2)), parseInt(msg.substr(12, 2)), parseInt(msg.substr(14, 2))); | ||
break; | ||
@@ -381,2 +382,3 @@ } | ||
message.record = '2'; | ||
let pos = msg.indexOf(',', 0); | ||
@@ -388,2 +390,3 @@ message.symbol = msg.substring(2, pos); | ||
message.delay = parseInt(msg.substr(pos + 5, 2)); | ||
switch (message.subrecord) { | ||
@@ -402,3 +405,3 @@ case '0': { | ||
case 'C': | ||
if (message.modifier == '1') | ||
if (message.modifier === '1') | ||
message.type = 'OPEN_INTEREST'; | ||
@@ -408,11 +411,11 @@ break; | ||
case 'd': | ||
if (message.modifier == '0') | ||
if (message.modifier === '0') | ||
message.type = 'SETTLEMENT'; | ||
break; | ||
case 'V': | ||
if (message.modifier == '0') | ||
if (message.modifier === '0') | ||
message.type = 'VWAP'; | ||
break; | ||
case '0': { | ||
if (message.modifier == '0') { | ||
if (message.modifier === '0') { | ||
message.tradePrice = message.value; | ||
@@ -430,5 +433,5 @@ message.type = 'TRADE'; | ||
case '7': { | ||
if (message.modifier == '1') | ||
if (message.modifier === '1') | ||
message.type = 'VOLUME_YESTERDAY'; | ||
else if (message.modifier == '6') | ||
else if (message.modifier === '6') | ||
message.type = 'VOLUME'; | ||
@@ -442,2 +445,3 @@ break; | ||
message.time = parseTimestamp(msg.substr(msg.indexOf('\x03') + 1, 9)); | ||
break; | ||
@@ -450,2 +454,3 @@ } | ||
const ary = msg.substring(pos + 8).split(','); | ||
message.openPrice = parseValue(ary[0], message.unitcode); | ||
@@ -463,6 +468,28 @@ message.highPrice = parseValue(ary[1], message.unitcode); | ||
message.session = ary[14].substr(1, 1); | ||
message.time = parseTimestamp(msg.substr(msg.indexOf('\x03') + 1, 9)); | ||
message.type = 'REFRESH_DDF'; | ||
break; | ||
} | ||
case '6': { | ||
if (msg.substr(1, 1) === '2') { | ||
const ary = msg.substring(pos + 8).split(','); | ||
message.openPrice = parseValue(ary[0], message.unitcode); | ||
message.highPrice = parseValue(ary[1], message.unitcode); | ||
message.lowPrice = parseValue(ary[2], message.unitcode); | ||
message.lastPrice = parseValue(ary[3], message.unitcode); | ||
message.volume = (ary[13].length > 0) ? parseInt(ary[13]) : undefined; | ||
message.day = ary[14].substr(0, 1); | ||
message.session = ary[14].substr(1, 1); | ||
message.type = 'OHLC'; | ||
} | ||
break; | ||
} | ||
case '7': { | ||
@@ -480,2 +507,3 @@ let pos2 = msg.indexOf(',', pos + 7); | ||
message.type = 'TRADE'; | ||
break; | ||
@@ -514,5 +542,7 @@ } | ||
message.type = 'TRADE_OUT_OF_SEQUENCE'; | ||
break; | ||
} | ||
} | ||
break; | ||
@@ -524,2 +554,3 @@ } | ||
message.subrecord = msg.substr(pos + 1, 1); | ||
switch (message.subrecord) { | ||
@@ -529,4 +560,4 @@ case 'B': { | ||
message.exchange = msg.substr(pos + 4, 1); | ||
message.bidDepth = ((msg.substr(pos + 5, 1) == 'A') ? 10 : parseInt(msg.substr(pos + 5, 1))); | ||
message.askDepth = ((msg.substr(pos + 6, 1) == 'A') ? 10 : parseInt(msg.substr(pos + 6, 1))); | ||
message.bidDepth = ((msg.substr(pos + 5, 1) === 'A') ? 10 : parseInt(msg.substr(pos + 5, 1))); | ||
message.askDepth = ((msg.substr(pos + 6, 1) === 'A') ? 10 : parseInt(msg.substr(pos + 6, 1))); | ||
message.bids = []; | ||
@@ -551,2 +582,3 @@ message.asks = []; | ||
message.type = 'BOOK'; | ||
break; | ||
@@ -553,0 +585,0 @@ } |
@@ -39,3 +39,3 @@ module.exports = (() => { | ||
const sign = (str.substr(0, 1) == '-') ? -1 : 1; | ||
const sign = (str.substr(0, 1) === '-') ? -1 : 1; | ||
@@ -42,0 +42,0 @@ if (sign === -1) { |
{ | ||
"name": "@barchart/marketdata-api-js", | ||
"version": "5.16.4", | ||
"version": "5.17.0", | ||
"description": "SDK for streaming market data from Barchart.com", | ||
@@ -62,3 +62,3 @@ "author": { | ||
"jshint": "^2.10.3", | ||
"log4js": "^4.4.0", | ||
"log4js": "^6.4.1", | ||
"merge-stream": "^2.0.0", | ||
@@ -65,0 +65,0 @@ "uuid": "^8.3.2", |
249380
7874