Bond yield from price
bond-yield-from-price · version 1.0.0 · Financial calculations · free, no key needed
Yield to maturity of a fixed-coupon bond from its clean price, with accrued and dirty price (Excel YIELD / SIA).
Use when you need to: implied yield to maturity of a bond quoted at a price · YTM of a coupon bond · yield from clean price.
Decide before calling
Read the versioned contract and the supported scope below. Reuse bond-yield-from-price@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use bond-yield-from-price@1.0.0 for implied yield to maturity of a bond quoted at a price. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- implied yield to maturity of a bond quoted at a price
- YTM of a coupon bond
- yield from clean price
- what yield does a bond price of 95 imply
- Excel YIELD function equivalent
- implied yield of a semiannual coupon bond
- solve bond yield given price and coupon
- yield to maturity between coupon dates
- תשואה לפדיון של אגרת חוב לפי מחיר
Not supported
- price from a yield (use bond-price-from-yield)
- current yield, simple yield, yield to call or yield to worst
- Treasury bill yields (use tbill-yield-convert)
- odd first or last coupon periods, callable and putable bonds
Behavior
- Dates are strict ISO YYYY-MM-DD real dates in years 1900 to 2200 with settlement strictly before maturity. frequency is the JSON integer 1, 2, 4 or 12; basis is 30-360-us (Excel 0, default), act-act (1), act-360 (2), act-365f (3) or 30e-360 (4). Coupon dates, N (above 1200 is limit_exceeded), A, DSC and E follow bond-price-from-yield (Excel COUP* rules).
- clean_price is the quoted price per 100 of face with 0 < clean_price <= 1e9; redemption is per 100 with 0 < redemption <= 1000 (default "100"); coupon_rate is a fraction from 0 to 1. A JSON number for a decimal field is invalid_input.
- accrued_interest = c*A/E with c = 100*coupon_rate/frequency, and the target dirty price is clean_price + accrued_interest exactly. The output yield is the annual yield (compounded frequency times a year) whose bond-price-from-yield dirty price equals that target; for N > 1 the price is strictly decreasing in the yield, so the root is unique.
- N = 1 (method closed-form): yield = frequency*((redemption + c)/dirty - 1)*(E/DSC), the Excel YIELD single-coupon formula, exact and rounded once; DSC = 0 is not_computable (division_by_zero).
- N > 1 (method root-finding): the periodic rate i = yield/frequency is bracketed on the pinned grid [-0.99, -0.95, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.25, -0.2, -0.15, -0.1, -0.075, -0.05, -0.025, -0.01, 0, 0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.125, 0.15, 0.175, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1, 1.5, 2, 3, 5, 10, 20, 50, 100, 1000] and solved with Brent's method (absolute tolerance 1e-14 on i, at most 200 iterations) on binary64 arithmetic. A target outside the price range of the grid (no_root_in_range) or a non-converging solve (no_convergence) is not_computable. Two roots inside one grid interval could be missed, but the price is monotonic so this cannot occur here.
- The yield agrees with the exact root within 2e-12 absolute, and is rounded from the float root converted exactly; a root within 2e-12 of a rounding boundary at rate_scale digits may round either way. It can lie outside (-frequency, 10] (up to 1000*frequency) and is reported as found. dirty_price and accrued_interest are exact-path values rounded once to scale.
- scale (0 to 12, default 6) sets the digits of dirty_price and accrued_interest; rate_scale (0 to 10, default 10) sets the digits of yield; rounding is half-up (default, half away from zero), half-even, half-down, up, down, ceiling or floor. Iteration counts are not reported. Outputs never contain -0.
- Any string input over 64 UTF-8 bytes is limit_exceeded, checked before parsing; a lone surrogate is invalid_input.
- Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice.
Input
settlement(string, required): max length 10; pattern^[0-9]{4}-[0-9]{2}-[0-9]{2}$maturity(string, required): max length 10; pattern^[0-9]{4}-[0-9]{2}-[0-9]{2}$coupon_rate(string, required): max length 64; pattern^(0|[1-9][0-9]{0,19})(\.[0-9]{1,20})?$frequency(one of 1, 2, 4, 12, required)basis(one of "30-360-us", "act-act", "act-360", "act-365f", "30e-360", optional)clean_price(string, required): max length 64; pattern^(0|[1-9][0-9]{0,19})(\.[0-9]{1,20})?$redemption(string, optional): max length 64; pattern^(0|[1-9][0-9]{0,19})(\.[0-9]{1,20})?$rate_scale(integer, optional): min 0; max 10scale(integer, optional): min 0; max 12rounding(one of "half-up", "half-even", "half-down", "up", "down", "ceiling", "floor", optional)
Output
yield(string, required): pattern^-?(0|[1-9][0-9]*)(\.[0-9]+)?$dirty_price(string, required): pattern^(0|[1-9][0-9]*)(\.[0-9]+)?$accrued_interest(string, required): pattern^(0|[1-9][0-9]*)(\.[0-9]+)?$coupons_remaining(integer, required): min 1; max 1200method(one of "closed-form", "root-finding", required)
Limits
- max string bytes: 64
- max coupons: 1200
- max iterations: 200
Example
Request input:
{
"settlement": "2008-02-15",
"maturity": "2016-11-15",
"coupon_rate": "0.0575",
"frequency": 2,
"clean_price": "95.04287",
"basis": "30-360-us",
"rate_scale": 6
}
Response:
{
"result": {
"yield": "0.065000",
"dirty_price": "96.480370",
"accrued_interest": "1.437500",
"coupons_remaining": 18,
"method": "root-finding"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "bond-yield-from-price",
"version": "1.0.0",
"input": {
"settlement": "2008-02-15",
"maturity": "2016-11-15",
"coupon_rate": "0.0575",
"frequency": 2,
"clean_price": "95.04287",
"basis": "30-360-us",
"rate_scale": 6
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/bond-yield-from-price/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"settlement":"2008-02-15","maturity":"2016-11-15","coupon_rate":"0.0575","frequency":2,"clean_price":"95.04287","basis":"30-360-us","rate_scale":6}'
The machine-readable contract is at /v1/tools/bond-yield-from-price/versions/1.0.0.
CLI
node cli.mjs run bond-yield-from-price 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Bond price from yield: Clean price, dirty price and accrued interest per 100 of a fixed-coupon bond from its yield (Excel PRICE, SIA).
- Tbill yield convert: Convert a Treasury bill price, discount rate, investment rate or money-market yield into all four (31 CFR 356 App. B).
- Bond duration convexity: Macaulay and modified duration, convexity and DV01 of a fixed-coupon bond at a yield (Excel DURATION, MDURATION).
- Bond cashflow schedule: Coupon dates, coupons remaining, accrued days and accrued interest for a regular fixed-coupon bond (Excel COUP* rules).
- Growth cagr compute: CAGR from start and end values or a total return over years or dates, with a sub-year warning.
- Cashflow irr: IRR of equally spaced cash flows with every root reported, the chosen root named and no-solution cases signalled.