Main Content

Convert Financial Time Series Objects (fints) to Timetables

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

Create Time Series

I/O Related Operations

TaskRemoved FunctionalityUse This Functionality
Construct by passing in data and datesfints(dates,data,datanames)

Use timetable:

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

Construct by conversion of filesascii2fts(filename,descrow,colheadrow,skiprows)Use readtable and table2timetable:

T = readtable(filename,opts,Name,Value)

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

Write filesfts2ascii(filename,tsobj,exttext)Use writetable:

writetable(TT,filename)

Convert to matrixfts2mat(tsobj)

S = vartype('numeric');

TT2 = TT(:,S)

TT2.Variables

Index an Object

Indexing an Object

TaskRemoved FunctionalityUse This Functionality
Indexing with a datemyfts('05/11/99')

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

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

Use timerange:

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.timesUse timeofday:

timeofday(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

TaskRemoved FunctionalityUse This Functionality
Boxcox transformationnewfts = boxcox(oldfts)

Use boxcox:

TT.Variables = boxcox(TT.Variables)

Differencingdiff(myfts)

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

TT(1,:) = []

Indexing with integers for rows

fillts(oldfts,fill_method)

Use fillmissing:

fillmissing(TT,method)

(Assumes no missing dates)

Linear filteringfilter(B,A, myfts)

Use filter:

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

Lag or lead time series object

lagts(myfts,lagperiod)

leadts(myfts,leadperiod)

Use lag:

lag(TT,lagperiod)

lag(TT,-leadperiod)

(Assumes a regularly spaced timetable)

Periodic averageperavg(myfts)

Use retime:

retime(TT,newTimes,'mean')

Downsample dataresamplets(oldfts,samplestep)

Use retime:

retime(TT,newTimeStep,method)

Smooth datasmoothts(input)

Use smoothdata:

smoothdata(TT)

Moving averagetsmovavg(tsobj,method,lag)

Use movavg:

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

TaskRemoved FunctionalityUse This Functionality
Convert to specified frequencyconvertto(oldfts,newfreq)

Use retime:

retime(TT,newTimeStep,method)

Convert to annualtoannual(oldfts,...)

Use convert2annual:

convert2annual(TT,…)

Convert to dailytodaily(oldfts,...)Use convert2daily:

convert2daily(TT,…)

Convert to monthlytomonthly(oldfts,...)Use convert2monthly:

convert2monthly(TT,…)

Convert to quarterlytoquarterly(oldfts,...)

Use convert2quarterly:

convert2quarterly(TT,…)

Convert to semiannualtosemi(oldfts,...)

Use convert2semiannual:

convert2semiannual(TT,…)

Convert to weeklytoweekly(oldfts,...)

Use convert2weekly:

convert2weekly(TT,…)

Merge Time Series

Merge Operations

TaskRemoved FunctionalityUse This Functionality
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]

Use horzcat or synchronize:

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]Use vertcat:

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

TaskRemoved Functionality Use This Functionality
Extract out numerical datasrs2 = myfts.series2

TT.Variables

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

Use cov (or max, mean, median, min, std, or var):

cov(TT.Variables)

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

Use sum or cumsum:

TT.Variables = cumsum(TT.Variables)

Data Extraction

Refer to timetable documentation for data extraction methods and examples.

See Also

| | | | | | | | | | | | | | | | | |

Related Topics