I was hoping you folks could help me out , as i dont know peoole who are familiar with quantlib ,I checked an example out and i wrote down a code in VS2010 C++ and boost + quanlib.
I have attached the code in a noted pad unfortunately i am not getting the required answer , hope you could help me out Now i have the following requirement : Current Price = 90 Par Value = 100 Coupon Rate = 5 % Years to maturity = 1 From the above data an online calculator calculates the Yield to maturity to be = 16.667 However the program i wrote gives 1.769. :( The code i wrote is attached with this email , i dont know where i am going wrong , could you kindly go through the program and let me know what i am doing wrong , i need to readjust the above mentioned program to display 16.6... something... Hope you could help me out... I have used the calculator at http://www.investopedia.com/calculator/AOYTM.aspx with the values 100 90 5 1 (select Annually) and it gives 16.67 and thats what i want. I have emailed you the code i am using on the notepad file... Plz take some time to go through it. I bet i must have made a very silly mistake... Thanks again |
I did attach the code file but it didnt get emailed... dont know why , I am reattaching the file again
Code.txt |
I know poertions of the code has been commented an awful lot so plz bare with me...
Actually i am really new to quantlib so this was just as desperate feeble attempt
|
In reply to this post by johnacandy
Try setting the evaluation date at a
global level… using Settings::instance().evaluationDate() = Then let us know what the result is. From:
Hayyan Rafiq [mailto:[hidden email]]
------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
i am currently trying to set
Settings::instance().evaluationDate() = ?? which date should i insert ? 15,June,2010 or 15,June,2011 as I have set the duration to 1 year.. ??
|
1 year before maturity... so in this case, 15 June 2010
-----Original Message----- From: johnacandy [mailto:[hidden email]] Sent: 18 October 2010 16:33 To: [hidden email] Subject: Re: [Quantlib-users] Calculating yield to maturity , incorrect answer ? why ? i am currently trying to set Settings::instance().evaluationDate() = ?? which date should i insert ? 15,June,2010 or 15,June,2011 as I have set the duration to 1 year.. ?? Simon Ibbotson-2 wrote: > > Try setting the evaluation date at a global level... using > Settings::instance().evaluationDate() = > > > > Then let us know what the result is. > > > > ________________________________ > > From: Hayyan Rafiq [mailto:[hidden email]] > Sent: 18 October 2010 15:53 > To: Simon Ibbotson > Subject: RE: [Quantlib-users] Calculating yield to maturity , > answer ? why ? > > > > > >> Subject: RE: [Quantlib-users] Calculating yield to maturity , > incorrect answer ? why ? >> Date: Mon, 18 Oct 2010 15:46:35 +0100 >> From: [hidden email] >> To: [hidden email] >> >> Attaching the code would be useful... >> >> -----Original Message----- >> From: johnacandy [mailto:[hidden email]] >> Sent: 18 October 2010 15:42 >> To: [hidden email] >> Subject: [Quantlib-users] Calculating yield to maturity , incorrect >> answer ? why ? >> >> >> I was hoping you folks could help me out , as i dont know peoole who > are >> familiar with quantlib ,I checked an example out and i wrote down a > code >> in >> VS2010 C++ and boost + quanlib. >> I have attached the code in a noted pad unfortunately i am not >> getting the required answer , hope you could help me out >> >> Now i have the following requirement : >> >> Current Price = 90 >> Par Value = 100 >> Coupon Rate = 5 % >> Years to maturity = 1 >> >> >From the above data an online calculator calculates the Yield to >> maturity to >> be = 16.667 >> >> However the program i wrote gives 1.769. :( >> >> The code i wrote is attached with this email , i dont know where i am >> going >> wrong , could you kindly go through the program and let me know what >> am >> doing wrong , i need to readjust the above mentioned program to > display >> 16.6... something... Hope you could help me out... >> >> I have used the calculator at >> http://www.investopedia.com/calculator/AOYTM.aspx >> with the values >> 100 >> 90 >> 5 >> 1 >> (select Annually) >> and it gives 16.67 >> and thats what i want. >> I have emailed you the code i am using on the notepad file... Plz >> some >> time to go through it. I bet i must have made a very silly mistake... >> Thanks again >> -- >> View this message in context: >> > http://old.nabble.com/Calculating-yield-to-maturity-%2C-incorrect-answer >> ---why---tp29991145p29991145.html >> Sent from the quantlib-users mailing list archive at Nabble.com. >> >> >> > ------------------------------------------------------------------------ >> ------ >> Download new Adobe(R) Flash(R) Builder(TM) 4 >> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly >> Flex(R) Builder(TM)) enable the development of rich applications that >> run >> across multiple browsers and platforms. Download your free trials > today! >> http://p.sf.net/sfu/adobe-dev2dev >> _______________________________________________ >> QuantLib-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> >> This communication and any attachments contains information which is > confidential and may be subject to legal privilege. It is for intended > recipients only. If you are not the intended recipient you must not > copy, distribute, publish, rely on or otherwise use it without our > consent. Some of our communications may contain confidential > which it could be a criminal offence for you to disclose or use without > authority. If you have received this email in error please notify > [hidden email] immediately and delete the email from your > computer. >> >> The FSA reserves the right to monitor all email communications for > compliance with legal, regulatory and professional standards. >> This email is not intended to nor should it be taken to create any > legal relations or contractual relationships. This email has originated > from >> >> The Financial Services Authority (FSA) >> 25 The North Colonnade, >> Canary Wharf, >> London >> E14 5HS >> United Kingdom >> >> Registered as a Limited Company in England and Wales No.1920623. >> Registered Office as above >> >> Switchboard: 020 7066 1000 >> Web Site: http://www.fsa.gov.uk >> ***************************************************************** >> > > > ------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > -- View this message in context: http://old.nabble.com/Calculating-yield-to-maturity-%2C-incorrect-answer ---why---tp29991145p29991643.html Sent from the quantlib-users mailing list archive at Nabble.com. ------------------------------------------------------------------------ ------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
So i made the changes as I was told which were
Settings::instance().evaluationDate()= bondDatedDate; //which is (15,June,2010) and made certain the Redemption was = 100.0 and i got an output of 5.667 which unfortunately is still not correct , its suppose to be 16.6 I have attached the cleaned up remodified final code at Code.txt hope you guys could take a look at the code and tell me what I am doing wrong. As i already mentioned I have used the calculator at http://www.investopedia.com/calculator/AOYTM.aspx with the values 100 90 5 1 and it gives 16.67 and this is the same answer that i want. I would be really grateful if any one could help me out..Thanks again...
|
On Oct 18, 2010, at 9:16 PM, johnacandy wrote: > > So i made the changes as I was told which were > Settings::instance().evaluationDate()= bondDatedDate; //which is > (15,June,2010) > and made certain the Redemption was = 100.0 > and i got an output of 5.667 which unfortunately is still not > correct , its > suppose to be 16.6 No, it's supposed to be 16.67% which is 0.1667. You also want to set bondCoupon = 0.05. Input and output rates are values in base 1, not percentages. Luigi ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi , just realized my mistake and then again i would really like to thank all of you guys in the mailing list
especially Luigi Ballabio , Harun Ozkan and offcourse Simon Ibotson. I really couldnt have managed without you guys. Thank You.
|
Hi i was playing around with yesterdays code to calculate Yield To Maturity and i came up with an issue
i was using the same online calculator and this time i used the following values Clean Price = 30 Face Value = 60 Coupon Rate = same = 5%= 0.05 Years to Maturity = 1 Now the output of my program was 1.16667 or 1.16667*100=116.66% and the output generated by the web application was 1.1 or 1.1*100=110% There is a lot of of difference b/w 116% and 110 % ... what am i doing wrong?? You can view my final code at code.txt Is my application over accurate and the entire calculators online and on excel unaccurate ?? or is there a problem with my code ... I would appreciate any guidance i may receive in this regard thanks..
|
I think i might have the redemption value wrong , if so plz let me know
How do we calculate the redemption value in the above scenario ?? Clean Price = 30 Face Value = 60 Coupon Rate = same = 5%= 0.05 Years to Maturity = 1
|
In reply to this post by johnacandy
Hi Hayyan,
It looks to be an amandable difference in figures, and, foremost, you should explore the source of difference. First, you'd better set the coupon rate to zero to make things less complicated. If the difference still persists -most probably it will- then, check out the compunding conventions. Try all of the *simple*, *compounded*, or *continuous* compunding options. Another probable source of difference would be about calendar. Try different day conventions. ----- Original Message ----- From: "johnacandy" <[hidden email]> To: <[hidden email]> Sent: Tuesday, October 19, 2010 1:17 PM Subject: Re: [Quantlib-users] Calculating yield to maturity , incorrect answer ? why ? > > Hi i was playing around with yesterdays code to calculate Yield To > Maturity > and i came up with an issue > i was using the same online calculator and this time > i used the following values > Clean Price = 30 > Face Value = 60 > Coupon Rate = same = 5%= 0.05 > Years to Maturity = 1 > > Now the output of my program was 1.16667 or 1.16667*100=116.66% > and the output generated by the web application was 1.1 or 1.1*100=110% > > There is a lot of of difference b/w 116% and 110 % ... what am i doing > wrong?? > > You can view my final code at > http://old.nabble.com/file/p29998757/code.txt > code.txt > Is my application over accurate and the entire calculators online and on > excel unaccurate ?? or > is there a problem with my code ... I would appreciate any guidance i may > receive in this regard thanks.. > > > > > > johnacandy wrote: >> >> Hi , just realized my mistake and then again i would really like to thank >> all of you guys in the mailing list >> especially Luigi Ballabio , Harun Ozkan and offcourse Simon Ibotson. I >> really couldnt have managed without you guys. Thank You. >> >> >> Luigi Ballabio wrote: >>> >>> >>> On Oct 18, 2010, at 9:16 PM, johnacandy wrote: >>> >>>> >>>> So i made the changes as I was told which were >>>> Settings::instance().evaluationDate()= bondDatedDate; //which is >>>> (15,June,2010) >>>> and made certain the Redemption was = 100.0 >>>> and i got an output of 5.667 which unfortunately is still not >>>> correct , its >>>> suppose to be 16.6 >>> >>> No, it's supposed to be 16.67% which is 0.1667. You also want to set >>> bondCoupon = 0.05. >>> Input and output rates are values in base 1, not percentages. >>> >>> Luigi >>> >>> >>> ------------------------------------------------------------------------------ >>> Download new Adobe(R) Flash(R) Builder(TM) 4 >>> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly >>> Flex(R) Builder(TM)) enable the development of rich applications that >>> run >>> across multiple browsers and platforms. Download your free trials today! >>> http://p.sf.net/sfu/adobe-dev2dev >>> _______________________________________________ >>> QuantLib-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >>> >> >> > > -- > View this message in context: > http://old.nabble.com/Calculating-yield-to-maturity-%2C-incorrect-answer---why---tp29991145p29998757.html > Sent from the quantlib-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by johnacandy
The redemption value is the amount paid to the holder at the maturity of
the bond. The face amount is the amount on which yield calculations / coupon rates are made. Unless you have a strange bond, it is best to have the face value equal to the redemption. -----Original Message----- From: johnacandy [mailto:[hidden email]] Sent: 19 October 2010 14:11 To: [hidden email] Subject: Re: [Quantlib-users] Calculating yield to maturity , incorrect answer ? why ? I think i might have the redemption value wrong , if so plz let me know How do we calculate the redemption value in the above scenario ?? Clean Price = 30 Face Value = 60 Coupon Rate = same = 5%= 0.05 Years to Maturity = 1 johnacandy wrote: > > Hi i was playing around with yesterdays code to calculate Yield To > Maturity and i came up with an issue > i was using the same online calculator and this time > i used the following values > Clean Price = 30 > Face Value = 60 > Coupon Rate = same = 5%= 0.05 > Years to Maturity = 1 > > Now the output of my program was 1.16667 or 1.16667*100=116.66% > and the output generated by the web application was 1.1 or > > There is a lot of of difference b/w 116% and 110 % ... what am i doing > wrong?? > > You can view my final code at > http://old.nabble.com/file/p29998757/code.txt code.txt > Is my application over accurate and the entire calculators online and on > excel unaccurate ?? or > is there a problem with my code ... I would appreciate any guidance i may > receive in this regard thanks.. > > > > > > johnacandy wrote: >> >> Hi , just realized my mistake and then again i would really like to thank >> all of you guys in the mailing list >> especially Luigi Ballabio , Harun Ozkan and offcourse Simon Ibotson. I >> really couldnt have managed without you guys. Thank You. >> >> >> Luigi Ballabio wrote: >>> >>> >>> On Oct 18, 2010, at 9:16 PM, johnacandy wrote: >>> >>>> >>>> So i made the changes as I was told which were >>>> Settings::instance().evaluationDate()= bondDatedDate; //which is >>>> (15,June,2010) >>>> and made certain the Redemption was = 100.0 >>>> and i got an output of 5.667 which unfortunately is still not >>>> correct , its >>>> suppose to be 16.6 >>> >>> No, it's supposed to be 16.67% which is 0.1667. You also want to >>> bondCoupon = 0.05. >>> Input and output rates are values in base 1, not percentages. >>> >>> Luigi >>> >>> >>> ------------------------------------------------------------------------ ------ >>> Download new Adobe(R) Flash(R) Builder(TM) 4 >>> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly >>> Flex(R) Builder(TM)) enable the development of rich applications that >>> run >>> across multiple browsers and platforms. Download your free trials today! >>> http://p.sf.net/sfu/adobe-dev2dev >>> _______________________________________________ >>> QuantLib-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >>> >> >> > > -- View this message in context: http://old.nabble.com/Calculating-yield-to-maturity-%2C-incorrect-answer ---why---tp29991145p30000059.html Sent from the quantlib-users mailing list archive at Nabble.com. ------------------------------------------------------------------------ ------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify [hidden email] immediately and delete the email from your computer. The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards. This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from The Financial Services Authority (FSA) 25 The North Colonnade, Canary Wharf, London E14 5HS United Kingdom Registered as a Limited Company in England and Wales No.1920623. Registered Office as above Switchboard: 020 7066 1000 Web Site: http://www.fsa.gov.uk ***************************************************************** ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |