Thanks alot Prince. Much appreciated. Regards, Boreh
On 13 December 2012 11:59, Prince <prince141...@gmail.com> wrote: > Hi Kip, > > Just copy this function and paste it in your workbook. The bold one last > line i have updated into this. > > 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) > > *PRICE364 = prin + coup - acr* > > End Function > > > Regards > Prince > > > On Thursday, December 13, 2012 12:54:42 PM UTC+5:30, kip wrote: > >> Hi expersts, >> I am trying to run the attached macro to get price of a bond. Please >> assist me get to know what i am doing wrong. Its not giving me any value, >> did i miss a step? >> >> Regards, >> Boreh >> >> >> On 11 December 2012 15:00, Robinson Boreh <rbo...@gmail.com> wrote: >> >>> Hi Prince, >>> Thanks for your feedback. >>> Attached is an excel sheet with the macro and am getting zero....did i >>> do it wrong? >>> >>> Thanks and regards, >>> Boreh >>> >>> >>> On 11 December 2012 14:27, Prince <prince...@gmail.com> wrote: >>> >>>> 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(**cppa**yleft_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 <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-...@googlegroups.com. >>>> To unsubscribe from this group, send email to excel-macros...@** >>>> googlegroups.com. >>>> >>>> Visit this group at >>>> http://groups.google.com/**group/excel-macros?hl=en<http://groups.google.com/group/excel-macros?hl=en> >>>> . >>>> >>>> >>>> >>> >>> >> -- > 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. > > > -- 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.