LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default yield code

I have code for calculating yield from Mangesh Yadav that I can't get to
equal excel's. Does anyone see anything obviously wrong here? I noticed
that he uses "compounding" and "frequency" as inputs, but they appear to be
the same thing. 9/12/05 settlement, 7/15/08 maturity, .06 rate, 95 price,
100 redemption, 2 frequency, 2 compounding should result in 7.9967%, but
this code yields 6.8387%. Assume 0 "basis" (30/360) Thanks, Mike Allen

Function mangeshprice(Settlement, Maturity, Rate, yield, Redemption,
Frequency, Compounding)


If Not (IsEmpty(Settlement) Or IsEmpty(Maturity)) Then

years = (Maturity - Settlement) / 365

If years < 0 Then
Application.StatusBar = "Maturity should be greater than settlement"
Exit Function
End If


' finding the PV of redemption or maturity value
pvRed = Redemption * (1 + yield / Compounding) ^ (-years * Compounding)


' finding the PV of coupon payments

Coupon = Redemption * Rate / Frequency
nosOfCoupons = Int(years * Frequency)
pvCoupon = 0

For i = 1 To nosOfCoupons

term = Coupon * (1 + yield / Compounding) ^ (-years * Compounding)
pvCoupon = pvCoupon + term

Next

mangeshprice = pvCoupon + pvRed

End If

End Function

Function mangeshyield(Settlement, Maturity, Rate, Price, Redemption,
Frequency, Compounding)

lowValue = -0.2
hiValue = 1
yield = 0.05

comp = mangeshprice(Settlement, Maturity, Rate, yield, Redemption,
Frequency, Compounding)

If Not IsEmpty(comp) Then

Do While (Abs(Price - comp) 0.001)
yield = (lowValue + hiValue) / 2
comp = mangeshprice(Settlement, Maturity, Rate, yield, Redemption,
Frequency, Compounding)
If (Price < comp) Then
lowValue = yield
Else
hiValue = yield
End If
i = i + 1
If (i 100) Then
Exit Function
End If
Loop

End If

mangeshyield = yield

End Function


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Yield vs. Yield to Maturity at low prices beariebird Excel Worksheet Functions 1 November 19th 09 08:50 PM
yield of a security Securities Auditor Excel Worksheet Functions 1 December 8th 06 07:40 PM
Yield rate Brad Excel Worksheet Functions 5 April 9th 05 01:22 AM
yield to call Dins95 Excel Discussion (Misc queries) 1 January 6th 05 02:36 AM
yield function mike allen[_2_] Excel Programming 9 December 31st 04 08:36 PM


All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"