How to get monthly financial time series data from daily fts

I understand that we can use the "tomonthly" function inside financial instrumentation, but this returns monthly data by default, taking the last business day of each month.

What if I want the first working day of every month?

I tried using 'ED' set to 1 like this:

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

      

But it was only partially successful in the sense that if the 1st month is a work day, everything is fine, but if it is not a work day, it becomes the previous work day, which is in the previous month.

I also tried using "BusDays" by setting it to 0, like this:

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

      

This successfully forces every entry to be the 1st of every month, but clearly can't be right as some of those dates obviously don't work!

Any help on this is greatly appreciated!

+3


source to share


1 answer


There is a way to extract data from daily financial time series in monthly periods starting from the first business day of the month. We can get dates in the middle of the series using the tomonthly

and functions busdate

.

Assuming the data starts at the beginning of the month and ends at the end of a specific month, we add the first date and exclude the last date we get after the operations.



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); 

      

0


source







All Articles