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 个评论
回答(1 个)
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)
Follow the below documentation in order to learn more about the basis:
I hope it helps!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!