{"id":"bond-price-from-yield","version":"1.0.0","description":"Clean price, dirty price and accrued interest per 100 of a fixed-coupon bond from its yield (Excel PRICE, SIA).","supported_operations":["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","מחיר אגרת חוב לפי תשואה לפדיון"],"unsupported_operations":["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"],"semantics":["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."],"limits":{"max_string_bytes":64,"max_coupons":1200},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["settlement","maturity","coupon_rate","frequency","yield"],"properties":{"settlement":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$","maxLength":10},"maturity":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$","maxLength":10},"coupon_rate":{"type":"string","pattern":"^(0|[1-9][0-9]{0,19})(\\.[0-9]{1,20})?$","maxLength":64},"frequency":{"type":"integer","enum":[1,2,4,12]},"basis":{"type":"string","enum":["30-360-us","act-act","act-360","act-365f","30e-360"]},"yield":{"type":"string","pattern":"^-?(0|[1-9][0-9]{0,19})(\\.[0-9]{1,20})?$","maxLength":64},"redemption":{"type":"string","pattern":"^(0|[1-9][0-9]{0,19})(\\.[0-9]{1,20})?$","maxLength":64},"scale":{"type":"integer","minimum":0,"maximum":12},"rounding":{"type":"string","enum":["half-up","half-even","half-down","up","down","ceiling","floor"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["clean_price","dirty_price","accrued_interest","coupons_remaining","accrued_days","days_to_next_coupon","period_days"],"properties":{"clean_price":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$"},"dirty_price":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$"},"accrued_interest":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$"},"coupons_remaining":{"type":"integer","minimum":1,"maximum":1200},"accrued_days":{"type":"integer","minimum":0},"days_to_next_coupon":{"type":"integer"},"period_days":{"type":"string","pattern":"^(0|[1-9][0-9]*)\\.[0-9]{6}$"}}},"examples":[{"input":{"settlement":"2008-02-15","maturity":"2017-11-15","coupon_rate":"0.0575","frequency":2,"yield":"0.065","basis":"30-360-us","scale":5},"output":{"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"}},{"input":{"settlement":"2020-05-15","maturity":"2030-05-15","coupon_rate":"0.05","frequency":2,"yield":"0.06"},"output":{"clean_price":"92.561263","dirty_price":"92.561263","accrued_interest":"0.000000","coupons_remaining":20,"accrued_days":0,"days_to_next_coupon":180,"period_days":"180.000000"}},{"input":{"settlement":"2022-08-01","maturity":"2022-11-15","coupon_rate":"0.06","frequency":2,"yield":"0.05","redemption":"100","scale":6},"output":{"clean_price":"100.266740","dirty_price":"101.533406","accrued_interest":"1.266667","coupons_remaining":1,"accrued_days":76,"days_to_next_coupon":104,"period_days":"180.000000"}}],"execute_url":"/v1/tools/bond-price-from-yield/versions/1.0.0/execute"}