# Bond price from yield

`bond-price-from-yield` · version 1.0.0 · Financial calculations · free, no key needed

Clean price, dirty price and accrued interest per 100 of a fixed-coupon bond from its yield (Excel PRICE, SIA).

**Use when you need to: price a bond given its yield to maturity · clean price of a bond · dirty price of a bond with accrued interest.**

## Decide before calling

Read the [versioned contract](/v1/tools/bond-price-from-yield/versions/1.0.0) and the supported scope below. Reuse `bond-price-from-yield@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-price-from-yield@1.0.0` for price a bond given its yield to maturity. 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

- price a bond given its yield to maturity
- clean price of a bond
- dirty price of a bond with accrued interest
- price a semiannual coupon bond at a given yield
- bond value per 100 face at a yield
- what is a 5 percent coupon bond worth at 6 percent yield
- Excel PRICE function equivalent
- street convention bond price
- מחיר אגרת חוב לפי תשואה לפדיון

## Not supported

- yield from a price (use bond-yield-from-price)
- duration, convexity or DV01 (use bond-duration-convexity)
- odd first or last coupon periods, callable and putable bonds
- yield conventions other than the periodic-compounded street yield

## 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). Prices are per 100 of face; there is no face input.
- Coupon dates are maturity shifted back j*(12/frequency) months, each computed from maturity and month ends when maturity is a month end. The previous coupon date is the latest one on or before settlement, N is the number of coupons remaining (above 1200 is limit_exceeded), and A, DSC and E follow Excel COUPDAYBS, COUPDAYSNC and COUPDAYS: 30/360 bases use E = 360/frequency and DSC = E - A; act-act uses actual days for A, DSC and E; act-360 and act-365f use actual days for A and DSC with E = 360/frequency or 365/frequency (exact).
- yield is the annual yield to maturity as a decimal fraction compounded frequency times a year, with -frequency < yield <= 10 ("0.065" is 6.5 percent); coupon_rate is a fraction from 0 to 1; redemption is per 100 with 0 < redemption <= 1000 (default "100"). A JSON number for a decimal field is invalid_input.
- With c = 100*coupon_rate/frequency and i = yield/frequency: for N > 1, dirty_price = redemption/(1+i)^(N-1+DSC/E) + the sum for k = 1..N of c/(1+i)^(k-1+DSC/E). For N = 1 (Excel PRICE special case), dirty_price = (redemption + c)/(1 + (DSC/E)*i); it is not_computable when that denominator is not positive.
- accrued_interest = c*A/E and clean_price = dirty_price - accrued_interest. Each of the three prices is rounded once from its exact value to scale, so the rounded clean price plus the rounded accrued interest can differ from the rounded dirty price by one unit in the last place. period_days is E with exactly 6 fractional digits.
- The N = 1 case uses simple (money-market) discounting for the last period, while bond-duration-convexity uses compound discounting for every N, so the two differ slightly for N = 1 by design (Excel PRICE versus DURATION).
- Defaults when omitted: scale 6 (integer 0 to 12), rounding half-up (half away from zero; also half-even, half-down, up, down, ceiling, floor), basis 30-360-us, redemption 100. Integer exponents are exact; fractional exponents use exp/ln in a 40-digit BigInt engine accurate to better than 1e-35 relative. Outputs never contain -0.
- If the exact dirty price reaches 1e20 the result is not_computable (details.reason overflow); this can happen only for a yield close to -frequency (many periods at a 1 + i close to 0, or an N = 1 denominator close to 0). It is detected from the exact ratio without building the oversized value, so the call costs no more than a regular call with the same coupon count. Under a fractional exponent a dirty price within 1e-30 relative of 1e20 is outside the guarantee; below 1e20 every output is rounded once from the exact value (integer exponents and the N = 1 formula are exact rationals).
- 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)
- `yield` (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})?$`
- `scale` (integer, optional): min 0; max 12
- `rounding` (one of "half-up", "half-even", "half-down", "up", "down", "ceiling", "floor", optional)

## Output

- `clean_price` (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 1200
- `accrued_days` (integer, required): min 0
- `days_to_next_coupon` (integer, required)
- `period_days` (string, required): pattern `^(0|[1-9][0-9]*)\.[0-9]{6}$`

## Limits

- max string bytes: 64
- max coupons: 1200

## Example

Request input:

```json
{
  "settlement": "2008-02-15",
  "maturity": "2017-11-15",
  "coupon_rate": "0.0575",
  "frequency": 2,
  "yield": "0.065",
  "basis": "30-360-us",
  "scale": 5
}
```

Response:

```json
{
  "result": {
    "clean_price": "94.63436",
    "dirty_price": "96.07186",
    "accrued_interest": "1.43750",
    "coupons_remaining": 20,
    "accrued_days": 90,
    "days_to_next_coupon": 90,
    "period_days": "180.000000"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "bond-price-from-yield",
  "version": "1.0.0",
  "input": {
    "settlement": "2008-02-15",
    "maturity": "2017-11-15",
    "coupon_rate": "0.0575",
    "frequency": 2,
    "yield": "0.065",
    "basis": "30-360-us",
    "scale": 5
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/bond-price-from-yield/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"settlement":"2008-02-15","maturity":"2017-11-15","coupon_rate":"0.0575","frequency":2,"yield":"0.065","basis":"30-360-us","scale":5}'
```

The machine-readable contract is at [/v1/tools/bond-price-from-yield/versions/1.0.0](/v1/tools/bond-price-from-yield/versions/1.0.0).

### CLI

```sh
node cli.mjs run bond-price-from-yield 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Bond yield from price](/tools/bond-yield-from-price): Yield to maturity of a fixed-coupon bond from its clean price, with accrued and dirty price (Excel YIELD / SIA).
- [Tbill yield convert](/tools/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](/tools/bond-duration-convexity): Macaulay and modified duration, convexity and DV01 of a fixed-coupon bond at a yield (Excel DURATION, MDURATION).
- [Cashflow npv](/tools/cashflow-npv): NPV of equally spaced cash flows, time-0 or Excel time-1, with inflow PV, outflow PV and profitability index.
- [Bond cashflow schedule](/tools/bond-cashflow-schedule): Coupon dates, coupons remaining, accrued days and accrued interest for a regular fixed-coupon bond (Excel COUP* rules).
- [Cashflow irr](/tools/cashflow-irr): IRR of equally spaced cash flows with every root reported, the chosen root named and no-solution cases signalled.
