Socket
Socket
Sign inDemoInstall

sp500

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sp500

Fetches the current S&P 500 price from Yahoo Finance API.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
2.53 kB
Created
Weekly downloads
 

Readme

Source

sp500

This npm module provides a simple interface to fetch the current price of the S&P500 from the Yahoo Finance API.

It's used by my Inflation Calculator website, in particular the section on Real S&P return.

Install

npm install sp500

Usage

Basic usage via fetch:

const sp500 = require('sp500');
sp500.fetch((err, result) => {
  console.log('Current value is:', result);
});

Constant updates via getMostRecent:

sp500.startPolling(30 * 1000);   // Update every 30 seconds.
// sp500.startPolling();         // Defaults to updating once every 5 min.

// Elsewhere in your app...
setInterval(() => {
  console.log('Updated value:', sp500.getMostRecent().value);    // A Number
  console.log('Updated at:', sp500.getMostRecent().timestamp);   // A JS Date object
}, 30 * 1000);

// Eventually
sp500.stopPolling();

FAQs

Last updated on 11 Jun 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc