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

1 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2024-9-25
编辑:Stephen23 2024-9-25
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

请先登录,再进行评论。

回答(1 个)

Aman
Aman 2024-9-25
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 个评论
Antonio Seabra
Antonio Seabra 2024-9-25
移动:Stephen23 2024-9-25
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by