NexusFi: Find Your Edge


Home Menu

 





How to calculate yield


Discussion in Treasury Notes and Bonds

Updated
    1. trending_up 4,461 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 2 attachments




 
Search this Thread

How to calculate yield

  #1 (permalink)
 timendaGain 
New York, NY
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES MES
Posts: 792 since Nov 2010
Thanks Given: 149
Thanks Received: 235

I’m trying to calculate the yield of notes and bonds in an excel spreadsheet. I can’t seem to get the calculated yield to match quotes I find online.

For example, I calculate a yield for the 10 year treasury at 2.32%, whilst Bloomberg quotes it at 2.61%
The formula that I use is one I find all over the web:

How to Calculate a Bond's Current [AUTOLINK]Yield[/AUTOLINK] | Chron.com

To arrive at 2.32% I have:

10 Year note price of 96 29.4/32 ( 96 and 29.4 32s ). This equates to 96.92 in decimal.

So now I have price 96.92.
Coupon ( or annual interest ): 2.25.

The formula is
Annual Interest = 2.25%
-----------------------
Current Price = 96.92

That gets me to a yield of 2.32%. Current quote is 2.61%

What am I missing? I attached the spreadsheet.

Attached Files
Elite Membership required to download: Bond Yield Calculator.xlsx
Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


It is more complicated than what you are trying to do.

You can not just divide the coupon by the price, that is a rough estimation.

Here are some of your mistakes :
1. the coupon is payable bi-annual, not annual
2. you forget the accrued interest
3. for the calculation of the accrued interest, you need to take into account the settlement date for accrual calculation
so the formulae is different for Monday versus a Friday
4. you can not calculate it linear, you need to calculate the polynomial, which turns it into a non linear problem.
Personally I calculate it in iterations until the error is sufficiently low (I get to the exact YTM (i have a Reuters, not a
Bloomberg, but the value is the same, as what you mentioned)

Took me few days to figure it out, posted the same question a while ago, nobody answered.

In order to talk the same vernacular, the yield on the Reuters/Bloomberg screens, is the YTM or Yield to Maturity.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 timendaGain 
New York, NY
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES MES
Posts: 792 since Nov 2010
Thanks Given: 149
Thanks Received: 235

Thanks for clearing that up. Yikes! I will try and figure this out.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863

OK, Here is some help :

Today accrual days is : 26+1 (settlement tomorrow)
Today accrual interest is : 0.167816

Annual Coupon : 2.25
6 month Coupon : 1.125

Settlement date : 14/03/2017

last coupon : 02/15/2017
next coupon 08/15/2017

coupon days : 181 (15/025/2017 -> 15/08/2017

coef : 27/181

YTM : 2.626

because :

96.909193 = (purchase + accrual) = polynomial with YTM = 2.626

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 timendaGain 
New York, NY
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES MES
Posts: 792 since Nov 2010
Thanks Given: 149
Thanks Received: 235


rleplae View Post
OK, Here is some help :

I’ve got it working now. I ended up using QuantLib to do it. ( Actually I used QLNet ). There are a lot of details as you mentioned and QuantLib has addressed all of these. Thank you for your help.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


timendaGain View Post
I’ve got it working now. I ended up using QuantLib to do it. ( Actually I used QLNet ). There are a lot of details as you mentioned and QuantLib has addressed all of these. Thank you for your help.

I couldn't make it work with QLnet, there was always a difference
At the end i wrote my own iterative process, to approximate the yield towards sufficient precision

Are you spot/on with Bloomberg/Reuters ?
or just happy with approximation ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 timendaGain 
New York, NY
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES MES
Posts: 792 since Nov 2010
Thanks Given: 149
Thanks Received: 235


rleplae View Post
I couldn't make it work with QLnet, there was always a difference
At the end i wrote my own iterative process, to approximate the yield towards sufficient precision

Are you spot/on with Bloomberg/Reuters ?
or just happy with approximation ?

"Nearly" spot on in my testing so far. Problem is that different quote providers aren't "spot on" with each other... at least not on websites which may have some latency ... therefore I can't tell from comparing to websites. But I'm within a hundredth of a percentage point.

I tested intra-day and also after close with market prices. I'm using websites to compare: MarketWatch and Bloomberg ( can't find the quote on Reuters )

Presently:
Market Watch: 2.417%
Me: 2.418%
Bloomberg: 2.42%

I struggled with quantlib a little. It was giving me "close" results but not perfect. Until I found an example that employs a solver. The solver uses a bisection algo to find the internal rate of return. Here is the complete listing of the program.

To get it to work for the 10 year treasury I changed the period type passed to the Schedule constructor to be Frequency.Semiannual.

I don't think I had to change anything else.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863

Did you test it on a Monday and on a Friday ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 timendaGain 
New York, NY
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES MES
Posts: 792 since Nov 2010
Thanks Given: 149
Thanks Received: 235



rleplae View Post
Did you test it on a Monday and on a Friday ?

If you can give me a quote of price and yield for a 10 year on a Monday or Friday then I can run a test now using the same date as the settlement date. I can't find historical prices for the cash note online... only historical yields. If not then I'll run a test on Friday and get back to you then.

Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on April 13, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts