Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stock-info

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stock-info - npm Package Compare versions

Comparing version 1.6.2 to 2.0.0

57

dist/index.d.ts

@@ -1,4 +0,57 @@

import { Stock } from "./types";
export { Stock } from "./types";
export declare const getSingleStockInfo: (stock: string) => Promise<Stock>;
export declare const getStocksInfo: (stockList: string[]) => Promise<Stock[]>;
export interface Stock {
maxAge: number;
preMarketChangePercent: NumberWrapper;
preMarketChange: NumberWrapper;
preMarketTime: number;
preMarketPrice: NumberWrapper;
preMarketSource: string;
postMarketChange: UnknownEmptyObject;
postMarketPrice: UnknownEmptyObject;
regularMarketChangePercent: NumberWrapper;
regularMarketChange: NumberWrapper;
regularMarketTime: number;
priceHint: NumberWrapperLongFormat;
regularMarketPrice: NumberWrapper;
regularMarketDayHigh: NumberWrapper;
regularMarketDayLow: NumberWrapper;
regularMarketVolume: NumberWrapperLongFormat;
averageDailyVolume10Day: UnknownEmptyObject;
averageDailyVolume3Month: UnknownEmptyObject;
regularMarketPreviousClose: NumberWrapper;
regularMarketSource: string;
regularMarketOpen: NumberWrapper;
strikePrice: UnknownEmptyObject;
openInterest: UnknownEmptyObject;
exchange: string;
exchangeName: string;
exchangeDataDelayedBy: number;
marketState: string;
quoteType: string;
symbol: string;
underlyingSymbol: null;
shortName: string;
longName: string;
currency: string;
quoteSourceName: string;
currencySymbol: string;
fromCurrency: null;
toCurrency: null;
lastMarket: null;
volume24Hr: UnknownEmptyObject;
volumeAllCurrencies: UnknownEmptyObject;
circulatingSupply: UnknownEmptyObject;
marketCap: NumberWrapperLongFormat;
}
export interface UnknownEmptyObject {
}
export interface NumberWrapperLongFormat {
raw: number;
fmt: string;
longFmt: string;
}
export interface NumberWrapper {
raw: number;
fmt: string;
}

2

dist/index.modern.js

@@ -1,2 +0,2 @@

