New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@barchart/marketdata-api-js

Package Overview
Dependencies
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@barchart/marketdata-api-js - npm Package Compare versions

Comparing version 5.14.1 to 5.15.0

13

lib/connection/Connection.js

@@ -72,3 +72,3 @@ const array = require('@barchart/common-js/lang/array'),

let __processOptions = { deferDayChange: false };
let __processOptions = { };

@@ -147,8 +147,2 @@ let __watchdogToken = null;

function setDeferredDayChangeMode(mode) {
if (__processOptions.deferDayChange !== mode) {
__processOptions.deferDayChange = mode;
}
}
//

@@ -1773,3 +1767,2 @@ // Functions for connecting to and disconnecting from JERQ, monitoring

setExtendedQuoteMode: setExtendedQuoteMode,
setDeferredDayChangeMode: setDeferredDayChangeMode,
handleProfileRequest: handleProfileRequest,

@@ -1859,6 +1852,2 @@ getDiagnosticsController: getDiagnosticsController

_setDeferredDayChangeMode(mode) {
return this._internal.setDeferredDayChangeMode(mode);
}
_handleProfileRequest(symbol) {

@@ -1865,0 +1854,0 @@ this._internal.handleProfileRequest(symbol);

@@ -30,3 +30,2 @@ const is = require('@barchart/common-js/lang/is');

this._extendedQuoteMode = false;
this._deferredDayChangeMode = false;

@@ -284,34 +283,4 @@ this._instance = ++instanceCounter;

/**
* @public
* @ignore
* @param {Boolean}
*/
setDeferredDayChangeMode(mode) {
if (is.boolean(mode) && this._deferredDayChangeMode !== mode) {
this._deferredDayChangeMode = mode;
this._setDeferredDayChangeMode(this._deferredDayChangeMode);
}
}
/**
* @protected
* @ignore
*/
_setDeferredDayChangeMode(mode) {
return;
}
/**
* @public
* @ignore
* @returns {Boolean}
*/
getDeferredDayChangeMode() {
return this._deferredDayChangeMode;
}
/**
* @protected
* @ignore
* @param {String}

@@ -318,0 +287,0 @@ */

99

lib/marketState/MarketState.js

@@ -230,2 +230,28 @@ const is = require('@barchart/common-js/lang/is'),

const _derivePriceChange = (quote) => {
let currentPrice = quote.lastPrice || null;
let comparePrice = quote.previousPrice || null;
if (quote.flag === 'p' && quote.days.length > 0) {
const previousDay = quote.days[0];
currentPrice = currentPrice || previousDay.lastPrice;
comparePrice = previousDay.previousPrice || comparePrice;
}
let priceChange = null;
let priceChangePercent = null;
if (is.number(currentPrice) && is.number(comparePrice)) {
priceChange = currentPrice - comparePrice;
if (comparePrice !== 0) {
priceChangePercent = priceChange / Math.abs(comparePrice);
}
}
quote.priceChange = priceChange;
quote.priceChangePercent = priceChangePercent;
};
const _processMessage = (message, options) => {

@@ -316,35 +342,37 @@ const symbol = message.symbol;

if (dayNum > q.dayNum || q.dayNum - dayNum > 5) {
let allowRoll = true;
q.message = message;
if (options && options.deferDayChange && !(message.type === 'REFRESH_DDF' || message.type === 'TRADE' || message.type === 'OPEN')) {
allowRoll = false;
// Roll the quote
q.days.unshift({ day: q.day, previousPrice: q.previousPrice, lastPrice: q.lastPrice });
while (q.days.length > 3) {
q.days.pop();
}
if (allowRoll) {
q.message = message;
q.day = message.day;
q.dayNum = dayNum;
q.flag = 'p';
q.bidPrice = 0.0;
q.bidSize = undefined;
q.askPrice = undefined;
q.askSize = undefined;
if (q.settlementPrice) {
q.previousPrice = q.settlementPrice;
q.previousSettlementPrice = q.settlementPrice;
} else if (q.lastPrice) {
q.previousPrice = q.lastPrice;
}
// Roll the quote
q.day = message.day;
q.dayNum = dayNum;
q.flag = 'p';
q.bidPrice = 0.0;
q.bidSize = undefined;
q.askPrice = undefined;
q.askSize = undefined;
if (q.settlementPrice) {
q.previousSettlementPrice = q.settlementPrice;
q.previousPrice = q.settlementPrice;
q.settlementPrice = undefined;
} else if (q.lastPrice) {
q.previousPrice = q.lastPrice;
}
q.lastPrice = undefined;
q.tradePrice = undefined;
q.tradeSize = undefined;
q.numberOfTrades = undefined;
q.openPrice = undefined;
q.highPrice = undefined;
q.lowPrice = undefined;
q.volume = undefined;
}
q.lastPrice = undefined;
q.tradePrice = undefined;
q.tradeSize = undefined;
q.numberOfTrades = undefined;
q.openPrice = undefined;
q.highPrice = undefined;
q.lowPrice = undefined;
q.volume = undefined;
q.settlementPrice = undefined;
_derivePriceChange(q);
} else if (q.dayNum > dayNum) {

@@ -385,2 +413,3 @@ return;

_derivePriceChange(q);
_deriveRecordHighPrice(q);

@@ -469,2 +498,5 @@ _deriveRecordLowPrice(q);

}
_derivePriceChange(q);
break;

@@ -509,2 +541,3 @@ }

_derivePriceChange(q);
_deriveRecordHighPrice(q);

@@ -535,2 +568,5 @@ _deriveRecordLowPrice(q);

}
_derivePriceChange(q);
break;

@@ -553,4 +589,6 @@ case 'TOB':

q.flag = undefined;
q.tradePrice = message.tradePrice;
q.lastPrice = message.tradePrice;
if (message.tradeSize) {

@@ -562,2 +600,3 @@ q.tradeSize = message.tradeSize;

q.ticks.push({ price: q.tradePrice, size: q.tradeSize });
while (q.ticks.length > 50) {

@@ -577,2 +616,4 @@ q.ticks.shift();

_derivePriceChange(q);
if (cv && cv.container && message.tradePrice && message.tradeSize) {

@@ -579,0 +620,0 @@ cv.container.incrementVolume(message.tradePrice, message.tradeSize);

@@ -100,3 +100,3 @@ const SymbolParser = require('./../utilities/parsers/SymbolParser'),

/**
* @property {string|undefined} expiration - First notice date, formatted as YYYY-MM-DD (futures only).
* @property {string|undefined} firstNotice - First notice date, formatted as YYYY-MM-DD (futures only).
*/

@@ -108,3 +108,3 @@ this.firstNotice = null;

/**
* @property {AssetClass|null} type - The instrument type (a.k.a. asset class). This will only be present when inference based on the instrument symbol is possible.
* @property {AssetClass|null} asset - The instrument type (a.k.a. asset class). This will only be present when inference based on the instrument symbol is possible.
*/

@@ -111,0 +111,0 @@ this.asset = null;

@@ -28,3 +28,3 @@ module.exports = (() => {

/**
* @property {string} message - Most recent DDF refresh message which caused this instance to mutate.
* @property {string} refresh - Most recent DDF refresh message which caused this instance to mutate.
* @public

@@ -50,3 +50,3 @@ * @readonly

/**
* @property {string} - One of two values, "I" or "R" -- indicating delayed or realtime data, respectively.
* @property {string} mode - One of two values, "I" or "R" -- indicating delayed or realtime data, respectively.
* @public

@@ -86,3 +86,3 @@ * @readonly

/**
* @property {Date|null} time - A timezone-aware version of {@link Quote#lastUpdate}. This property will only have a value when both (a) the exchange timezone is known; and (b) the client computer's timezone is known.
* @property {Date|null} lastUpdateUtc - A timezone-aware version of {@link Quote#lastUpdate}. This property will only have a value when both (a) the exchange timezone is known; and (b) the client computer's timezone is known.
* @public

@@ -143,2 +143,3 @@ * @readonly

this.numberOfTrades = null;
this.vwap1 = null; // Exchange Provided

@@ -232,3 +233,3 @@ this.vwap2 = null; // Calculated

/**
* @property {Date|null} time - A timezone-aware version of {@link Quote#time}. This property will only have a value when both (a) the exchange timezone is known; and (b) the client computer's timezone is known.
* @property {Date|null} timeUtc - A timezone-aware version of {@link Quote#time}. This property will only have a value when both (a) the exchange timezone is known; and (b) the client computer's timezone is known.
* @public

@@ -239,2 +240,6 @@ * @readonly

this.priceChange = null;
this.priceChangePercent = null;
this.days = [];
this.ticks = [];

@@ -241,0 +246,0 @@ }

@@ -5,4 +5,4 @@ module.exports = (() => {

return {
version: '5.14.1'
version: '5.15.0'
};
})();

@@ -208,16 +208,8 @@ const xmlDom = require('xmldom');

// 2021/06/30, The "options" concept is a hack.
if (premarket && options && options.deferDayChange) {
if (premarket) {
message.previousPrice = sessions.previous.previousPrice;
//console.log(`Using option 1, previous price = ${message.previousPrice}`);
} else if (sessions.combined.previousPrice) {
message.previousPrice = sessions.combined.previousPrice;
//console.log(`Using option 2, previous price = ${message.previousPrice}`);
} else {
message.previousPrice = sessions.previous.previousPrice;
//console.log(`Using option 3, previous price = ${message.previousPrice}`);
}

@@ -224,0 +216,0 @@

{
"name": "@barchart/marketdata-api-js",
"version": "5.14.1",
"version": "5.15.0",
"description": "SDK for streaming market data from Barchart.com",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc