Swap pricing is more about precision than complexity, which is how I soon had an API returning par rates and DV01 across 27 currencies.
Three weeks into my role at Actrix I was asked whether I could build a pricer for interest rate swaps. Having only graduated four weeks ago I said yes, because saying yes and then working it out is most of what a first job consists of.
A couple weeks later what exists is an API with two endpoints. The first returns the par rate for any swap you would like. The second returns DV01 for a single swap, denominated in whichever currency you ask for. To me, this had sounded beyond confusing at first, however I soon realised it’s about being precise rather than complex.
I made use of Claude throughout. It helped me with the more finicky bits through simple examples, and it was quick at the repetitive parts: schedule generation, curve interpolation, API wiring.
But AI could not tell me if the output was correct, so I took the slow and steady route. Price a swap, compare it against a known-correct market quote, check if the par rate matches to 9 d.p, and repeat, currency-by-currency and tenor-by-tenor, until the curve matched.
What is a swap pricer?
To understand a swap pricer we need to first know what a swap is. By CFTC’s own definition it’s pretty vague, so don’t get hung up on it. Two parties agree to exchange payments on the same notional, on the same schedule, for a fixed term. One pays a rate agreed on day one and the other pays whatever the market rate happens to be, reset at intervals. The notional is never exchanged; it exists to scale the payments. Tens of trillions of dollars of it are outstanding globally. This is all a swap is.
Like me, you might have thought pricing a swap meant forecasting where rates go. Luckily, all it means is finding the fixed rate that makes the swap worth exactly zero today, the par rate, using the market’s own current view of the future, embedded in a discount curve.

The worked example below assumes a single-curve swap, such as ESTR OIS, where the same curve is used both to discount and to project cash flows. Let be the discount factor for date
, and let the swap run from the effective date
to maturity
. The floating leg pays on dates
, and each period from
to
has length
in years. However, you must consider the currency’s day-count convention when calculating this length.
Actual/360 counts the real number of calendar days between the two dates and divides by 360:
(days here means an actual calendar count — 28, 30, 31, 92, whatever the calendar gives you — not a rounded number of months.) ESTR, the index in the example above, uses this on both legs.
Over that period, the curve implies a forward rate, which is just how much more a euro is worth at the start of the period than at the end, turned into an annual rate using whichever came out of the step above:
Each floating payment is that rate multiplied by the period length, discounted to today with . Add one of those up for every period and you get the floating leg’s value:
For a single-curve index like ESTR, almost all of that cancels out. Substitute back in and multiply through:
so every term in the sum is just one discount factor minus the next one. Notice that has actually vanished from this simplified form, which is a side effect of using the same curve for discounting and projecting. Add a run of these together and everything in the middle cancels, leaving only the very first and very last discount factor:
The fixed leg pays a constant rate instead of a forward rate, on its own payment dates
, with its own period lengths
.
needs the same treatment as
did, so run through whatever day-count convention applies to the fixed leg specifically, which is frequently not the same convention the floating leg uses. The fixed leg can also run on an entirely different payment schedule to the floating leg, which is why its dates and period lengths get their own letters even though the underlying idea, a period length, times a discount factor, is identical. Because
doesn’t change from payment to payment, it pulls straight outside the sum:
That sum on its own, the period length times discount factor, added up over the fixed leg’s dates, doesn’t involve at all. It’s called the annuity,
:
The par rate is whichever makes the two legs equal in value:

DV01 asks what happens to the swap’s value if the curve moves by one basis point. Every discount factor shifts down slightly:
with in years. This is a continuously compounded shift: it raises the rate implied by the curve by one basis point and applies it as continuous compounding over
years.
Recompute the floating leg and the annuity using in place of
, giving
and
. The swap’s value before and after the bump is:
DV01 is the difference between the two:

Where things get fiddly
Dates. Which days count as coupon dates. Whether a period is measured Actual/360, Actual/365 or 30/360. Whether the floating leg resets monthly, quarterly or semi-annually, and whether that lines up with the fixed leg. Whether a currency’s short-dated swaps pay one amount at maturity instead of coupons along the way. Whether your calendar knows the local public holidays or has fallen back to weekends-only.
Each of these is a fact you look up (in theory) rather than a problem you solve. It is here where you need to be meticulous as if you use the wrong conventions your answer isn’t going to be massively wrong; it will only be off by a few basis points.
For example I had these wrong at first:
- Mexican peso swaps discount on a different curve from the obvious default.
- Chinese yuan OIS pays quarterly at every tenor, with no short-end exception, unlike most currencies.
- Hungarian forint swaps use a day-count convention that sources had got wrong.
The only thing that caught these was a price that didn’t match the market.
Rigour
AI made writing and rewriting the code easy, which mattered, because I rewrote a lot of it. All the plumbing which would have taken me (a non-computer science grad) hours, was able to be done in minutes allowing me to focus on increasing accuracy instead.
Next Time
So that’s a simple swap pricer! I hope you will join me next time where I look at building forward rates and a discount curve from par rates. Subscribe to this blog to see it!


Leave a Reply