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

조회 수: 1 (최근 30일)
Antonio Seabra
Antonio Seabra 2021년 2월 7일
편집: Stephen23 2024년 9월 25일
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