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

finance-stock-info

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

finance-stock-info

Module to retrieve current stock information from Alpha Vantage API

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

TS-JS Finance Stock Info Library

npm npm bundle size

Module to retrieve current stock information from Alpha Vantage API.

Installation

  • Sign up for your own API Key on Rapid API
  • Install it:
npm i finance-stock-info

Link to npm library

Usage

const { StockInfo } = require('finance-stock-info');

// Insert your RapidApi API Key:
const myApiKey = '<MYAPIKEY>';

// Instantiate a new StockInfo class
const stock = new StockInfo(myApiKey);

// Use these methods to return you a Promise:
stock.getStockInfo('tsla').then((info) => console.log(info));
/* 
  {
    'Global Quote': {
      '01. symbol': 'TSLA',
      '02. open': '729.6750',
      '03. high': '743.3899',
      '04. low': '700.2534',
      '05. price': '703.5500',
      '06. volume': '37464579',
      '07. latest trading day': '2022-06-03',
      '08. previous close': '775.0000',
      '09. change': '-71.4500',
      '10. change percent': '-9.2194%'
    }
  }
*/

stock.getPrice('tsla').then((price) => console.log(price));
// 703.5500

stock.getTotalValue('tsla', 3).then((value) => console.log(value));
// 2110.6499999999996

stock.getChangePercent('twtr').then((percent) => console.log(percent));
// 0.6264%

stock.getTradeVolume('twtr').then((volume) => console.log(volume));
// 18269884

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Testing

To run tests:

  • Include your API key in the tests/test.js file. Then run:
npm test

To check code test coverage:

npx jest --coverage

License

MIT

FAQs

Package last updated on 15 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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