{"_id":"32nds","_rev":"2-2ff64c6abc398a8381142b5677c23cf7","name":"32nds","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"32nds","version":"1.0.0","keywords":["treasury","bonds","fixed-income","32nds","tick","basis-points","bps","finance","fintech","price","quote","cme","futures","bond-math","trading"],"author":{"url":"https://moshemalka.com","name":"Moshe Malka","email":"hello@moshemalka.com"},"license":"MIT","_id":"32nds@1.0.0","maintainers":[{"name":"quentin_code","email":"moshe@quentin.software"}],"homepage":"https://moshemalka.com","bugs":{"url":"https://github.com/moshejs/32nds/issues"},"dist":{"shasum":"30bac77868ad30924ff98621bef5202612f3355c","tarball":"https://registry.npmjs.org/32nds/-/32nds-1.0.0.tgz","fileCount":7,"integrity":"sha512-MubL844mZwAjYbjmNndB3nhsPpnqtbb+JUu1M6mtKxb1dJ+gQtpHtQHEvEPcjaZJqkQovSQlRwW84KZbxmpMwQ==","signatures":[{"sig":"MEQCICKOrHLsWPRcRBQ1iem3YZJVJVciAL6YvpbKacSMUYXJAiAbeIFuFEz44V42ICPv8U20zQTFfGOyHCmBF1BnRi8WAA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23053},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"3d45f69554fcb465c54e2f5e57761ecf3179a128","scripts":{"test":"vitest run","build":"tsup src/index.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"_npmUser":{"name":"quentin_code","email":"moshe@quentin.software"},"repository":{"url":"git+https://github.com/moshejs/32nds.git","type":"git"},"_npmVersion":"10.9.2","description":"US Treasury price math — parse and format 32nds quotes (105-16+), ticks, and basis points. Zero dependencies, exact IEEE 754 arithmetic.","directories":{},"sideEffects":false,"_nodeVersion":"23.6.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","vitest":"^3.2.0","typescript":"^5.8.0"},"_npmOperationalInternal":{"tmp":"tmp/32nds_1.0.0_1783738035077_0.08060684254684869","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-07-11T02:47:15.023Z","modified":"2026-07-16T02:33:08.311Z","1.0.0":"2026-07-11T02:47:15.216Z"},"bugs":{"url":"https://github.com/moshejs/32nds/issues"},"author":{"url":"https://moshemalka.com","name":"Moshe Malka","email":"hello@moshemalka.com"},"license":"MIT","homepage":"https://moshemalka.com","keywords":["treasury","bonds","fixed-income","32nds","tick","basis-points","bps","finance","fintech","price","quote","cme","futures","bond-math","trading"],"repository":{"url":"git+https://github.com/moshejs/32nds.git","type":"git"},"description":"US Treasury price math — parse and format 32nds quotes (105-16+), ticks, and basis points. Zero dependencies, exact IEEE 754 arithmetic.","maintainers":[{"email":"moshe@quentin.software","name":"moshejs"}],"readme":"# 32nds\n\nUS 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.\n\n```\nnpm install 32nds\n```\n\n## Why\n\nTreasuries 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.\n\n`32nds` does exactly that one job, correctly:\n\n```ts\nimport { parsePrice, formatPrice, tickValue } from \"32nds\";\n\nparsePrice(\"105-16+\");                    // 105.515625\nparsePrice(\"104-072\");                    // 104.2265625  (7¼ 32nds)\nparsePrice(\"110'165\", { style: \"cme\" });  // 110.515625   (futures display)\n\nformatPrice(99.109375);                   // \"99-03+\"\nformatPrice(110.5, { style: \"cme\" });     // \"110'160\"\n\ntickValue(1_000_000);                     // 312.50 — a 32nd on $1MM face\n```\n\nA 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.\n\n## Conventions handled\n\n| Notation | Meaning | Decimal |\n| --- | --- | --- |\n| `105-16` | 105 + 16/32 | 105.50 |\n| `105-16+` | + half a 32nd (1/64) | 105.515625 |\n| `104-072` | trailing digit = eighths of a 32nd (cash market) | 104.2265625 |\n| `105-16½` | unicode fractions accepted | 105.515625 |\n| `110'165` | CME futures: 2/5/7 = ¼/½/¾ of a 32nd | 110.515625 |\n| `-0-08+` | signed quotes (price changes) | −0.265625 |\n\nSeparators `-`, `'`, 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.\n\n## API\n\n### `parsePrice(quote, opts?) → number`\n\nQuote string → percent-of-par number. `opts.style`: `\"eighths\"` (default, cash-market: trailing digit 0–7 is eighths of a 32nd) or `\"cme\"` (futures: 0/2/5/7 = 0/¼/½/¾). Throws `RangeError` on malformed input, 32nds ≥ 32, or invalid fraction digits.\n\n### `formatPrice(price, opts?) → string`\n\nNumber → quote string. Rounds to the style's resolution first (1/256 eighths, 1/128 cme).\n\n- `style` — `\"eighths\"` (default) or `\"cme\"` (always renders the fraction digit, like Globex: `110'160`)\n- `sep` — separator; defaults `\"-\"` (eighths) / `\"'\"` (cme)\n- `plus` — render half a 32nd as `\"+\"` (default `true`)\n- `pad` — two-digit 32nds, `99-03` (default `true`)\n\n### Ticks and values\n\n- `ticksBetween(from, to, tick?)` — signed tick count between two prices (default tick 1/32)\n- `roundToTick(price, tick?)` — snap a price to the nearest tick\n- `change32nds(from, to)` — a move expressed in 32nds\n- `toBps(decimal)` / `fromBps(bps)` — basis-point conversion (`toBps(0.0025)` → 25)\n- `dollarValue(price, face)` — dollar value of a price on a face amount\n- `tickValue(face, tick?)` — dollar value of one tick (`tickValue(1_000_000)` → 312.50)\n\n### Tick constants\n\n`THIRTY_SECOND` (1/32, cash tick), `HALF_32ND` (1/64, ZN futures), `QUARTER_32ND` (1/128, ZF/ZT futures), `EIGHTH_32ND` (1/256, cash quote resolution).\n\n## References\n\n- [CME Group — Calculating U.S. Treasury Pricing](https://www.cmegroup.com/education/courses/introduction-to-treasuries/calculating-us-treasury-pricing)\n- [CME Group — Treasury Futures Price Rounding Conventions](https://www.cmegroup.com/trading/interest-rates/files/treasury-futures-price-rounding-conventions-2020.pdf)\n\n## Related\n\nPart of a small fixed-income toolkit: [`day-count`](https://github.com/moshejs/day-count) (ISDA conventions) · [`accrued-interest`](https://github.com/moshejs/accrued-interest) · [`sifma-holidays`](https://github.com/moshejs/sifma-holidays) (bond-market calendar) · [`treasurydirect`](https://github.com/moshejs/treasurydirect) (auction data client).\n\n## Author\n\nBuilt by **[Moshe Malka](https://moshemalka.com)** — engineering leader in New York City. Studio work at [Quentin.Code](https://www.quentin.software/).\n\nMIT © Moshe Malka\n","readmeFilename":"README.md"}