Puzzled by a value returned by function date2time from the Financial Toolbox

1 view (last 30 days)
date2time('31-Jul-2015', '30-Sep-2015', 1, 0, 1)
returns 61/366 = 0.166666666666667
Since the compounding frequency is 1, the other quasi coupon date is twelve months prior to maturity, therefore '30-Sep-2014'. One can use these two dates ('30-Sep-2014' and '30-Sep-2015') to compute the total number of actual days in this period, which should be 365. Since there are 61 days between 31-Jul-2015 and 30-Sep-2015, I was expecting date2time to be computed as 61/365 and not 61/366. What am I doing wrong? Many thanks in advance.
  1 Comment
Stephen23
Stephen23 on 25 Sep 2024
Edited: Stephen23 on 25 Sep 2024
The values in question:
format long G
date2time('31-Jul-2015', '30-Sep-2015', 1, 0, 1)
ans =
0.166666666666667
61/366
ans =
0.166666666666667
61/365
ans =
0.167123287671233

Sign in to comment.

Answers (1)

Aman
Aman on 25 Sep 2024
Hi Antonio,
From the info that you shared, I understand that you are facing issues in understanding the output of the function.
The output that you are receiving is expected because the basis used is 0, which follows actual/actual convention and calculates the fraction of the year based on the actual number of days in the period and the actual number of days in the year. Since 2016 is a leap year, the calculation considers 366 days for the year.
In order to get your desired output, you can use 3 as the basis, as it considers 365 days, although a drawback would be that it considers 365 in the case of a leap year as well. You can refer to the below snippet of code to see how to do that.
date2time('31-Jul-2015', '30-Sep-2015', 1, 3, 1)
ans = 0.1671
Follow the below documentation in order to learn more about the basis:
I hope it helps!
  1 Comment
Antonio Seabra
Antonio Seabra on 25 Sep 2024
Moved: Stephen23 on 25 Sep 2024
Thank you for your reply. However I believe that the fact that 2016 is a leap is not relevante here, since the period of interest is between '31-Jul-2015' and '30-Sep-2015', well before the start of 2016.

Sign in to comment.

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!