stock-info
Advanced tools
Comparing version 1.1.0 to 1.2.0
18
index.js
@@ -6,6 +6,6 @@ const axios = require('axios'); | ||
if (!stock) { | ||
return reject(new Error('Stock symbol required')); | ||
return reject(Error('Stock symbol required')); | ||
} | ||
if (typeof stock !== 'string') { | ||
return reject(new Error(`Invalid argument type. Required: string. Found: ${typeof stock}`)); | ||
return reject(Error(`Invalid argument type. Required: string. Found: ${typeof stock}`)); | ||
} | ||
@@ -32,9 +32,10 @@ | ||
const getStocksInfo = (stockList) => { | ||
const getStocksInfo = stockList => new Promise((resolve, reject) => { | ||
if (!stockList) { | ||
return new Error('Stock symbol list required'); | ||
return reject(Error('Stock symbol list required')); | ||
} | ||
if (typeof stockList !== 'object') { | ||
return new Error('Invalid argument type. Array required.'); | ||
if (!Array.isArray(stockList)) { | ||
return reject(Error('Invalid argument type. Array required.')); | ||
} | ||
const list = [...stockList]; | ||
@@ -44,5 +45,6 @@ if (!list.length || list.length < 1) { | ||
} | ||
const promises = list.map(getSingleStockInfo); | ||
return Promise.all(promises); | ||
}; | ||
return resolve(Promise.all(promises)); | ||
}); | ||
@@ -49,0 +51,0 @@ module.exports = { |
{ | ||
"name": "stock-info", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Node.js module to retrieve stock information from Yahoo Finance API", | ||
@@ -18,15 +18,15 @@ "main": "index.js", | ||
"name": "Luiz Chagas", | ||
"email": "luizchagasjr@gmail.com", | ||
"url": "https://luizjr.me/" | ||
"email": "luiz@luizchagas.com", | ||
"url": "https://luizchagas.com/" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"mocha": "^5.2.0" | ||
"eslint": "^7.0.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"mocha": "^7.2.0" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.18.0" | ||
"axios": "^0.18.1" | ||
} | ||
} |
@@ -6,4 +6,2 @@ # stock-info | ||
[TOC] | ||
## Installation | ||
@@ -27,3 +25,3 @@ | ||
const si = require('stock-info'); | ||
si.getSingleStockInfo('GOOG').then(stock => console.log); | ||
si.getSingleStockInfo('GOOG').then(console.log); | ||
//Outputs the result | ||
@@ -42,3 +40,3 @@ ``` | ||
const stocks = ['AMZN', 'NFLIX']; | ||
si.getStocksInfo(stocks).then(stocks => console.log); | ||
si.getStocksInfo(stocks).then(console.log); | ||
//Outputs the result | ||
@@ -51,3 +49,77 @@ ``` | ||
``` | ||
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; | ||
``` | ||
Example: | ||
``` | ||
regularMarketPrice: 1065.545, | ||
symbol: 'GOOG' | ||
longName: 'Alphabet Inc.', | ||
language: 'en-US', | ||
@@ -57,3 +129,2 @@ quoteType: 'EQUITY', | ||
currency: 'USD', | ||
**regularMarketPrice**: 1065.545, | ||
regularMarketTime: 1527603620, | ||
@@ -73,3 +144,2 @@ regularMarketChange: -10.11499, | ||
fullExchangeName: 'NasdaqGS', | ||
**longName**: 'Alphabet Inc.', | ||
financialCurrency: 'USD', | ||
@@ -112,2 +182,2 @@ sharesOutstanding: 348952000, | ||
tradeable: true, | ||
**symbol**: 'GOOG' | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10321
7
140
176
Updatedaxios@^0.18.1