npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@livefolio/market

v0.3.1

Published

Market data provider for Livefolio. Fetches daily bars from Yahoo Finance (equities, ETFs, crypto) and FRED (Treasury rates), and streams live prices from Yahoo's WebSocket feed.

Downloads

487

Readme

@livefolio/market

Market data provider for Livefolio. Fetches daily bars from Yahoo Finance (equities, ETFs, crypto) and FRED (Treasury rates), and streams live prices from Yahoo's WebSocket feed.

Implements the MarketProvider and PriceStream interfaces from @livefolio/sdk.

Install

npm install @livefolio/market

Requires Node 20+.

Daily bars

import { createYahooFredMarket } from '@livefolio/market';

const market = createYahooFredMarket({ fredApiKey: process.env.FRED_API_KEY! });

await market.fetchBars('AAPL');          // Yahoo
await market.fetchBars('DGS10');         // FRED (10-year Treasury)
await market.fetchBars('SPY', '2020-01-01');

Symbols are routed automatically: known FRED series (DGS3MO, DGS1, DGS10, DTB3, etc.) hit FRED; everything else goes to Yahoo.

Returns DailyBar[] where each bar is { date: 'YYYY-MM-DD', value: number }. Fetch failures throw MarketFetchError with the source and symbol attached.

Polling live quotes

fetchQuotes returns current prices for a mixed batch of Yahoo and FRED symbols. Each result is either { symbol, price, time } or { symbol, error } — the method itself never throws, and partial failures don't kill the batch.

import { createYahooFredMarket } from '@livefolio/market';

const market = createYahooFredMarket({ fredApiKey: process.env.FRED_API_KEY! });
const quotes = await market.fetchQuotes(['AAPL', 'SPY', 'DGS10', 'BOGUS']);

for (const q of quotes) {
  if (q.error) console.warn(q.error.message);
  else console.log(q.symbol, q.price, q.time);
}

Yahoo times are tick-accurate ISO 8601 timestamps. FRED times are the observation date at T00:00:00.000Z since FRED observations are date-granular.

Live price stream

import { createYahooPriceStream } from '@livefolio/market/stream';

const stream = createYahooPriceStream();

stream.on('tick', (symbol, price, time) => {
  console.log(symbol, price, time);
});
stream.on('status', (status) => console.log(status)); // 'connected' | 'reconnecting' | 'disconnected'
stream.on('error', (err) => console.error(err));

stream.subscribe('AAPL', 'MSFT');
// ...
stream.unsubscribe('MSFT');
stream.close();

Connects to wss://streamer.finance.yahoo.com/, decodes Yahoo's protobuf ticker frames, and reconnects with exponential backoff (capped at 8s) until close() is called.

Development

npm run build
npm test
npm run lint