šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

sp500

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

sp500

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

1.0.5
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
Ā 
Created
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

Package last updated on 11 Jun 2018

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