Skip to content

Fixed income

Bond price and yield

Full and flat price and accrued interest of a fixed-coupon bond from its yield, and its yield to maturity, to a call and to worst from its price.

Model id
fixed_income.bond_pricing, version 2
Domain
Fixed income
Evidence
standard
Cost class
light: A short numerical method; a hosted run may take up to 10 seconds.

Formula

Pfull=∑jCFj(1+y/f)w+j−1P_{\mathrm{full}} = \sum_{j} \frac{CF_j}{(1 + y/f)^{w + j - 1}}Pfulltreasury=∑jCFj(1+y/f)−(j−1)1+wy/fP_{\mathrm{full}}^{\mathrm{treasury}} = \frac{\sum_j CF_j (1 + y/f)^{-(j - 1)}}{1 + w y / f}AI=F c τ(tprev,tsettle),Pflat=Pfull−AIAI = F\,c\,\tau(t_{\mathrm{prev}}, t_{\mathrm{settle}}), \quad P_{\mathrm{flat}} = P_{\mathrm{full}} - AIYTW=min⁡(YTM,min⁡kYTCk)YTW = \min\left(YTM, \min_k YTC_k\right)

Where

PfullP_{\mathrm{full}}
Full (dirty) price at settlement full_price
CFjCF_j
The j-th remaining cash flow: a coupon, or the last coupon and the redemption
yy
Yield to maturity per year, compounded at the coupon frequency yield_to_maturity
ff
Coupons per year frequency
ww
The fraction of a coupon period from settlement to the next coupon
AIAI
Accrued interest accrued_interest
FF
Face value face_value
cc
Annual coupon rate coupon_rate
τ(tprev,tsettle)\tau(t_{\mathrm{prev}}, t_{\mathrm{settle}})
The year fraction from the previous coupon date to settlement, by the day count
PflatP_{\mathrm{flat}}
Flat (clean) price: the full price less accrued interest flat_price
YTWYTW
Yield to worst yield_to_worst
YTMYTM
Yield to maturity yield_to_maturity
YTCkYTC_k
Yield to the k-th call date yield_to_call

Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.

Variables

Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.

Inputs

