Hi Kip,

I got  91.7021557489662  value in price variable and i call this function 
as per the parameter provided by you ie :  

Sub test()
    Call PRICE364("31-10-2012", "22/4/2013", 11.5, 10.293, 100, 2)
End Sub

Please check may be you the way you passing the parameter in it is wrong.

Regards
Prince


On Tuesday, December 11, 2012 2:49:41 PM UTC+5:30, kip wrote:
>
> Hi,
> I have the following macro which i am trying to get the price of a bond 
> but ends up giving me zero value. What could be the prblem?
>
> Function PRICE364(settlement As Date, maturity As Date, rate As Double, 
> yld As Double, redemption, frequency)
>
> 'Initialize Variables
>
> Dim COUPNCD As Date
> Dim COUPPCD As Date
>
> coup = 0
> cppayleft_exact = (maturity - settlement) / (364 / frequency)
> CPPAYLEFT = WorksheetFunction.RoundUp(cppayleft_exact, 0)
>
> mosToMat = (CPPAYLEFT - 1) * (12 / frequency)
> mosToMatprev = (CPPAYLEFT) * (12 / frequency)
> COUPNCD = DateAdd("m", -1 * mosToMat, maturity)
> COUPPCD = DateAdd("m", -1 * mosToMatprev, maturity)
>
> N = CPPAYLEFT
> A = (settlement - COUPPCD)
> k = 1
> e = 364 / frequency
> DCS = e - A
>
> yfactor = 1 + (yld / frequency)
>
> prin = redemption / (yfactor ^ (N - 1 + (DCS / e)))
>
> Do Until k = N + 1
>
> num = 100 * (rate / frequency)
> den = yfactor ^ (k - 1 + (DCS / e))
> coup = coup + (num / den)
>
> k = k + 1
>
> Loop
>
> acr = 100 * (rate / frequency) * (A / e)
>
> PRICE = prin + coup - acr
>
> End Function
>
> The bond details are as follows
> Settlement date 31-10-2012
> maturity date 22/4/2013
> coupon rate 11.5%
> Yield to maturity 10.293%
> Frequency 2
> Redemption is 100.
>
> The price i should be getting using actual/364 is 100.8238 but the above 
> macro is giving me zero. Any ideas where the problem is?
>
> Regards,
> Boreh
>

-- 
Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros?hl=en.


Reply via email to