+ Reply to Thread
Results 1 to 21 of 21

ODDFPRICE function solved mathematically

  1. #1
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    ODDFPRICE function solved mathematically

    Hi,

    I am trying to solve the ODDFPRICE function mathematically based on a set of parameters shown below in particular with the basis parameter set as US 30/360. I am able to solve the formula mathematically with frequency = 1 which when solved outputs the answer of 90.93640046. However for Frequency = 2 I am off by approx. .40 cents. Would anyone please provide the arithmetic with the actual numbers input to solve for the below function parameters. Output should be 88.91159635. This formula calculates the clean price of a bond with an odd first short/long coupon period. In this instance the first odd period is short.

    Settlement Date 2010-10-15
    Maturity Date 2017-11-30
    Issue Date 2009-12-01
    First Coupon Date 2010-11-30
    Percent Coupon 2.75%
    Yield 4.25%
    Redemption Value 100.00
    Frequency 2
    Basis 0

    Thank you.
    Last edited by Streamer; 02-12-2019 at 06:50 PM.

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: ODDFPRICE function solved mathematically

    Hello Streamer. Welcome to the forum.

    Please post your actual formula ... or better yet a sample workbook with representative data and the formula in it.

    Please bear in mind we are good at formulas, but not many of us are knowledgeable in finance.

    Then I am confident someone can work out a solution.
    Dave

  3. #3
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi FlameRetired,

    I have attached the ODDFPRICE workbook for your reference. Hope this helps.

    Thanks,
    Streamer
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    Are you still interested?

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: ODDFPRICE function solved mathematically

    Yes. Unfortunately I do not understand enough to contribute.

    As of this moment there have been 7 views of the attachment. So others are looking at this as well. There is interest.

    I will call for community help on this one as it appears to be highly specialized.

  6. #6
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    Sorry about the delay. Life happened!

    The answer is very simple: Streamer made several mistakes.

    The most serious mistake is: by choosing the same issue date, specifically 359 days before the first coupon, the semiannual example is a long first period, not a short first period like the annual example. As the ODDFPERIOD help page explains, a different formula applies to a long first period.

    Another significant mistake is: using N=16 (and N-1=15) for the semiannual example. N=15 is correct. The semiannual formulas should be similar to the annual formulas, to wit:

    C12: =COUPNUM(I1,I2,I8,I9)
    C13: =C12-1

    I did not verify that the long-first-period formula works with Streamer's semiannual example. But the following model demonstrates the documented formula for a short first period does indeed work for a short-first-period semiannual example as well as for a short-first-period annual example.

    Unfortunately, I cannot post a table in this forum. Refer to the "ODDFPRICE 30360 (2)" worksheet in the attached Excel file.

    The following formula (settlement date) ensures that the requirement settlement > issue date is adhered to, in case we experiment with other issue dates.

    E1: =MAX(DATE(2010,10,15),E3+1)

    The following formula (issue date) ensures that the issue date is at least 1 day after the quasi-coupon date (in J4) before the first coupon.

    I3: =MAX(E3, J4+1+ISERROR(ODDFPRICE(I1,I2,J4+1,I4,I5,I6,I7,I8,I9)))
    J4: =COUPPCD(I4-1,I4,I8,I9)

    The ISERROR expression avoids an error that I discovered when freq=4 and basis=2. In that case, the issue date must be at least 2 days, not just 1 day, after the quasi-coupon date before the first coupon. Off-hand, I don't know why.

    The PV(...,0) formula in E14 is mathematically equivalent to the NPV of the regular coupon payments, to wit:

    E14: =PV(E6/E8,B13,-100*E5/E8,0,0) / (1+E6/E8)^B16

    Alternatively, the following formula might be a more intuitive equivalent:

    E14: =PV(B26,B24-1,-100*B25,0,1) / (1+B26)^(1+B28)

    Either PV formula is more flexible than the SUM of the periodic PVs, which Streamer constructed -- although the latter could be made to be just as flexible.

    The many other formula corrections are too numerious to explain. Generally, they are more versatile, allowing for changes in frequency and day-count basis.

    With all of the changes, generally, my own "oddfprice" calculation matches the ODDFPRICE result within 15 significant digits for a variety of settlement/issue date and frequency/basis combinations.

    With freq=4, generally, the different methods match up to 14 significant digits. Perhaps the difference is due to my use of PV in E14 instead of the sum of periodic PVs. (Speculation.)

    However, with freq=4 and basis=1, the difference is in the 3rd decimal place(!). Off-hand, I don't know why.

    Similarly large differences arise when the settlement or issue date is the end of a month, but not day 30, and the day-count basis is zero (30/360). Obviously, a defect in counting days. But I don't know if the error is in the various COUP* functions that I use or in ODDFPRICE.
    Attached Files Attached Files
    Last edited by joeu2004; 02-24-2019 at 05:47 PM.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: ODDFPRICE function solved mathematically

    joeu2004 my apologies. I thought I was responding to Streamer ... the thread owner.

  8. #8
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Excellent! I will review in detail in the next few days and get back to you if I need any further help. Many Thanks.

  9. #9
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Good day joeu2004,

    I have reviewed your post in detail and have attained a strong grasp of the ODDFPRICE function calculations. However I have also attempted
    to solve the ODDLPRICE function mathematically to no avail. The formula for the ODDLPRICE function is not available in the help page and so
    I have had to retrieve one from google which was not an easy task since it seems the formula is scarcely available. I have attached my
    workbook with the ODDLPRICE function calculations. Could you please also take a look and see if you can come up with a solution. I reckon,
    the formula in the workbook applies to both the short and long last coupon periods. The calculations I have attempted are for the short
    last period and so I would also appreciate if you could shed some light on how the long last period calculation would be performed. The
    formula looks striaght forward nonetheless the input parameters are oddly unclear.

    I appreciate any help you could provide and welcome contributions from other fellow contributors.

    Thanks and regards,
    Streamer
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    @Streamer.... Not ignoring your query. I'm traveling today and tomorrow. And there are some issues with ODDLPRICE that I want to look into. So it might another 2-3 days before I can respond.

  11. #11
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Noted. Thank you.

  12. #12
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi joeu2004,

    Any updated on the ODDLPRICE function?

    Regards,
    Streamer

  13. #13
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    My apologies. I got distracted by life; then so much time had elapased that I didn't know if you were still interested.

    I cannot offer a good solution; I think it is best implemented in VBA.

    What I provide is a proof of concept with some explanation.

    For the discussion below, download the file "oddlprice excelforum.xlsx" from https://app.box.com/s/wyb64fte7i211fjqsxxm2h09sjpr08r2 . Ignore any preview errors, and just download. Also, you are not required to log into box.net/files first.

    I tried to test the formulas extensively. Their results seem to be consistent with Excel ODDLPRICE. If you find an example that does not work, I would be happy to investigate it.

    [Update: I do find differences with some combinations of dates, frequency and day-count basis. I believe the disparity has to do with date calculations involving leap years in the Excel ODDLPRICE and COUP* functions. When I manipulate the dates to avoid leap years and quasi-coup dates in or at the end of Feb, my results agree with Excel ODDLPRICE for the same frequency and day-count basis combinations.]

    -----

    [I have never been able to get the HTML tool to work. So I cannot create tables. Refer to the "ODDLPRICE (2)" worksheet in the Excel file.]

    First, it is important to understand an arbitrary limitation of ODDLPRICE, namely: maturity > settlement > last coupon (paid). This simplifies the PV calculation insofar as there is only one payment (at maturity). That is why there is only one discount term in the mathematical formula that you found.

    In contrast, if we allow for last coupon > settlement, there would be multiple discount terms, similar to NPV. For example, see http://westclintech.com/Blog/tabid/1...st-Coupon.aspx .

    Second, the following is an improved description of the variables in the mathematical formula that you found:

    Please Login or Register  to view this content.
    The "i" refers to the quasi-coup period number following the last coupon (paid).

    However, I cannot see any reason for NLi. I believe it should be the same for all periods. Therefore, I use a constant "NL".

    [Update: In hindsight, that might be the reason why my calculation does not agree with Excel ODDLPRICE when leap years are involved. Arguably, NLi might be different for periods including Feb for some combinations of frequency and day-count basis. "The refinement is left as an exercise for the student". (wink)]

    The following discussion is for your Example #1. Similar forumlas apply to your Example #2.

    You had set up the following input values:

    Please Login or Register  to view this content.
    I set up the following additional helper values:

    Please Login or Register  to view this content.
    Note the "creative" interpretation of the "settlement" and "maturity" parameters for the COUP* functions. That is the key to the correct calculations of those values and dates for all combinations of frequency and day-count basis.

    An important difference with ODDLPRICE calculations is: coup dates are determined forward from last coup date, not back from maturity date. This is because with an odd last period, the maturity date is typically not a regular coupon date (unlike your example).

    In contrast, with other bond calculations and with Excel bond functions, the maturity date is assumed to be a regular coupon date. Consequently, other coupon dates can be calculated by counting back from the maturity date, depending on the day-count basis.

    That difference is reflected in B13: we need to determine the end of the quasi-coupon period that contains the maturity date. Ostensibly, that is determined by treating the maturity date as the "settlement" date in the COUPNCD function, and by creating a fictitious "maturity" date, which is the last-coup date in the year following the maturity date. The COUPPCD(COUPNCD)=B4 logic handles the special case when the maturity date is a regular coupon date.

    The following demonstrates my ODDLPRICE calculation. It relies on a table of helper cells in A25:E57, described below.

    Please Login or Register  to view this content.
    "Num" (numerator), "denom" (denominator) and "accr int" (accrued interest) refer to the terms of the mathematical formula that you found.

    The real "magic" is performed in the table below, which determines Ai, DCi and DSCi for each quasi-coup period.

    Please Login or Register  to view this content.
    Ai is the number of days of accrued interest between the last coup (paid) date and the settlement date. For the quasi-coup period that contains the settlement date, it is the number of days between the previous quasi-coup date and the settlement date. Otherwise, Ai is the full number of days in quasi-coup periods before the settlement period; and it is zero for quasi-coup periods after the settlement period.

    DCi is the total number of days of interest (including accrued interest) between the last coup (paid) date and the maturity date. For the quasi-coup period that contains the maturity date, it is the number of days between the previous quasi-coup date and the maturity date. (We must make a special case for when the maturity date is a quasi-coup date, due to an arbitrary limitation of COUPDAYBS.) Otherwise, DCi is the full number of days in each quasi-coup period.

    DSCI is the number of days that the payment at maturity is discounted back to the settlement date. Ostensibly, it is the full number of days in quasi-coup periods between the settlement and maturity periods. For the settlement period, DCi is the number of days between the settlement date and the next quasi-coup date. For the maturity period, it is the number of days between the previous quasi-coup date and the maturity date. A special case arises when the settlement and maturity dates are in the same quasi-coup period. The construction of the DCi calculation handles both the normal and the special cases automagically.

    SIGN(...)+2 results in the CHOOSE indexes 1, 2 and 3 for the conditions B25<B14, B25=B14 and B25>B14 respectively.

    I hope that helps to understand how the Excel ODDLPRICE implements the mathematical formula, at least conceptually.

    (I do not have any knowledge about how Excel ODDLPRICE is actually implemented.)
    Last edited by joeu2004; 03-25-2019 at 02:44 AM.

  14. #14
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    Quote Originally Posted by joeu2004 View Post
    I cannot see any reason for NLi. I believe it should be the same for all periods. Therefore, I use a constant "NL".

    [Update: In hindsight, that might be the reason why my calculation does not agree with Excel ODDLPRICE when leap years are involved. Arguably, NLi might be different for periods including Feb for some combinations of frequency and day-count basis. "The refinement is left as an exercise for the student". (wink)]
    FYI, I did calculate NLi for each period and integrate that into my "solution". But my calculations still do not agree with Excel ODDLPRICE for all combinations of frequency and day-count basis with certain sets of dates (last coup paid, settlement and maturity).

    Either I made some mistakes; very possible. Or, as I suspect, there are differences between the way that COUPDAYS calculates days between dates, using adjacent quasi-coup dates for "settlement" and "maturity", and the way that Excel ODDLPRICE does, for some combinations of frequency and day-count bases and some sets of dates.

    IMHO, it would take a lot of effort to determine where the culprit lies, handcrafting all 15 combinations of frequency and day-count basis with each of several date scenarios.

    Unfortunately, I do not have time to do that.

  15. #15
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi joeu2004,

    Splendid work. Very analytical and resourceful. Once again thank you for your input and meaningful contribution.

    Regards,
    Streamer

  16. #16
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi joeu2004,

    I have reviewed your solution to the ODDLPRICE function and found it to be of great benefit. I have advanced
    the calculations to include the quarterly frequency however I am off by a 9 cents. I tried calibrating the parameters to include two
    leap years (not sure if I did it correctly), namely for 2012 and 2016 nonetheless this only produces a nominal variance. In addition,
    I applied the same concept from the ODDLPRICE function calculation with that of the ODDLYIELD function with the condition of
    Maturity Date > Settlement Date > Last Interest Date. This was done using the same parameters however the output does not comply with the
    expected answer of 4.25%. Not sure why that is. Could you please take a look at the attached worksheet and see if you can spot
    the errors and provide any comments at your discretion to the ODDLPRICE (quarterly) and ODDLYIELD calculations as I would greatly
    appreciate it. Note: I am interested in your feedback despite that you may be busy and it would take a while for you to respond.

    Thank you in advance and Kind Regards,
    Streamer
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: ODDFPRICE function solved mathematically

    I'm afraid that I will not be able to work on these questions anymore. Lack of time. And also some frustration with "inexplicable" errors like the one below.

    I did notice that you made a "translation" error when you created Example #3. The formulas starting in Q25 should be:

    Please Login or Register  to view this content.
    You omitted the red-highlighted parameter.

    With that correction, note that with lastcoup set to 8/31/2010, some of the quasi-coup dates in column N are Feb 28 or Feb 29.

    I believe that is what causes the 9-cent difference.

    If we set lastcoup to 8/27/2010 or earlier -- any day of the month that can be common to all months -- there is no difference.

    I could understand the difference for day-count bases 1, 2 and 3. Those are the "actual" day-count conventions, and my mistake of assuming that NLi is constant might cause some difference.

    However, for day-count basis 0 (and 4), my assumption should be correct.

    So IMHO, the defect is in applying the day-count basis either in the COUP* functions or the ODDLPRICE function or both.

    It is not worth my time to try to invent a work-around, especially since my own mistake is still a factor for other day-count bases.

    FYI, I believe I also determined that my method of creating a quasi-final coupon date (B13:D13) causes problems with some combination of dates (lastcoup, settlement and maturity), frequency and day-count basis.

    I do not remember the details. But with the "right" combination, the 1st quasi-coup date (B25, H25, N25) is just a day or so after the lastcoup date (B24, H24, N24).

    Bottom line: I believe there are two sets of defects: mine and Excel's. And I do not have the time or interest in trying to correct them.

    Sorry, but I have to draw a line somewhere.

  18. #18
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi joeu2004,

    Thank you for your prompt reply. You have insofar met and exceeded my expectations with your help on the subject matter. I have made the corrections as noted in the aforementioned post and the 9 cent difference has in fact balanced. As for the ODDLYIELD function I will try and post it on a different forum since on Excel Forum there appear to be no contributors knowledgeable on this topic.

    Thank you once again for your help,
    Streamer

  19. #19
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: ODDFPRICE function solved mathematically

    Streamer, thank you for alerting us about possible cross posts.

    If you do so please posts links to those cross posts back here in this thread as well as in the other forums. It is a forum rule here as well as in other forums.

    Please understand that contributors knowledgeable may not be currently logged on. It is the downside of free forums "staffed" by volunteers. So please check back from time to time.
    When you do find solution as a courtesy please post back to all forums with link to the solution and mark threads Solved in all the cross posts.

    I'm sure you understand. Thank you in advance.

  20. #20
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically

    Hi FlameRetired,

    I will proceed accordingly.

    Thanks,
    Streamer

  21. #21
    Registered User
    Join Date
    02-11-2019
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    15

    Re: ODDFPRICE function solved mathematically


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 05-25-2017, 06:27 AM
  2. [SOLVED] [Solved] Using if function with #N/A Result from Index function
    By scohn14 in forum Excel General
    Replies: 1
    Last Post: 06-09-2014, 09:05 PM
  3. Replies: 15
    Last Post: 12-06-2012, 01:07 PM
  4. Help with function **SOLVED**
    By Tonymac in forum Excel General
    Replies: 8
    Last Post: 08-21-2011, 11:21 PM
  5. Mathematically possible?
    By Sardonumse in forum Excel General
    Replies: 1
    Last Post: 05-16-2010, 03:18 PM
  6. [SOLVED] How to use this function?
    By Á÷À˵ÄË& in forum Excel General
    Replies: 5
    Last Post: 06-15-2005, 03:05 AM
  7. [SOLVED] [SOLVED] MIN function
    By Walt in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-08-2005, 10:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1