1.0.4 • Published 2 years ago

finance-stock-info v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago