Skip to content

Fixed income

Bond convexity

Convexity of a fixed-coupon bond from its yield, effective convexity off a spot curve, and the duration-and-convexity price-change estimate.

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

Formula

C=1P∂2P∂y2=1Pf2(1+y/f)2∑jtj(tj+1)CFj(1+y/f)tj\begin{aligned} C &= \frac{1}{P}\frac{\partial^2 P}{\partial y^2} \\ &= \frac{1}{P f^2 (1 + y/f)^2}\sum_j t_j (t_j + 1) \frac{CF_j}{(1 + y/f)^{t_j}} \end{aligned}Ceff=P(z−h)+P(z+h)−2P(z)P(z)h2C_{\mathrm{eff}} = \frac{P(z - h) + P(z + h) - 2 P(z)}{P(z) h^2}ΔPP≈−Dmod Δy+12C (Δy)2\frac{\Delta P}{P} \approx -D_{\mathrm{mod}}\,\Delta y + \tfrac{1}{2} C\,(\Delta y)^2

Where

CC
Convexity, in years squared convexity
PP
Full price of the bond full_price
yy
Yield to maturity per year, compounded at the coupon frequency yield_to_maturity
ff
Coupons per year frequency
tjt_j
Time to cash flow j, in coupon periods from settlement
CFjCF_j
The j-th remaining cash flow
CeffC_{\mathrm{eff}}
Effective convexity effective_convexity
P(z)P(z)
The price off the spot curve z
zz
The spot curve curve_rates
hh
The parallel shift of the curve, up and down bump
Δy\Delta y
The change in yield yield_change
DmodD_{\mathrm{mod}}
Modified duration modified_duration
ΔPP\frac{\Delta P}{P}
The estimated relative change in price estimated_change

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

Convexity from the yield (analytical): 12 inputs
Inputs of the calculation analytical
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
CalculationcalculationtextConvexity from the yield
Yield to maturityyield_to_maturityrate · [-0.1, 1]Yield to maturity per year, compounded at the coupon frequency
Effective convexity off a spot curve (effective): 14 inputs
Inputs of the calculation effective
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
Curve tenorscurve_tenorsyears (array) · length min 1, max 100; each (0, 100]Tenors of the spot curve's nodes, in years, increasing
Curve ratescurve_ratesrate (array) · length min 1, max 100; each [-0.1, 1]Spot rate at each tenor, compounded at the coupon frequency; linear between nodes and flat beyond them
Bumpbumprate · [1e-06, 0.01]Shift of the curve up and down for the central difference
CalculationcalculationtextEffective convexity off a spot curve
Duration and convexity price-change estimate (price_change): 13 inputs
Inputs of the calculation price_change
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
CalculationcalculationtextDuration and convexity price-change estimate
Yield to maturityyield_to_maturityrate · [-0.1, 1]Yield to maturity per year, compounded at the coupon frequency
Yield changeyield_changerate · [-0.02, 0.02]Change in the yield, in decimals (0.01 is 100 basis points)

Outputs

Convexity from the yield (analytical): 3 outputs
Outputs of the calculation analytical
NameDescription
CalculationcalculationtextConvexity from the yield
Convexityconvexityratio · [0, 100000]Second derivative of the price in the yield, over the price (years squared)
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)
Effective convexity off a spot curve (effective): 3 outputs
Outputs of the calculation effective
NameDescription
CalculationcalculationtextEffective convexity off a spot curve
Effective convexityeffective_convexityratio · [-100000, 100000](P_down + P_up - 2 P) / (P bump^2), in years squared
Full pricefull_pricemoney · [0, 1e+15]Full (dirty) price at settlement, of the face value held (per 100 by default)
Duration and convexity price-change estimate (price_change): 8 outputs
Outputs of the calculation price_change
NameDescription
CalculationcalculationtextDuration and convexity price-change estimate
Modified durationmodified_durationyears · [0, 200]Modified duration at the yield
Convexityconvexityratio · [0, 100000]Convexity at the yield (years squared)
Duration effectduration_effectratio · [-1000, 1000]-D_mod x the yield change
Convexity effectconvexity_effectratio · [-1000, 1000]Half the convexity x the yield change squared
Estimated changeestimated_changeratio · [-1000, 1000]Relative price change estimated by duration and convexity
Actual changeactual_changereturn · [-1, 100]Relative change in the full price on repricing
Approximation errorapproximation_errorratio · [-1000, 1000]Actual change less the estimate

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 convexity of 24.4724 years squared.

Example five_year_annual. Inputs:

{
  "calculation": "analytical",
  "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:

{
  "calculation": "analytical",
  "convexity": 24.472405046329648,
  "full_price": 95.67052332936917
}

Assumptions

  • Times t_j are counted in coupon periods from settlement, as in fixed_income.bond_pricing; the yield compounds at the coupon frequency, under street convention.
  • The spot curve is linear in its rates between nodes and flat beyond them, and is shifted in parallel.
  • The bond has no embedded option, so its cash flows do not move with rates.

Limitations

  • Effective convexity is a second difference: its rounding error grows as the bump shrinks, and its truncation error as it grows.
  • Yield changes are limited to 200 basis points either way.

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. Fabozzi, F. J. (2005). Fixed Income Mathematics: Analytical and Statistical Techniques, 4th ed. McGraw-Hill. https://openlibrary.org/isbn/9780071460736 (Chapter 13 (combining duration and convexity to measure price volatility)). ISBN 9780071460736
  2. QuantLib (2026). BondFunctions. QuantLib 1.43 reference. https://www.quantlib.org/reference/struct_quant_lib_1_1_bond_functions.html (BondFunctions::convexity)

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.convexity/run
MCP tool
run_model with the model's id, fixed_income.convexity. Connect an assistant
Command line
pyeconomics models run fixed_income.convexity --help

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

Python
import pyeconomics

inputs = {
    "calculation": "analytical",
    "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.convexity", inputs)
print(result.to_json())
Command line
pyeconomics models run fixed_income.convexity --inputs - <<'JSON'
{
  "calculation": "analytical",
  "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