Full and flat price from a yield (price_from_yield): 13 inputs
Inputs of the calculation price_from_yield
NameDescription
SettlementsettlementdateSettlement date: the price is for this date
MaturitymaturitydateMaturity date: the last coupon and redemption (for a bond with n years left, n years after settlement)
Coupon ratecoupon_raterate · [0, 1]Annual coupon rate, paid in equal parts
FrequencyfrequencytextCoupons per year (also the yield's compounding)
Day countday_counttextDay count for accrued interest and stubs
Face valueface_valuemoney · [0.01, 1e+09]Face (par) value held: at 100, a price is per 100 of face value
Redemptionredemptionmoney · [1, 200]Amount repaid at maturity per 100 of face value
Issue dateissue_datedateDate interest starts to accrue, when the first coupon period is irregular; omitted (null) for a regular schedule
First periodfirst_periodtextWhether an irregular first period ends at the first coupon date after the issue date (short) or at the one after that (long)
End of monthend_of_monthflagKeep coupon dates at month ends when the maturity is one
CalculationcalculationtextFull and flat price from a yield
Yield to maturityyield_to_maturityrate · [-0.1, 1]Yield to maturity per year, compounded at the coupon frequency
ConventionconventiontextDiscounting over the first fraction of a period: compound (street) or simple interest (treasury, 31 CFR Part 356 Appendix B)
Yield to maturity from a price (yield_from_price): 14 inputs
Inputs of the calculation yield_from_price
NameDescription
SettlementsettlementdateSettlement date: the price is for this date
MaturitymaturitydateMaturity date: the last coupon and redemption (for a bond with n years left, n years after settlement)
Coupon ratecoupon_raterate · [0, 1]Annual coupon rate, paid in equal parts
FrequencyfrequencytextCoupons per year (also the yield's compounding)
Day countday_counttextDay count for accrued interest and stubs
Face valueface_valuemoney · [0.01, 1e+09]Face (par) value held: at 100, a price is per 100 of face value
Redemptionredemptionmoney · [1, 200]Amount repaid at maturity per 100 of face value
Issue dateissue_datedateDate interest starts to accrue, when the first coupon period is irregular; omitted (null) for a regular schedule
First periodfirst_periodtextWhether an irregular first period ends at the first coupon date after the issue date (short) or at the one after that (long)
End of monthend_of_monthflagKeep coupon dates at month ends when the maturity is one
CalculationcalculationtextYield to maturity from a price
Pricepricemoney · (0, 1e+15]Price of the face value held (per 100 by default)
Price typeprice_typetextWhether the price excludes (flat) or includes (full) accrued interest
ConventionconventiontextDiscounting over the first fraction of a period: compound (street) or simple interest (treasury, 31 CFR Part 356 Appendix B)
Yield to a call date (yield_to_call): 16 inputs
Inputs of the calculation yield_to_call
NameDescription
SettlementsettlementdateSettlement date: the price is for this date
MaturitymaturitydateMaturity date: the last coupon and redemption (for a bond with n years left, n years after settlement)
Coupon ratecoupon_raterate · [0, 1]Annual coupon rate, paid in equal parts
FrequencyfrequencytextCoupons per year (also the yield's compounding)
Day countday_counttextDay count for accrued interest and stubs
Face valueface_valuemoney · [0.01, 1e+09]Face (par) value held: at 100, a price is per 100 of face value
Redemptionredemptionmoney · [1, 200]Amount repaid at maturity per 100 of face value
Issue dateissue_datedateDate interest starts to accrue, when the first coupon period is irregular; omitted (null) for a regular schedule
First periodfirst_periodtextWhether an irregular first period ends at the first coupon date after the issue date (short) or at the one after that (long)
End of monthend_of_monthflagKeep coupon dates at month ends when the maturity is one
CalculationcalculationtextYield to a call date
Pricepricemoney · (0, 1e+15]Price of the face value held (per 100 by default)
Price typeprice_typetextWhether the price excludes (flat) or includes (full) accrued interest
Call datecall_datedateCoupon date on which the bond is called
Call pricecall_pricemoney · [1, 200]Amount paid on the call, per 100 of face value
ConventionconventiontextDiscounting over the first fraction of a period: compound (street) or simple interest (treasury, 31 CFR Part 356 Appendix B)
Lowest yield over the calls and maturity (yield_to_worst): 16 inputs
Inputs of the calculation yield_to_worst
NameDescription
SettlementsettlementdateSettlement date: the price is for this date
MaturitymaturitydateMaturity date: the last coupon and redemption (for a bond with n years left, n years after settlement)
Coupon ratecoupon_raterate · [0, 1]Annual coupon rate, paid in equal parts
FrequencyfrequencytextCoupons per year (also the yield's compounding)
Day countday_counttextDay count for accrued interest and stubs
Face valueface_valuemoney · [0.01, 1e+09]Face (par) value held: at 100, a price is per 100 of face value
Redemptionredemptionmoney · [1, 200]Amount repaid at maturity per 100 of face value
Issue dateissue_datedateDate interest starts to accrue, when the first coupon period is irregular; omitted (null) for a regular schedule
First periodfirst_periodtextWhether an irregular first period ends at the first coupon date after the issue date (short) or at the one after that (long)
End of monthend_of_monthflagKeep coupon dates at month ends when the maturity is one
CalculationcalculationtextLowest yield over the calls and maturity
Pricepricemoney · (0, 1e+15]Price of the face value held (per 100 by default)
Price typeprice_typetextWhether the price excludes (flat) or includes (full) accrued interest
Call datescall_datesdate (array) · length min 1, max 50Coupon dates on which the bond may be called
Call pricescall_pricesmoney (array) · length min 1, max 50; each [1, 200]Amount paid on each call, per 100 of face value
ConventionconventiontextDiscounting over the first fraction of a period: compound (street) or simple interest (treasury, 31 CFR Part 356 Appendix B)

Outputs

Full and flat price from a yield (price_from_yield): 6 outputs
Outputs of the calculation price_from_yield
NameDescription
CalculationcalculationtextFull and flat price from a yield
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)
Flat priceflat_pricemoney · [-1e+15, 1e+15]Flat (clean) price, of the face value held (per 100 by default): the full price less accrued interest
Accrued interestaccrued_interestmoney · [0, 2e+09]Interest accrued up to settlement
Next coupon datenext_coupon_datedateFirst payment after settlement
Paymentspaymentscount · [1, 1201]Payments remaining after settlement
Yield to maturity from a price (yield_from_price): 5 outputs
Outputs of the calculation yield_from_price
NameDescription
CalculationcalculationtextYield to maturity from a price
Yield to maturityyield_to_maturityrate · [-0.1, 1]Yield to maturity that gives the price
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)
Flat priceflat_pricemoney · [-1e+15, 1e+15]Flat (clean) price, of the face value held (per 100 by default): the full price less accrued interest
Accrued interestaccrued_interestmoney · [0, 2e+09]Interest accrued up to settlement
Yield to a call date (yield_to_call): 3 outputs
Outputs of the calculation yield_to_call
NameDescription
CalculationcalculationtextYield to a call date
Yield to callyield_to_callrate · [-0.1, 1]Yield if the bond is called on the call date
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)
Lowest yield over the calls and maturity (yield_to_worst): 5 outputs
Outputs of the calculation yield_to_worst
NameDescription
CalculationcalculationtextLowest yield over the calls and maturity
Yield to worstyield_to_worstrate · [-0.1, 1]Lowest of the yield to maturity and to each call
Worst dateworst_datedateCall or maturity date that gives it
Yield to maturityyield_to_maturityrate · [-0.1, 1]Yield to maturity
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)

