如何提取每日fts的每月财务时间序列

时间:2014-10-14 13:02:50

标签: matlab

据我所知,我们可以在财务工具箱中使用“tomonthly”功能,但这会返回每个月最后一个工作日的默认月度数据。

如果我想要每个月的第一个工作日呢?

我尝试按以下方式将'ED'设置为1:

ftsFuture = fints (matlabDate, lnPrice);
monthlyFuture = tomonthly(ftsFuture,'ED',1); 

但这只是部分成功,因为如果本月1日是工作日,那就没关系,但如果不是工作日,那就是前一个工作日,即上个月。

我也尝试使用'BusDays'将其设置为0,方法如下:

ftsFuture = fints (matlabDate, lnPrice);
monthlyFuture = tomonthly(ftsFuture,'ED',1, 'BusDays',0);  

这成功地强制每个条目成为每个月的第1个,但显然不能正确,因为其中一些日期显然不是工作日!

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

有一种方法可以从每月的第一个工作日开始的每月财务时间序列中提取数据。我们可以使用tomonthlybusdate函数在系列中间获取日期。

假设数据从某月开始到某个月结束,我们会添加第一个日期并删除操作后的最后日期。

ftsFuture = fints (matlabDate, lnPrice);
monthlyFuture = tomonthly(ftsFuture);
eomDates = monthlyFuture.dates ; % getting end of month business days) 
fomDates = busdate(eomDates) ;  % getting first month bussines days)
fomDates(end)=[] ; % deleting the last date in the array (out of range otherwise).
firstday = ftsFuture.dates(1); % adding the first date of the series.
fomDates = [firstday ; fomDates];
fomDates = datestr(fomDates);
fomftsFuture = ftsFuture(fomDates);