Where you are. You have a bond’s schedule and the machinery to move any payment to today. Put them together and you can price a bond: discount every payment in the array and add them up. This lesson does that, then does the more useful thing - running the conversion backwards - and in the process explains the single most repeated sentence in finance, which is that when rates go up, bond prices go down.
Yesterday’s bond, in this morning’s market
You hold a five-year bond paying a 4% coupon. You bought it at its face value of 100, because when it was issued 4% was what the market paid for that kind of promise.
Overnight, rates move. New bonds of the same kind, from the same issuer, are being issued at 6%.
You want to sell. Your bond still pays 4 a year, exactly as promised, and still returns 100 at the end. Nothing about it has changed. But a buyer comparing your bond to a new one has an obvious question: why would anyone take 4 a year from you when they can have 6 from the bond issued this morning?
There is exactly one thing you can adjust. Not the coupon, which is fixed to the face. Not the maturity. Only the price. You must sell for less than 100, and the amount less is precisely the amount that makes your smaller payments add up to the same return as the new bond’s larger ones.
The idea in one paragraph
A bond’s price and its yield are two ways of stating one fact, joined by present value. Given a yield, the price is mechanical: discount every promised payment at that yield and sum them. Given a price, the yield is the rate that would make that sum come out to the price, and because no closed-form inverse exists for a general bond, you find it by searching - guess a rate, price it, adjust, repeat. The relationship runs one way only: raise the yield and every payment is discounted harder, so the price falls, always, for every bond. That is the seesaw, and it is not a market convention or a behavioural quirk. It is division.
Forwards: price from yield
Discount each payment in the array at the yield and add. Three things fall out immediately, and the exercise asserts all three.
Discount a 4% bond at 4% and you get exactly 100. That is not a coincidence: the coupon is doing precisely the work the discount rate asks of it, so every payment’s present value lines up to par.
Discount the same bond at 6% and you get less than 100, which is your seller’s problem from the hook, quantified. Discount it at 2% and you get more than 100, because now your old bond pays better than what is on offer and buyers will compete for it.
Backwards: yield from price
The useful direction is the other one, because the market quotes prices. Somebody offers you a bond at 92.40; what return does that represent?
There is no formula. A bond’s price is a sum of terms with the unknown in several different powers, and for the general case it cannot be rearranged. So you search instead: bracket the answer between a rate that is obviously too low and one obviously too high, take the midpoint, price it, and keep whichever half still contains the target. Repeat until the bracket is narrow enough to stop caring.
This works, and works reliably, for exactly one reason: price falls monotonically as yield rises. Because the relationship never turns around, a midpoint that prices too high tells you unambiguously which half to discard. The seesaw is not just the lesson’s headline; it is the property that makes the solver correct.
Check yourself
1. Rates rise and your bond’s price falls. Nothing about the bond changed. What actually made it worth less?
Its payments are now being compared against better alternatives, so a buyer will only take them at a discount deep enough to match the new return. Mechanically, every promised payment is being divided by a larger number, so the sum of their present values is smaller. The bond is unchanged; the rate everything is measured against moved.
2. A 4% bond prices at exactly 100 when discounted at 4%. Why is that not a coincidence?
Because a bond priced at face is one where the coupon exactly compensates for the time value at that rate: each payment’s present value works out so the total is the face. When the discount rate equals the coupon rate, the two effects cancel by construction, which is why bonds are issued at a coupon close to prevailing rates.
3. Why does recovering the yield from a price need a search rather than a formula?
Because the unknown appears in several different powers across the sum, so the equation cannot be rearranged for it in general. A search sidesteps the algebra entirely by evaluating the forward direction repeatedly, which is cheap and exact enough.
4. The solver keeps whichever half of the bracket still contains the target price. What property of the price-yield relationship makes that step valid?
That price falls monotonically as yield rises. Because the relationship never reverses, a midpoint priced above the target proves the true yield is higher and the lower half can be discarded without risk. Without monotonicity the halving step could throw away the answer.
Do this
Build both directions and prove they invert.
python3 code/price_yield.py
The starter provides yield_to_price and leaves you price_to_yield, the bisection. The assertions check that a 4% bond at a 4% yield prices at par, that the seesaw holds in both directions, and that a hundred seeded bonds survive a full round trip with a worst error under 1e-8. Success prints the worst error and the line:
quoting the price and quoting the yield say the same thing; the yield is just the price expressed as what you will earn
The completed version is in solutions/price_yield.py.
What you can now do. You can convert freely between a bond’s price and its yield, and explain the seesaw as division rather than folklore. What you cannot yet do is answer the question a holder actually asks, which is not “what is it worth at this yield” but “how much will this hurt if rates move a point”. That is a sensitivity, and the next lesson measures it.