Giter VIP home page Giter VIP logo

alphavantage's Introduction

AlphaVantage

Build Status Coverage Status Greenkeeper badge

This is a simple wrapper around the Alpha Vantage API hosted on NPM. I have no affiliation with AlphaVantage.

All contributions are welcome! This is an open source project under the MIT license, see LICENSE.md for additional information.

All available functions with this SDK have the same parameters as listed in the the Alpha Vantage Docs, without the "function" or "apikey". Do not include the "function" or "apikey" parameters when using this library. All functions return promises with the response data.

Installation

npm i alphavantage

Usage

/**
 * Init Alpha Vantage with your API key.
 *
 * @param {String} key
 *   Your Alpha Vantage API key.
 */
const alpha = require('alphavantage')({ key: 'qweqweqwe' });

// Simple examples
alpha.data.intraday(`msft`).then(data => {
  console.log(data);
});

alpha.forex.rate('btc', 'usd').then(data => {
  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);
});

alpha.performance.sector().then(data => {
  console.log(data);
});

Util

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.
const polished = alpha.util.polish(data);

Data

See Alpha Vantage for the parameters.

alpha.data.intraday(symbol, outputsize, datatype, interval);
alpha.data.daily(symbol, outputsize, datatype, interval);
alpha.data.daily_adjusted(symbol, outputsize, datatype, interval);
alpha.data.weekly(symbol, outputsize, datatype, interval);
alpha.data.weekly_adjusted(symbol, outputsize, datatype, interval);
alpha.data.monthly(symbol, outputsize, datatype, interval);
alpha.data.monthly_adjusted(symbol, outputsize, datatype, interval);
alpha.data.quote(symbol, outputsize, datatype, interval);
alpha.data.search(keywords);

Forex

See Alpha Vantage for the parameters.

alpha.forex.rate(from_currency, to_currency);

Crypto

See Alpha Vantage for the parameters.

alpha.crypto.daily(symbol, market);
alpha.crypto.weekly(symbol, market);
alpha.crypto.monthly(symbol, market);

Technicals

See Alpha Vantage for the parameters.

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);

Performance

See Alpha Vantage for the parameters.

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:

<script src="./node_modules/alphavantage/dist/bundle.js"></script>

Then you can use it with the following:

// 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

All contributions are welcome! The purpose of this library is to keep function parity with the Alpha Vantage API, while keeping a slim and intuitive programming interface. Before any pull requests are made, please run npm run lint to fix style issues and ensure that all test are passing npm test. The codebase should always remain at 100% test coverage.

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

alphavantage's People

Contributors

2pacisalive avatar brunoquaresma avatar freddyfy avatar greenkeeper[bot] avatar ianmitchell avatar jzatt avatar zackurben avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.