Documentation

Convert Financial Time Series Objects fints to Timetables

In R2018a, financial time series (fints), and its associated methods have been replaced with a MATLAB® timetable function. If you use fints or the associated methods, you receive a warning. To help you convert from the older fints to the newer timetable functionality, use the following information.

Create Time Series

I/O Related Operations

Construct by passing in data and datesfints(dates,data,datanames)

timetable(rowTimes,var1,...,varN,'VariableNames',{'a','b',...})

Construct by conversion of filesascii2fts(filename,descrow,colheadrow,skiprows)

TT = table2timetable(T,'RowTimes',timeVarName)

Construct by using App with user interfaceUsing the Financial Time Series app with user interfaceUsing ImportData from HOME tab
Write filesfts2ascii(filename,tsobj,exttext)writetable(TT,filename)
Convert to matrixfts2mat(tsobj)

S = vartype('numeric');

TT2 = TT(:,S)

TT2.Variables

Index an Object

Indexing an Object

Indexing with a datemyfts('05/11/99')

TT({'1999-05-11'},:)

Indexing with a date rangemyfts ('05/11/99::05/15/99')

S = timerange('1999-05-11','1999-05-15');

TT2 = TT(S,:)

Indexing with integers for rows

myfts.series2(1)

myfts.series2([1, 3, 5])

myfts.series2(16:20)

TT(1,{'series2'})

TT([1, 3, 5],{'series2'})

TT(16:20,{'series2'})

Contents of a specific time fieldmyfts.timestimeofday(TT.Properties.RowTimes)
Contents for a specific field in a matrixfts2mat(myfts.series2)

TT.series2

Transform Time Series

Assume that all variables are numeric within a timetable, or the operations can be applied on TT2:

S = vartype('numeric');

TT2 = TT(:,S)

Filter Time Series

Boxcox transformationnewfts = boxcox(oldfts)

TT.Variables = boxcox(TT.Variables)

Differencingdiff(myfts)

TT{2:end,:} = diff(TT.Variables)

TT(1,:) = []

Indexing with integers for rows

fillts(oldfts,fill_method)

fillmissing(TT,method)

(Assumes no missing dates)

Linear filteringfilter(B,A, myfts)

TT.Variables = filter(b,a,TT.Variables)

Lag or lead time series object

lagts(myfts,lagperiod)

lag(TT,lagperiod)

(Assumes a regularly spaced timetable)

Periodic averageperavg(myfts)

retime(TT,newTimes,'mean')

Downsample dataresamplets(oldfts,samplestep)

retime(TT,newTimeStep,method)

Smooth datasmoothts(input)

smoothdata(TT)

Moving averagetsmovavg(tsobj,method,lag)

movavg(TT,type,windowSize)

Convert Time Series

Assume that all variables are numeric within a timetable, or the operations can be applied on TT2:

S = vartype('numeric');

TT2 = TT(:,S)

Conversion Operations

Convert to specified frequencyconvertto(oldfts,newfreq)

retime(TT,newTimeStep,method)

Convert to annualtoannual(oldfts,CalcMethod)

retime(TT,'yearly',method)

Convert to dailytodaily(oldfts,CalcMethod)retime(TT,'daily',method)
Convert to monthlytomonthly(oldfts,CalcMethod)retime(TT,'monthly',method)
Convert to quarterlytoquarterly(oldfts,CalcMethod)

retime(TT,'quarterly',method)

Convert to semiannualtosemi(oldfts,CalcMethod)

semiAnnualDates (manually generated)

retime(TT, semiAnnualDates,method)

Convert to weeklytoweekly(oldfts,CalcMethod)

retime(TT,'weekly',method)

Merge Time Series

Merge Operations

Merge multiple time series objectsmerge(fts1,fts2)

[TT1;TT2] (requires variable name to be the same)

unique(TT)

Concatenate financial time series objects horizontallyhorzcat(fts1,fts2) or [fts1,fts2]

horzcat[TT1,TT2] (requires variable name to be the same) or

synchronize(TT1,TT2)

Concatenate financial time series objects verticallyvertcat(fts1,fts2) or [fts1;fts2]vertcat[TT1;TT2]

Analyze Time Series

Due to flexibility of a timetable that can hold heterogeneous variables, a timetable does not support math operations or descriptive statistical calculations. If you would like to apply any numeric calculations on a timetable, use the following guidelines.

Assume that all variables are numeric within a timetable, or the operations can be applied on TT2:

S = vartype('numeric');

TT2 = TT(:,S)

Descriptive Statistics and Arithmetic and Math Operations

Extract out numerical datasrs2 = myfts.series2

TT.Variables

Apply some options (statistics)For example: min, max, mean, median, cov, std, and var

cov(TT.Variables)

Apply some options (operations)For example: sum and cumsum

TT.Variables = cumsum(TT.Variables)

Data Extraction

Refer to timetable documentation for data extraction methods and examples.