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

alphavantage

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alphavantage - npm Package Compare versions

Comparing version 1.2.6 to 2.0.0

__mocks__/cross-fetch.js

97

CHANGELOG.md
0.0.1
- Initial release
- Initial release
0.0.2
- Adding initial tests
- Adding initial tests
0.0.3
- Updating documentation
- Fixing code linting
- Updating documentation
- Fixing code linting
0.0.4
- Adding sector performance api
- Adding sector performance api
0.0.5
- Adding env variable support
- Adding output restructuring utils with tests
- Adding CHANGELOG.md and backfilling releases
- Adding utils to the core export
- Adding missing tests
- Adding env variable support
- Adding output restructuring utils with tests
- Adding CHANGELOG.md and backfilling releases
- Adding utils to the core export
- Adding missing tests
0.0.6
- Increasing jest timeout
- Updating deps
- Increasing jest timeout
- Updating deps
0.0.7
- Adding env support for the api key
- Updating deps
- Adding env support for the api key
- Updating deps
1.0.0
- Adding forex support
- Adding crypto support
- Adding technical indicator support
- Adding weekly and monthly adjusted time series data support
- Updating deps
- Fixed issue where failing requests were not going to a catch handler.
- Adding forex support
- Adding crypto support
- Adding technical indicator support
- Adding weekly and monthly adjusted time series data support
- Updating deps
- Fixed issue where failing requests were not going to a catch handler.
BREAKING
- Changing the daily adjusted data to be under the daily_adjusted namespace from
adjusted
- Changing the daily adjusted data to be under the daily_adjusted namespace from
adjusted
1.1.0
- Adding batch quote support
- Updating jest to 22.0.4
- Adding batch quote support
- Updating jest to 22.0.4
1.1.1
- Updating dotenv dependency
- Fixing documentation for data endpoints
- Updating dotenv dependency
- Fixing documentation for data endpoints
1.1.2
- Updating deps
- Fixing broken forex test
- Updating deps
- Fixing broken forex test
1.2.0
- Adding global quote endpoint support
- Adding global quote endpoint support
1.2.1
- Fixing documentation for SMA usage
- Removing test for intraday crypto data (removed from API)
- Fixing documentation for SMA usage
- Removing test for intraday crypto data (removed from API)
1.2.2
- Adding Time Series FX (Daily) to the polish function
- Adding Time Series FX (Daily) to the polish function
1.2.3
- Updating dependencies to remove audit and outdated warnings
- Updating dependencies to remove audit and outdated warnings
1.2.4
- Adding symbol search endpoint support
- Adding symbol search endpoint support
1.2.5
- Removing crypto intraday support (removed from API)
- Removing crypto intraday support (removed from API)
1.2.6
- Updating dependencies.
- Removing sector performance test until the API works again.
- Updating dependencies.
- Removing sector performance test until the API works again.
2.0.0
- Adding browser support via UMD bundle.
'use strict';
require('dotenv').config();
const apiKey = 'AV_KEY';
import Util from './lib/util';
import Data from './lib/data';
import Forex from './lib/forex';
import Crypto from './lib/crypto';
import Technical from './lib/technical';
import Performance from './lib/performance';
// Attempt to load the env
try {
require('dotenv').config();
} catch (e) {}
/**
* The Alpha Vantage core module.
*/
module.exports = config => {
config = Object.assign({}, { key: process.env[apiKey] }, config);
export default (config = {}) => {
let key;
try {
key = process.env.AV_KEY;
} catch (e) {}
config = Object.assign({}, { key }, config);
// Check for config errors.

@@ -28,9 +42,9 @@ let errors = [];

return {
util: require('./lib/util')(config),
data: require('./lib/data')(config),
forex: require('./lib/forex')(config),
crypto: require('./lib/crypto')(config),
technical: require('./lib/technical')(config),
performance: require('./lib/performance')(config)
util: Util(config),
data: Data(config),
forex: Forex(config),
crypto: Crypto(config),
technical: Technical(config),
performance: Performance(config)
};
};
'use strict';
module.exports = config => {
const util = require('./util')(config);
import Util from './util';
export default config => {
const util = Util(config);
/**

@@ -7,0 +9,0 @@ * Util function to get the crypto data.

'use strict';
module.exports = config => {
const util = require('./util')(config);
import Util from './util';
export default config => {
const util = Util(config);
/**

@@ -7,0 +9,0 @@ * Util function to get the timeseries data.

'use strict';
module.exports = config => {
const util = require('./util')(config);
import Util from './util';
export default config => {
const util = Util(config);
return {

@@ -7,0 +9,0 @@ rate: (from_currency, to_currency) => util.fn('CURRENCY_EXCHANGE_RATE')({ from_currency, to_currency })

'use strict';
module.exports = config => {
const util = require('./util')(config);
import Util from './util';
export default config => {
const util = Util(config);
return {

@@ -7,0 +9,0 @@ sector: util.fn('SECTOR')

'use strict';
module.exports = config => {
const util = require('./util')(config);
import Util from './util';
export default config => {
const util = Util(config);
/**

@@ -7,0 +9,0 @@ * A generic function generator for sma-like technicals.

'use strict';
const request = require('request-promise-native');
import fetch from 'cross-fetch';

@@ -219,3 +219,3 @@ /**

module.exports = config => {
export default config => {
/**

@@ -312,11 +312,9 @@ * Recursively walk the data tree and replace weird keys with a normalized set.

const fn = type => params =>
request
.get(url(Object.assign({}, params, { function: type })), { resolveWithFullResponse: true, simple: false })
.then(response => {
const { body, statusCode } = response;
if (statusCode !== 200) {
throw `An AlphaVantage error occurred. ${statusCode}: ${body}`;
fetch(url(Object.assign({}, params, { function: type })))
.then(res => {
if (res.status !== 200) {
throw `An AlphaVantage error occurred. ${res.status}: ${res.text()}`;
}
return JSON.parse(body);
return res.json();
})

@@ -323,0 +321,0 @@ .then(data => {

{
"name": "alphavantage",
"version": "1.2.6",
"version": "2.0.0",
"description": "A simple interface to the Alpha Vantage API.",
"main": "index.js",
"browser": "dist/bundle.js",
"directories": {

@@ -11,4 +12,5 @@ "test": "test"

"test": "jest",
"lint": "prettier --print-width 120 --single-quote --write \"./**/**.js\"",
"coveralls": "cat ./coverage/lcov.info | coveralls"
"lint": "prettier --print-width 120 --single-quote --write \"./!(dist)**/**.js\"",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"build": "webpack"
},

@@ -34,11 +36,14 @@ "keywords": [

"dependencies": {
"dotenv": "^8.1.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.7"
"cross-fetch": "^3.0.4"
},
"devDependencies": {
"@babel/core": "^7.6.3",
"@babel/preset-env": "^7.6.3",
"babel-jest": "^24.9.0",
"coveralls": "^3.0.6",
"delay": "^4.3.0",
"jest": "^24.9.0",
"prettier": "^1.18.2"
"prettier": "^1.18.2",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
},

@@ -53,3 +58,6 @@ "jest": {

"testEnvironment": "node"
},
"optionalDependencies": {
"dotenv": "^8.1.0"
}
}

@@ -14,2 +14,3 @@ # AlphaVantage

## Installation
```bash

@@ -41,11 +42,11 @@ npm i alphavantage

console.log(data);
})
});
alpha.crypto.daily('btc', 'usd').then(data => {
console.log(data);
})
});
alpha.technical.sma(`msft`, `daily`, 60, `close`).then(data => {
console.log(data);
})
});

@@ -60,4 +61,5 @@ alpha.performance.sector().then(data => {

Data polishing
- Rewrite weird data keys to be consistent across all api calls. This is an optional utility you can use with the result of any api call.
- Rewrite weird data keys to be consistent across all api calls. This is an optional utility you can use with the result of any api call.
```javascript

@@ -70,2 +72,3 @@ const polished = alpha.util.polish(data);

See [Alpha Vantage](https://www.alphavantage.co/documentation/#time-series-data) for the parameters.
```javascript

@@ -87,4 +90,5 @@ alpha.data.intraday(symbol, outputsize, datatype, interval)

See [Alpha Vantage](https://www.alphavantage.co/documentation/#fx) for the parameters.
```javascript
alpha.forex.rate(from_currency, to_currency)
alpha.forex.rate(from_currency, to_currency);
```

@@ -95,6 +99,7 @@

See [Alpha Vantage](https://www.alphavantage.co/documentation/#digital-currency) for the parameters.
```javascript
alpha.crypto.daily(symbol, market)
alpha.crypto.weekly(symbol, market)
alpha.crypto.monthly(symbol, market)
alpha.crypto.daily(symbol, market);
alpha.crypto.weekly(symbol, market);
alpha.crypto.monthly(symbol, market);
```

@@ -105,55 +110,66 @@

See [Alpha Vantage](https://www.alphavantage.co/documentation/#technical-indicators) for the parameters.
```javascript
alpha.technical.sma(symbol, interval, time_period, series_type)
alpha.technical.ema(symbol, interval, time_period, series_type)
alpha.technical.wma(symbol, interval, time_period, series_type)
alpha.technical.dema(symbol, interval, time_period, series_type)
alpha.technical.tema(symbol, interval, time_period, series_type)
alpha.technical.trima(symbol, interval, time_period, series_type)
alpha.technical.kama(symbol, interval, time_period, series_type)
alpha.technical.mama(symbol, interval, series_type, fastlimit, slowlimit)
alpha.technical.t3(symbol, interval, time_period, series_type)
alpha.technical.macd(symbol, interval, series_type, fastperiod, slowperiod, signalperiod)
alpha.technical.macdext(symbol, interval, series_type, fastperiod, slowperiod, signalperiod, fastmatype, slowmatype, signalmatype)
alpha.technical.stoch(symbol, interval, fastkperiod, slowkperiod, slowdperiod, slowkmatype, slowdmatype)
alpha.technical.stochf(symbol, interval, fastkperiod, fastdperiod, fastdmatype)
alpha.technical.rsi(symbol, interval, time_period, series_type)
alpha.technical.stochrsi(symbol, interval, time_period, series_type, fastkperiod, slowdperiod, fastdmatype)
alpha.technical.willr(symbol, interval, time_period)
alpha.technical.adx(symbol, interval, time_period)
alpha.technical.adxr(symbol, interval, time_period)
alpha.technical.apo(symbol, interval, series_type, fastperiod, slowperiod, matype)
alpha.technical.ppo(symbol, interval, series_type, fastperiod, slowperiod, matype)
alpha.technical.mom(symbol, interval, time_period, series_type)
alpha.technical.bop(symbol, interval)
alpha.technical.cci(symbol, interval, time_period)
alpha.technical.cmo(symbol, interval, time_period, series_type)
alpha.technical.roc(symbol, interval, time_period, series_type)
alpha.technical.rocr(symbol, interval, time_period, series_type)
alpha.technical.aroon(symbol, interval, time_period)
alpha.technical.aroonosc(symbol, interval, time_period)
alpha.technical.mfi(symbol, interval, time_period)
alpha.technical.trix(symbol, interval, time_period, series_type)
alpha.technical.ultosc(symbol, interval, timeperiod1, timeperiod2, timeperiod3)
alpha.technical.dx(symbol, interval, time_period)
alpha.technical.minus_di(symbol, interval, time_period)
alpha.technical.plus_di(symbol, interval, time_period)
alpha.technical.minus_dm(symbol, interval, time_period)
alpha.technical.plus_dm(symbol, interval, time_period)
alpha.technical.bbands(symbol, interval, time_period, series_type, nbdevup, nbdevdn)
alpha.technical.midpoint(symbol, interval, time_period, series_type)
alpha.technical.midprice(symbol, interval, time_period)
alpha.technical.sar(symbol, interval, acceleration, maximum)
alpha.technical.trange(symbol, interval)
alpha.technical.atr(symbol, interval, time_period)
alpha.technical.natr(symbol, interval, time_period)
alpha.technical.ad(symbol, interval)
alpha.technical.adosc(symbol, interval, fastperiod, slowperiod)
alpha.technical.obv(symbol, interval)
alpha.technical.ht_trendline(symbol, interval, series_type)
alpha.technical.ht_sine(symbol, interval, series_type)
alpha.technical.ht_trendmode(symbol, interval, series_type)
alpha.technical.ht_dcperiod(symbol, interval, series_type)
alpha.technical.ht_dcphase(symbol, interval, series_type)
alpha.technical.ht_dcphasor(symbol, interval, series_type)
alpha.technical.sma(symbol, interval, time_period, series_type);
alpha.technical.ema(symbol, interval, time_period, series_type);
alpha.technical.wma(symbol, interval, time_period, series_type);
alpha.technical.dema(symbol, interval, time_period, series_type);
alpha.technical.tema(symbol, interval, time_period, series_type);
alpha.technical.trima(symbol, interval, time_period, series_type);
alpha.technical.kama(symbol, interval, time_period, series_type);
alpha.technical.mama(symbol, interval, series_type, fastlimit, slowlimit);
alpha.technical.t3(symbol, interval, time_period, series_type);
alpha.technical.macd(symbol, interval, series_type, fastperiod, slowperiod, signalperiod);
alpha.technical.macdext(
symbol,
interval,
series_type,
fastperiod,
slowperiod,
signalperiod,
fastmatype,
slowmatype,
signalmatype
);
alpha.technical.stoch(symbol, interval, fastkperiod, slowkperiod, slowdperiod, slowkmatype, slowdmatype);
alpha.technical.stochf(symbol, interval, fastkperiod, fastdperiod, fastdmatype);
alpha.technical.rsi(symbol, interval, time_period, series_type);
alpha.technical.stochrsi(symbol, interval, time_period, series_type, fastkperiod, slowdperiod, fastdmatype);
alpha.technical.willr(symbol, interval, time_period);
alpha.technical.adx(symbol, interval, time_period);
alpha.technical.adxr(symbol, interval, time_period);
alpha.technical.apo(symbol, interval, series_type, fastperiod, slowperiod, matype);
alpha.technical.ppo(symbol, interval, series_type, fastperiod, slowperiod, matype);
alpha.technical.mom(symbol, interval, time_period, series_type);
alpha.technical.bop(symbol, interval);
alpha.technical.cci(symbol, interval, time_period);
alpha.technical.cmo(symbol, interval, time_period, series_type);
alpha.technical.roc(symbol, interval, time_period, series_type);
alpha.technical.rocr(symbol, interval, time_period, series_type);
alpha.technical.aroon(symbol, interval, time_period);
alpha.technical.aroonosc(symbol, interval, time_period);
alpha.technical.mfi(symbol, interval, time_period);
alpha.technical.trix(symbol, interval, time_period, series_type);
alpha.technical.ultosc(symbol, interval, timeperiod1, timeperiod2, timeperiod3);
alpha.technical.dx(symbol, interval, time_period);
alpha.technical.minus_di(symbol, interval, time_period);
alpha.technical.plus_di(symbol, interval, time_period);
alpha.technical.minus_dm(symbol, interval, time_period);
alpha.technical.plus_dm(symbol, interval, time_period);
alpha.technical.bbands(symbol, interval, time_period, series_type, nbdevup, nbdevdn);
alpha.technical.midpoint(symbol, interval, time_period, series_type);
alpha.technical.midprice(symbol, interval, time_period);
alpha.technical.sar(symbol, interval, acceleration, maximum);
alpha.technical.trange(symbol, interval);
alpha.technical.atr(symbol, interval, time_period);
alpha.technical.natr(symbol, interval, time_period);
alpha.technical.ad(symbol, interval);
alpha.technical.adosc(symbol, interval, fastperiod, slowperiod);
alpha.technical.obv(symbol, interval);
alpha.technical.ht_trendline(symbol, interval, series_type);
alpha.technical.ht_sine(symbol, interval, series_type);
alpha.technical.ht_trendmode(symbol, interval, series_type);
alpha.technical.ht_dcperiod(symbol, interval, series_type);
alpha.technical.ht_dcphase(symbol, interval, series_type);
alpha.technical.ht_dcphasor(symbol, interval, series_type);
```

@@ -164,6 +180,27 @@

See [Alpha Vantage](https://www.alphavantage.co/documentation/#sector-information) for the parameters.
```javascript
alpha.performance.sector()
alpha.performance.sector();
```
## Browser Usage
This library can be used in the browser or in node since it is packaged as a UMD module. To use it in the browser, you must first include the bundled source. Without a bundler, that can be acheived with:
```html
<script src="./node_modules/alphavantage/dist/bundle.js"></script>
```
Then you can use it with the following:
```js
// import api from 'alphavantage';
let AV = window.alphavantage.default({ key: 'XXX' });
let data = AV.data.quote('aapl').then(data => {
console.log(data);
});
```
> Note: Your API key will be visible in the network traffic, this should not be used for public projects.
## Contributing

@@ -173,5 +210,8 @@

The build script, `npm run build`, can be used to rebuild the UMD module `dist/bundle.js` and it should be updated with each pull request.
## Contact
- Author: Zack Urben
- Twitter: https://twitter.com/zackurben (better)
- Contact: zackurben@gmail.com
- Author: Zack Urben
- Twitter: https://twitter.com/zackurben (better)
- Contact: zackurben@gmail.com
'use strict';
import Alpha from '../';
import delay from 'delay';
const alpha = Alpha();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jest.unmock('request-promise-native');
const alpha = require('../')();
const delay = require('delay');
jest.unmock('cross-fetch');
const TIME = 1000;

@@ -8,0 +10,0 @@

'use strict';
import Alpha from '../';
import delay from 'delay';
const alpha = Alpha();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jest.unmock('request-promise-native');
const alpha = require('../')();
const delay = require('delay');
jest.unmock('cross-fetch');
const TIME = 1000;

@@ -8,0 +10,0 @@

'use strict';
import Alpha from '../';
import delay from 'delay';
const alpha = Alpha();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jest.unmock('request-promise-native');
const alpha = require('../')();
const delay = require('delay');
jest.unmock('cross-fetch');
const TIME = 1000;

@@ -8,0 +10,0 @@

'use strict';
import Alpha from '../';
const env = process.env;
const Alpha = require('../');

@@ -6,0 +6,0 @@ // Clear the current environment variables for testing.

'use strict';
import Alpha from '../';
import delay from 'delay';
const alpha = Alpha();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jest.unmock('request-promise-native');
const alpha = require('../')();
const delay = require('delay');
jest.unmock('cross-fetch');
const TIME = 1000;

@@ -8,0 +10,0 @@

'use strict';
import Alpha from '../';
import delay from 'delay';
const alpha = Alpha();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jest.unmock('request-promise-native');
const alpha = require('../')();
const delay = require('delay');
jest.unmock('cross-fetch');
const TIME = 1000;

@@ -8,0 +10,0 @@

'use strict';
jest.mock('request-promise-native');
const alpha = require('../')();
jest.mock('cross-fetch');
import Alpha from '../';
const alpha = Alpha();

@@ -6,0 +7,0 @@ test(`the url builder properly builds urls`, () => {

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