Catalog npm
PACKAGE EXPLORERView in registry

32nds

npm

US Treasury price math — parse and format 32nds quotes (105-16+), ticks, and basis points. Zero dependencies, exact IEEE 754 arithmetic.

32ndsbasis-pointsbond-mathbondsbpscmefinancefintechfixed-incomefuturespricequoteticktradingtreasury
Versions collected2
Direct dependencies3From release 1.1.0
Last observed20 Oct, 19:25 UTC

README

Current package documentation

32nds

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

Why

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.

Conventions handled

NotationMeaningDecimal
105-16105 + 16/32105.50
105-16++ half a 32nd (1/64)105.515625
104-072trailing digit = eighths of a 32nd (cash market)104.2265625
105-16½, 105-16 1/2unicode or ASCII fractions of a 32nd105.515625
105-16.25explicit decimal 32nds105.5078125
110'165CME futures: 2/5/7 = ¼/½/¾ of a 32nd110.515625
104'166CME 2-year note (ZT): 1/3/6/8 = ⅛/⅜/⅝/⅞ of a 32nd104.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.

API

parsePrice(quote, opts?) → number

Quote 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?) → string

Number → 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)

Ticks and values

  • 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 32nds
  • toBps(decimal) / fromBps(bps) — basis-point conversion (toBps(0.0025) → 25)
  • dollarValue(price, face) — dollar value of a price on a face amount
  • tickValue(face, tick?) — dollar value of one tick (tickValue(1_000_000) → 312.50)

Tick constants

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).

References

Part of a small fixed-income toolkit: day-count (ISDA conventions) · accrued-interest · sifma-holidays (bond-market calendar) · treasurydirect (auction data client).

Author

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

MIT © Moshe Malka

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 2

Collected releases
VersionPublishedDirect dependenciesOpen version
1.1.0Registry latest10 Oct 20263
1.0.011 Jul 20263

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
moshejs/32nds

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:25 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:fce0eaa0739a01b946f6b878a2a51a0dabac3fbbe410a55cb51f014744203c04