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!