Observed since 20 Oct, 19:25 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
US Treasury price math — parse and format 32nds quotes (105-16+), ticks, and basis points. Zero dependencies, exact IEEE 754 arithmetic.
US Treasury price math for JavaScript/TypeScript — parse and format 32nds quotes (105-16+, 110'165), count ticks, convert basis points, and compute dollar values. Zero dependencies.
npm install 32nds
Treasuries don't trade in decimals. A 10-year note is quoted like 105-16+: a handle of 105 points, 16 thirty-seconds, plus half a 32nd — 105.515625% of par. Every fixed-income UI, blotter, and P&L report has to translate between that notation and numbers, and npm had nothing for it: bond analytics libraries compute yield and duration, but none of them can read a price the way the market writes it.
32nds does exactly that one job, correctly:
import { parsePrice, formatPrice, tickValue } from "32nds";
parsePrice("105-16+"); // 105.515625
parsePrice("104-072"); // 104.2265625 (7¼ 32nds)
parsePrice("110'165", { style: "cme" }); // 110.515625 (futures display)
formatPrice(99.109375); // "99-03+"
formatPrice(110.5, { style: "cme" }); // "110'160"
tickValue(1_000_000); // 312.50 — a 32nd on $1MM face
A nice property: Treasury fractions are dyadic rationals (powers of two), so every value here is exact in IEEE 754 floating point. No decimal library, no epsilon comparisons.
| Notation | Meaning | Decimal |
|---|---|---|
105-16 | 105 + 16/32 | 105.50 |
105-16+ | + half a 32nd (1/64) | 105.515625 |
104-072 | trailing digit = eighths of a 32nd (cash market) | 104.2265625 |
105-16½, 105-16 1/2 | unicode or ASCII fractions of a 32nd | 105.515625 |
105-16.25 | explicit decimal 32nds | 105.5078125 |
110'165 | CME futures: 2/5/7 = ¼/½/¾ of a 32nd | 110.515625 |
104'166 | CME 2-year note (ZT): 1/3/6/8 = ⅛/⅜/⅝/⅞ of a 32nd | 104.51953125 |
-0-08+ | signed quotes (price changes) | −0.265625 |
Separators -, ', and : are accepted. A decimal point is deliberately not a separator: parsePrice("105.16") throws instead of silently reading 16/32 — decimals are already numbers.
The same trailing digit means different things in the two notations: cash 105-165 is 16⅝/32, CME 105'165 is 16½/32. CME's digit is the fraction of a 32nd truncated to tenths (⅛ = .125 → 1, ⅝ = .625 → 6), so it is never 4 or 9; the eighths digits 1/3/6/8 are used by 2-year note futures, whose tick has been ⅛ of a 32nd since January 2019.
parsePrice(quote, opts?) → numberQuote string → percent-of-par number. opts.style: "eighths" (default, cash-market: trailing digit 0–7 is eighths of a 32nd) or "cme" (futures: 0/1/2/3/5/6/7/8 = 0/⅛/¼/⅜/½/⅝/¾/⅞). Throws RangeError on malformed input, 32nds ≥ 32, or invalid fraction digits.
formatPrice(price, opts?) → stringNumber → quote string. Rounds to 1/256 (an eighth of a 32nd) first, halfway values away from zero; a negative value that rounds to zero prints as 0-00.
style — "eighths" (default) or "cme" (always renders the fraction digit, like Globex: 110'160)sep — separator; defaults "-" (eighths) / "'" (cme)plus — render half a 32nd as "+" (default true)pad — two-digit 32nds, 99-03 (default true)ticksBetween(from, to, tick?) — signed tick count between two prices (default tick 1/32)roundToTick(price, tick?) — snap a price to the nearest tick (halfway values away from zero)change32nds(from, to) — a move expressed in 32ndstoBps(decimal) / fromBps(bps) — basis-point conversion (toBps(0.0025) → 25)dollarValue(price, face) — dollar value of a price on a face amounttickValue(face, tick?) — dollar value of one tick (tickValue(1_000_000) → 312.50)THIRTY_SECOND (1/32, cash tick), HALF_32ND (1/64, ZN futures), QUARTER_32ND (1/128, ZF/Z3N futures), EIGHTH_32ND (1/256, cash quote resolution and the ZT futures tick since 2019).
Part of a small fixed-income toolkit: day-count (ISDA conventions) · accrued-interest · sifma-holidays (bond-market calendar) · treasurydirect (auction data client).
Built by Moshe Malka — engineering leader in New York City. Studio work at Quentin.Code.
MIT © Moshe Malka
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:25 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:fce0eaa0739a01b946f6b878a2a51a0dabac3fbbe410a55cb51f014744203c04