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 = ;sp500;
Constant updates via getMostRecent
:
sp500; // Update every 30 seconds.// sp500.startPolling(); // Defaults to updating once every 5 min. // Elsewhere in your app...; // Eventuallysp500;