import r from"axios";const e=e=>new Promise((t,o)=>{if(!e)return o(Error("Stock symbol required"));if("string"!=typeof e)return o(Error("Invalid argument type. Required: string. Found: "+typeof e));const n=`https://query1.finance.yahoo.com/v7/finance/quote?symbols=${e}`,s="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+n:n;return r.get(s,{headers:{"Content-Type":"application/json"}}).then(r=>{const{data:n}=r;return n&&n.quoteResponse&&n.quoteResponse.result&&0!==n.quoteResponse.result.length?t(n.quoteResponse.result[0]):o(Error(`Error retrieving info for symbol ${e}`))}).catch(r=>o(r))}),t=r=>new Promise((t,o)=>{if(!r)return o(Error("Stock symbol list required"));if(!Array.isArray(r))return o(Error("Invalid argument type. Array required."));const n=[...r];if(!n.length||n.length<1)return Promise.resolve([]);const s=n.map(e);return t(Promise.all(s))});export{e as getSingleStockInfo,t as getStocksInfo};
import r from"axios";const e=e=>new Promise((t,o)=>{if(!e)return o(Error("Stock symbol required"));if("string"!=typeof e)return o(Error("Invalid argument type. Required: string. Found: "+typeof e));const n=`https://query1.finance.yahoo.com/v10/finance/quoteSummary/${e}?modules=price`,i="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+n:n;return r.get(i,{headers:{"Content-Type":"application/json"}}).then(r=>{var n,i,u;const{data:s}=r;if(null==s||null==(n=s.quoteSummary)||null==(i=n.result)||null==(u=i[0])||!u.price)return o(Error(`Error retrieving info for symbol ${e}`));const{price:a}=s.quoteSummary.result[0];return t(a)}).catch(o)}),t=r=>new Promise((t,o)=>{if(!r)return o(Error("Stock symbol list required"));if(!Array.isArray(r))return o(Error("Invalid argument type. Array required."));const n=[...r];if(!n.length||n.length<1)return Promise.resolve([]);const i=n.map(e);return t(Promise.all(i))});export{e as getSingleStockInfo,t as getStocksInfo};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

import r from"axios";var e=function(e){return new Promise(function(t,n){if(!e)return n(Error("Stock symbol required"));if("string"!=typeof e)return n(Error("Invalid argument type. Required: string. Found: "+typeof e));var o="https://query1.finance.yahoo.com/v7/finance/quote?symbols="+e,i="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+o:o;return r.get(i,{headers:{"Content-Type":"application/json"}}).then(function(r){var o=r.data;return o&&o.quoteResponse&&o.quoteResponse.result&&0!==o.quoteResponse.result.length?t(o.quoteResponse.result[0]):n(Error("Error retrieving info for symbol "+e))}).catch(function(r){return n(r)})})},t=function(r){return new Promise(function(t,n){if(!r)return n(Error("Stock symbol list required"));if(!Array.isArray(r))return n(Error("Invalid argument type. Array required."));var o=[].concat(r);if(!o.length||o.length<1)return Promise.resolve([]);var i=o.map(e);return t(Promise.all(i))})};export{e as getSingleStockInfo,t as getStocksInfo};
import r from"axios";var e=function(e){return new Promise(function(n,t){if(!e)return t(Error("Stock symbol required"));if("string"!=typeof e)return t(Error("Invalid argument type. Required: string. Found: "+typeof e));var o="https://query1.finance.yahoo.com/v10/finance/quoteSummary/"+e+"?modules=price",i="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+o:o;return r.get(i,{headers:{"Content-Type":"application/json"}}).then(function(r){var o,i,u,a=r.data;return null!=a&&null!=(o=a.quoteSummary)&&null!=(i=o.result)&&null!=(u=i[0])&&u.price?n(a.quoteSummary.result[0].price):t(Error("Error retrieving info for symbol "+e))}).catch(t)})},n=function(r){return new Promise(function(n,t){if(!r)return t(Error("Stock symbol list required"));if(!Array.isArray(r))return t(Error("Invalid argument type. Array required."));var o=[].concat(r);if(!o.length||o.length<1)return Promise.resolve([]);var i=o.map(e);return n(Promise.all(i))})};export{e as getSingleStockInfo,n as getStocksInfo};
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],r):r((e||self).stockInfo={},e.axios)}(this,function(e,r){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(r),o=function(e){return new Promise(function(r,t){if(!e)return t(Error("Stock symbol required"));if("string"!=typeof e)return t(Error("Invalid argument type. Required: string. Found: "+typeof e));var o="https://query1.finance.yahoo.com/v7/finance/quote?symbols="+e,i="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+o:o;return n.default.get(i,{headers:{"Content-Type":"application/json"}}).then(function(n){var o=n.data;return o&&o.quoteResponse&&o.quoteResponse.result&&0!==o.quoteResponse.result.length?r(o.quoteResponse.result[0]):t(Error("Error retrieving info for symbol "+e))}).catch(function(e){return t(e)})})};e.getSingleStockInfo=o,e.getStocksInfo=function(e){return new Promise(function(r,t){if(!e)return t(Error("Stock symbol list required"));if(!Array.isArray(e))return t(Error("Invalid argument type. Array required."));var n=[].concat(e);if(!n.length||n.length<1)return Promise.resolve([]);var i=n.map(o);return r(Promise.all(i))})}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],r):r((e||self).stockInfo={},e.axios)}(this,function(e,r){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(r),o=function(e){return new Promise(function(r,t){if(!e)return t(Error("Stock symbol required"));if("string"!=typeof e)return t(Error("Invalid argument type. Required: string. Found: "+typeof e));var o="https://query1.finance.yahoo.com/v10/finance/quoteSummary/"+e+"?modules=price",i="undefined"!=typeof window?"https://thingproxy.freeboard.io/fetch/"+o:o;return n.default.get(i,{headers:{"Content-Type":"application/json"}}).then(function(n){var o,i,u,f=n.data;return null!=f&&null!=(o=f.quoteSummary)&&null!=(i=o.result)&&null!=(u=i[0])&&u.price?r(f.quoteSummary.result[0].price):t(Error("Error retrieving info for symbol "+e))}).catch(t)})};e.getSingleStockInfo=o,e.getStocksInfo=function(e){return new Promise(function(r,t){if(!e)return t(Error("Stock symbol list required"));if(!Array.isArray(e))return t(Error("Invalid argument type. Array required."));var n=[].concat(e);if(!n.length||n.length<1)return Promise.resolve([]);var i=n.map(o);return r(Promise.all(i))})}});
//# sourceMappingURL=index.umd.js.map
{
"name": "stock-info",
"type": "module",
"version": "1.6.2",
"version": "2.0.0",
"description": "Module to retrieve stock information from Yahoo Finance API",

@@ -15,3 +15,4 @@ "files": [

"dev": "microbundle watch",
"prepare": "npm run build"
"prepare": "npm run build",
"release": "standard-version"
},

@@ -38,3 +39,4 @@ "keywords": [

"mocha": "^9.1.3",
"prettier": "^2.4.1"
"prettier": "^2.4.1",
"standard-version": "^9.5.0"
},

@@ -41,0 +43,0 @@ "dependencies": {

@@ -10,3 +10,3 @@ # stock-info

```shell
$ npm install --save stock-info
npm install --save stock-info
```

@@ -67,134 +67,57 @@

The **stock** object has the following shape:
The **stock** object has the following interface:
```
language: string;
region: string;
quoteType: string;
quoteSourceName: string;
triggerable: boolean;
currency: string;
sourceInterval: number;
exchangeDataDelayedBy: number;
postMarketChangePercent: number;
postMarketTime: number;
postMarketPrice: number;
postMarketChange: number;
regularMarketChange: number;
regularMarketChangePercent: number;
regularMarketTime: number;
sharesOutstanding: number;
bookValue: number;
fiftyDayAverage: number;
fiftyDayAverageChange: number;
fiftyDayAverageChangePercent: number;
twoHundredDayAverage: number;
twoHundredDayAverageChange: number;
twoHundredDayAverageChangePercent: number;
marketCap: number;
forwardPE: number;
priceToBook: number;
tradeable: boolean;
priceHint: number;
firstTradeDateMilliseconds: number;
regularMarketPrice: number;
regularMarketDayHigh: number;
regularMarketDayRange: string;
regularMarketDayLow: number;
regularMarketVolume: number;
regularMarketPreviousClose: number;
bid: number;
ask: number;
bidSize: number;
askSize: number;
fullExchangeName: string;
financialCurrency: string;
regularMarketOpen: number;
averageDailyVolume3Month: number;
averageDailyVolume10Day: number;
fiftyTwoWeekLowChange: number;
fiftyTwoWeekLowChangePercent: number;
fiftyTwoWeekRange: string;
fiftyTwoWeekHighChange: number;
fiftyTwoWeekHighChangePercent: number;
fiftyTwoWeekLow: number;
fiftyTwoWeekHigh: number;
trailingPE: number;
epsTrailingTwelveMonths: number;
epsForward: number;
exchange: string;
shortName: string;
longName: string;
messageBoardId: string;
exchangeTimezoneName: string;
exchangeTimezoneShortName: string;
gmtOffSetMilliseconds: number;
market: string;
esgPopulated: boolean;
marketState: string;
displayName: string;
symbol: string;
```
```ts
interface Stock {
maxAge: number;
preMarketChangePercent: NumberWrapper;
preMarketChange: NumberWrapper;
preMarketTime: number;
preMarketPrice: NumberWrapper;
preMarketSource: string;
postMarketChange: UnknownEmptyObject;
postMarketPrice: UnknownEmptyObject;
regularMarketChangePercent: NumberWrapper;
regularMarketChange: NumberWrapper;
regularMarketTime: number;
priceHint: NumberWrapperLongFormat;
regularMarketPrice: NumberWrapper;
regularMarketDayHigh: NumberWrapper;
regularMarketDayLow: NumberWrapper;
regularMarketVolume: NumberWrapperLongFormat;
averageDailyVolume10Day: UnknownEmptyObject;
averageDailyVolume3Month: UnknownEmptyObject;
regularMarketPreviousClose: NumberWrapper;
regularMarketSource: string;
regularMarketOpen: NumberWrapper;
strikePrice: UnknownEmptyObject;
openInterest: UnknownEmptyObject;
exchange: string;
exchangeName: string;
exchangeDataDelayedBy: number;
marketState: string;
quoteType: string;
symbol: string;
underlyingSymbol: null;
shortName: string;
longName: string;
currency: string;
quoteSourceName: string;
currencySymbol: string;
fromCurrency: null;
toCurrency: null;
lastMarket: null;
volume24Hr: UnknownEmptyObject;
volumeAllCurrencies: UnknownEmptyObject;
circulatingSupply: UnknownEmptyObject;
marketCap: NumberWrapperLongFormat;
}
Example:
interface UnknownEmptyObject {}
interface NumberWrapperLongFormat {
raw: number;
fmt: string;
longFmt: string;
}
```
regularMarketPrice: 1065.545,
symbol: 'GOOG'
longName: 'Alphabet Inc.',
language: 'en-US',
quoteType: 'EQUITY',
quoteSourceName: 'Nasdaq Real Time Price',
currency: 'USD',
regularMarketTime: 1527603620,
regularMarketChange: -10.11499,
regularMarketOpen: 1064.89,
regularMarketDayHigh: 1072.99,
regularMarketDayLow: 1065,
regularMarketVolume: 322473,
trailingPE: 59.210102,
epsTrailingTwelveMonths: 17.996,
epsForward: 47.32,
market: 'us_market',
bidSize: 8,
askSize: 13,
messageBoardId: 'finmb_29096',
fullExchangeName: 'NasdaqGS',
financialCurrency: 'USD',
sharesOutstanding: 348952000,
bookValue: 219.496,
fiftyDayAverage: 1056.5917,
fiftyDayAverageChange: 8.953369,
fiftyDayAverageChangePercent: 0.008473821,
twoHundredDayAverage: 1071.8778,
twoHundredDayAverageChange: -6.3327637,
twoHundredDayAverageChangePercent: -0.0059081023,
marketCap: 741920931840,
forwardPE: 22.517859,
priceToBook: 4.854508,
sourceInterval: 15,
exchangeTimezoneName: 'America/New_York',
exchangeTimezoneShortName: 'EDT',
gmtOffSetMilliseconds: -14400000,
exchangeDataDelayedBy: 0,
marketState: 'REGULAR',
exchange: 'NMS',
priceHint: 2,
**shortName**: 'Alphabet Inc.',
regularMarketChangePercent: -0.94035196,
regularMarketDayRange: '1065.0 - 1072.99',
regularMarketPreviousClose: 1075.66,
bid: 1068.35,
ask: 1069,
averageDailyVolume3Month: 1849285,
averageDailyVolume10Day: 957300,
fiftyTwoWeekLowChange: 170.75507,
fiftyTwoWeekLowChangePercent: 0.19083257,
fiftyTwoWeekRange: '894.79 - 1186.89',
fiftyTwoWeekHighChange: -121.34497,
fiftyTwoWeekHighChangePercent: -0.10223775,
fiftyTwoWeekLow: 894.79,
fiftyTwoWeekHigh: 1186.89,
esgPopulated: false,
tradeable: true,
```

@@ -1,4 +0,1 @@

import { Stock } from "./types";
export { Stock } from "./types";
import axios from "axios";

@@ -17,3 +14,3 @@

const url = `https://query1.finance.yahoo.com/v7/finance/quote?symbols=${stock}`;
const url = `https://query1.finance.yahoo.com/v10/finance/quoteSummary/${stock}?modules=price`;
const proxy = "https://thingproxy.freeboard.io/fetch/";

@@ -31,13 +28,9 @@

const { data } = res;
if (
!data ||
!data.quoteResponse ||
!data.quoteResponse.result ||
data.quoteResponse.result.length === 0
) {
if (!data?.quoteSummary?.result?.[0]?.price) {
return reject(Error(`Error retrieving info for symbol ${stock}`));
}
return resolve(data.quoteResponse.result[0]);
const { price } = data.quoteSummary.result[0] as { price: Stock };
return resolve(price);
})
.catch((err) => reject(err));
.catch(reject);
});

@@ -62,1 +55,59 @@

});
export interface Stock {
maxAge: number;
preMarketChangePercent: NumberWrapper;
preMarketChange: NumberWrapper;
preMarketTime: number;
preMarketPrice: NumberWrapper;
preMarketSource: string;
postMarketChange: UnknownEmptyObject;
postMarketPrice: UnknownEmptyObject;
regularMarketChangePercent: NumberWrapper;
regularMarketChange: NumberWrapper;
regularMarketTime: number;
priceHint: NumberWrapperLongFormat;
regularMarketPrice: NumberWrapper;
regularMarketDayHigh: NumberWrapper;
regularMarketDayLow: NumberWrapper;
regularMarketVolume: NumberWrapperLongFormat;
averageDailyVolume10Day: UnknownEmptyObject;
averageDailyVolume3Month: UnknownEmptyObject;
regularMarketPreviousClose: NumberWrapper;
regularMarketSource: string;
regularMarketOpen: NumberWrapper;
strikePrice: UnknownEmptyObject;
openInterest: UnknownEmptyObject;
exchange: string;
exchangeName: string;
exchangeDataDelayedBy: number;
marketState: string;
quoteType: string;
symbol: string;
underlyingSymbol: null;
shortName: string;
longName: string;
currency: string;
quoteSourceName: string;
currencySymbol: string;
fromCurrency: null;
toCurrency: null;
lastMarket: null;
volume24Hr: UnknownEmptyObject;
volumeAllCurrencies: UnknownEmptyObject;
circulatingSupply: UnknownEmptyObject;
marketCap: NumberWrapperLongFormat;
}
export interface UnknownEmptyObject {}
export interface NumberWrapperLongFormat {
raw: number;
fmt: string;
longFmt: string;
}
export interface NumberWrapper {
raw: number;
fmt: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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