## Calculating U.S. Treasury Notes Pricing

### 01/28/2024

A few years ago, I worked on a type that could process `double`

values received as real-time market data updates and helped to convert them to be displayed for humans on a UI.

The type was used to process market data updates of U.S. Treasury Notes. The pricing of U.S. Treasury Notes is detailed on the cmegroup site. In this post I will focus on the pricing of bond and note products while keeping futures aside.

The prices of these products are displayed in *fractions*. The price of such a product may look as `99-032`

. This means it is 99 full points plus 3/32s of a point plus 2/8 of 1/32s of a point. The last digit of the price can take up values of `0`

`2`

, `+`

and `6`

, where plus denotes 4/8 or 1/2.Hence `99-032`

equals 99 + 3/32 + 2/256 = 99.1015625. Note, that the last digit is always a multiple of 1/4th of a 1/32nd. Another example may be `100-23+`

which equals 100.734375. However, this post will focus on displaying such data, converting it from a `double`

such as 100.734375 to `100-23+`

.

A few years back .NET was less performant. In this post, I will revisit the original implementation as well as review 3 implementations I would consider building today to take advantage of the performance benefits of the modern .NET. Even the original implementation is significantly faster when run on .NET 8 due to the number of optimizations that have been built into the BCL and the JIT.