Calculator

Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.

Loading the calculator…

Worked example

A five-year bond with a 4% annual coupon at a 5% yield, settled on a coupon date: a price of 95.6705 per 100 of face value.

Example five_year_annual. Inputs:

{
  "calculation": "price_from_yield",
  "convention": "street",
  "coupon_rate": 0.04,
  "day_count": "act_act_icma",
  "end_of_month": true,
  "face_value": 100,
  "first_period": "short",
  "frequency": "annual",
  "issue_date": null,
  "maturity": "2031-01-15",
  "redemption": 100,
  "settlement": "2026-01-15",
  "yield_to_maturity": 0.05
}

Outputs:

{
  "accrued_interest": 0,
  "calculation": "price_from_yield",
  "flat_price": 95.67052332936917,
  "full_price": 95.67052332936917,
  "next_coupon_date": "2027-01-15",
  "payments": 5
}

Assumptions

  • Coupons are fixed and paid f times a year on dates stepped back from the maturity; a regular coupon is c/f of the face value, and an irregular first coupon is the day count's fraction of it.
  • The yield compounds at the coupon frequency. Street convention discounts the fraction w of a period to the first payment by (1 + y/f)^w; the treasury convention uses simple interest, 1 + w y/f, as 31 CFR Part 356 Appendix B does.
  • Accrued interest runs from the previous coupon date, or from the issue date in an irregular first period, under the bond's day count.
  • A call is exercised on a coupon date at the call price per 100 of face value, after that date's coupon is paid.
  • Payment dates are not adjusted for business days.

Limitations

  • Yields are solved in [-0.1, 1]. A price no yield in that range gives raises DomainError, including in yield_to_worst a call whose yield is below -0.1; a call whose yield is above 1 is skipped there, with a warning.
  • Only a first period may be irregular; odd last periods, floating or step-up coupons, sinking funds, and ex-dividend periods are out of scope.
  • Day counts are ACT/ACT (ICMA), US 30/360 and 30E/360. A regular coupon is c/f, and payments after the first are whole periods apart, even where a 30/360 count of a period touching a February month end is not 360/f; QuantLib, which sums each period's 30/360 fraction, differs there.

Evidence

Status: standard. Textbook consensus, such as bond duration or the CAPM formula.

Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).

Syllabus

The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.

Citations

  1. US Department of the Treasury (2022). 31 CFR Part 356, Appendix B: Formulas and Tables. Electronic Code of Federal Regulations. https://www.ecfr.gov/current/title-31/subtitle-B/chapter-II/subchapter-B/part-356/appendix-Appendix%20B%20to%20Part%20356 (Section I (computation of interest) and section II, paragraphs A-G (non-indexed yield to price, with examples))
  2. Fabozzi, F. J. (2005). Fixed Income Mathematics: Analytical and Statistical Techniques, 4th ed. McGraw-Hill. https://openlibrary.org/isbn/9780071460736 (Chapter 5 (the price of a bond, between coupon dates included)). ISBN 9780071460736
  3. QuantLib (2026). BondFunctions and FixedRateBond. QuantLib 1.43 reference. https://www.quantlib.org/reference/struct_quant_lib_1_1_bond_functions.html (BondFunctions::cleanPrice, dirtyPrice, accruedAmount and yield)

Changelog

  • Version 1: First version.
  • Version 2: Correct US 30/360 long-stub accrual and discount times (#89).

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/fixed_income.bond_pricing/run
MCP tool
fixed_income_bond_pricing, or run_model with the model's id; both give the same result. Connect an assistant
Command line
pyeconomics models run fixed_income.bond_pricing --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "calculation": "price_from_yield",
    "convention": "street",
    "coupon_rate": 0.04,
    "day_count": "act_act_icma",
    "end_of_month": True,
    "face_value": 100,
    "first_period": "short",
    "frequency": "annual",
    "issue_date": None,
    "maturity": "2031-01-15",
    "redemption": 100,
    "settlement": "2026-01-15",
    "yield_to_maturity": 0.05,
}
result = pyeconomics.run("fixed_income.bond_pricing", inputs)
print(result.to_json())
Command line
pyeconomics models run fixed_income.bond_pricing --inputs - <<'JSON'
{
  "calculation": "price_from_yield",
  "convention": "street",
  "coupon_rate": 0.04,
  "day_count": "act_act_icma",
  "end_of_month": true,
  "face_value": 100,
  "first_period": "short",
  "frequency": "annual",
  "issue_date": null,
  "maturity": "2031-01-15",
  "redemption": 100,
  "settlement": "2026-01-15",
  "yield_to_maturity": 0.05
}
JSON