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

tips-index-ratio

v1.0.0

Published

US TIPS inflation math per 31 CFR 356 Appendix B — reference-CPI interpolation, index ratios, inflation-adjusted principal and interest, deflation floor. Reproduces TreasuryDirect's published values. Zero dependencies.

Readme

tips-index-ratio

US TIPS inflation math per 31 CFR Part 356, Appendix B — reference-CPI interpolation, index ratios, inflation-adjusted principal and interest, and the deflation floor. Zero dependencies.

npm install tips-index-ratio

Why

A Treasury Inflation-Protected Security's principal moves with the CPI, and the exact rule is fiddly: the reference CPI on any date is a day-weighted interpolation between the CPI-U from three and two months prior, rounded to five decimals, and the index ratio divides one by another. Get the interpolation or the rounding slightly wrong and every downstream number drifts. npm had nothing that implements it — this package does, and it reproduces TreasuryDirect's own published figures to the digit.

import { refCpi, indexRatio, redemptionValue } from "tips-index-ratio";

// CPI-U NSA (BLS series CUUR0000SA0), keyed by month:
const cpi = { "2026-01": 325.252, "2026-02": 326.785, "2026-03": 330.213, "2026-04": 333.020 };

refCpi("2026-04-15", cpi);   // 325.9674  — matches TreasuryDirect's refCpiOnDatedDate
refCpi("2026-06-30", cpi);   // 332.92643 — matches refCpiOnIssueDate

indexRatio({ date: "2026-06-30", datedDate: "2026-04-15", cpi });
// 1.02135 — matches TreasuryDirect's indexRatioOnIssueDate

redemptionValue(1000, 0.9779); // 1000 — deflation floor guarantees par at maturity

API

CPI input is the not-seasonally-adjusted CPI-U (BLS series CUUR0000SA0), an object keyed "YYYY-MM". Dates are "YYYY-MM-DD" strings or Date objects (UTC).

  • refCpi(date, cpi, opts?) — reference CPI on a date. opts.rounded (default true) applies the Treasury's 5-decimal rounding. Throws a helpful error naming the exact month if the series is missing a value it needs.
  • indexRatio({ date, datedDate, cpi }, opts?)refCpi(date) / refCpi(datedDate), rounded to 5 decimals.
  • adjustedPrincipal(face, ratio)face × ratio (unfloored; this is the coupon base).
  • redemptionValue(face, ratio)face × max(ratio, 1); the deflation floor applies only at maturity.
  • interestPayment(face, rate, ratio, frequency?)face × ratio × rate / frequency; rate is a decimal, frequency defaults to 2 (semiannual).

You bring the CPI series — pair it with a BLS client or TreasuryDirect's published values. The math is exact and offline.

Correctness

Test vectors are live TreasuryDirect TIPS auction records: for real CUSIPs the package reproduces the published refCpiOnDatedDate, refCpiOnIssueDate, and indexRatioOnIssueDate exactly, using real BLS CPI-U figures as input.

Related

Part of a small fixed-income toolkit: treasurydirect (fetch the TIPS records and CPI refs) · accrued-interest · day-count · tbill · 32nds · sifma-holidays · newyorkfed · instrument-identifiers.

Author

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

MIT © Moshe Malka