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

treasury-bill-yield

v1.0.0

Published

US Treasury bill yield math — discount rate ↔ price ↔ bond-equivalent yield (investment rate), money-market yield. Treasury's own formulas incl. the >182-day quadratic and Feb-29 year basis. Zero dependencies.

Readme

treasury-bill-yield

US Treasury bill yield math — convert between the discount rate (how bills are auctioned and quoted), the price per $100, and the bond-equivalent yield (the "investment rate" TreasuryDirect publishes). Zero dependencies.

npm install treasury-bill-yield

Why

T-bills don't pay coupons, so their yields come in three flavors that constantly need converting: the 360-day discount rate, the actual price, and the 365/366-day bond-equivalent yield used to compare bills against notes and bonds. The formulas are the US Treasury's own — including the quadratic for bills longer than 182 days and the February-29 year-basis rule — and npm had none of them.

import { priceFromDiscount, bondEquivalentYield, discountFromPrice } from "tbill";

// 13-week bill auctioned at a 3.735% discount rate:
priceFromDiscount(0.03735, 91);   // 99.055875 — matches the published price

// 52-week bill 912797VQ7 (uses the >182-day quadratic):
bondEquivalentYield({
  price: 96.097111,
  issueDate: "2026-07-09",
  maturityDate: "2027-07-08",
});                                // 0.04032 — TreasuryDirect's investment rate

discountFromPrice(99.717667, 28); // 0.0363

Every function is tested against live TreasuryDirect auction records: for each fixture the government publishes all three numbers (discount rate, price, investment rate), and the tests reproduce each from the others — across 4-week, 13-week, 26-week, and 52-week tenors.

API

Rates are decimals (0.0383 = 3.83%; passing 3.83 throws with a helpful message). Prices are per-$100. Dates are "YYYY-MM-DD" strings or Date objects read as UTC.

  • priceFromDiscount(discountRate, days)100 · (1 − d·t/360)
  • discountFromPrice(price, days)
  • bondEquivalentYield({ price, issueDate, maturityDate }) — derives days and year basis, then: ≤182 days ((100−P)/P)·(y/t); >182 days the Treasury quadratic P·(1 + (t−y/2)/y·i)·(1 + i/2) = 100
  • bondEquivalentYieldFromDays(price, days, basis?) — explicit-basis variant
  • moneyMarketYield(discountRate, days) — CD-equivalent, 360·d/(360 − d·t)
  • yearBasis(issueDate) — 366 when Feb 29 falls within the following year, else 365
  • daysToMaturity(issueDate, maturityDate)

Related

Part of a small fixed-income toolkit: 32nds (Treasury quote notation) · day-count · accrued-interest · sifma-holidays · treasurydirect (fetch the auction data these formulas reproduce).

Author

Built by Moshe Malka — engineering leader in New York City. Studio work at Quentin.Code.

MIT © Moshe Malka