## 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. You can use `fts2timetable` to convert a `fints` object to a `timetable` object. 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 dates`fints(dates,data,datanames)`

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

Construct by conversion of files`ascii2fts(filename,descrow,colheadrow,skiprows)`

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

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

Write files`fts2ascii(filename,tsobj,exttext)``writetable(TT,filename)`
Convert to matrix`fts2mat(tsobj)`

```S = vartype('numeric');```

```TT2 = TT(:,S)```

`TT2.Variables`

### Index an Object

Indexing an Object

Indexing with a date`myfts('05/11/99')`

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

Indexing with a date range`myfts ('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 field`myfts.times``timeofday(TT.Properties.RowTimes)`
Contents for a specific field in a matrix`fts2mat(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 transformation`newfts = boxcox(oldfts)`

```TT.Variables = boxcox(TT.Variables) ```

Differencing`diff(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 filtering`filter(B,A, myfts)`

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

Lag or lead time series object

`lagts(myfts,lagperiod)`

`leadts(myfts,leadperiod)`

`lag(TT,lagperiod)`

`lag(TT,-leadperiod)`

(Assumes a regularly spaced timetable)

Periodic average`peravg(myfts)`

`retime(TT,newTimes,'mean')`

Downsample data`resamplets(oldfts,samplestep)`

`retime(TT,newTimeStep,method)`

Smooth data`smoothts(input)`

`smoothdata(TT)`

Moving average`tsmovavg(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 frequency`convertto(oldfts,newfreq)`

`retime(TT,newTimeStep,method)`

Convert to annual`toannual(oldfts,...)`

`convert2annual(TT,…)`

Convert to daily`todaily(oldfts,...)``convert2daily(TT,…)`
Convert to monthly`tomonthly(oldfts,...)``convert2monthly(TT,…)`
Convert to quarterly`toquarterly(oldfts,...)`

`convert2quarterly(TT,…)`

Convert to semiannual`tosemi(oldfts,...)`

`convert2semiannual(TT,…)`

Convert to weekly`toweekly(oldfts,...)`

`convert2weekly(TT,…)`

### Merge Time Series

Merge Operations

Merge multiple time series objects`merge(fts1,fts2)`

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

`unique(TT)`

Concatenate financial time series objects horizontally`horzcat(fts1,fts2)` or `[fts1,fts2]`

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

`synchronize(TT1,TT2)`

Concatenate financial time series objects vertically`vertcat(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 data`srs2 = 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.