| Financial Time Series | ![]() |
Data Extraction
Here is an exercise on how to extract data from a financial time series object. As mentioned before, you can think of the object as a MATLAB structure. Cut and paste each line in the exercise to the MATLAB command window and press Enter to execute it.
To begin create a financial time series object called myfts.
dates = (datenum('05/11/99'):datenum('05/11/99')+100)';
data_series1 = exp(randn(1, 101))';
data_series2 = exp(randn(1, 101))';
data = [data_series1 data_series2];
myfts = fints(dates, data);
myfts = desc: (none) freq: Unknown (0) 'dates: (101)' 'series1: (101)' 'series2: (101)' '11-May-1999' [ 2.8108] [ 0.9323] '12-May-1999' [ 0.2454] [ 0.5608] '13-May-1999' [ 0.3568] [ 1.5989] '14-May-1999' [ 0.5255] [ 3.6682] '15-May-1999' [ 1.1862] [ 5.1284] '16-May-1999' [ 3.8376] [ 0.4952] '17-May-1999' [ 6.9329] [ 2.2417] '18-May-1999' [ 2.0987] [ 0.3579] '19-May-1999' [ 2.2524] [ 3.6492] '20-May-1999' [ 0.8669] [ 1.0150] '21-May-1999' [ 0.9050] [ 1.2445] '22-May-1999' [ 0.4493] [ 5.5466] '23-May-1999' [ 1.6376] [ 0.1251] '24-May-1999' [ 3.4472] [ 1.1195] '25-May-1999' [ 3.6545] [ 0.3374]...
There are more dates in the object; only the first few lines are shown here.
Now create another object with only the values for series2.
srs2 = myfts.series2 srs2 = desc: (none) freq: Unknown (0) 'dates: (101)' 'series2: (101)' '11-May-1999' [ 0.9323] '12-May-1999' [ 0.5608] '13-May-1999' [ 1.5989] '14-May-1999' [ 3.6682] '15-May-1999' [ 5.1284] '16-May-1999' [ 0.4952] '17-May-1999' [ 2.2417] '18-May-1999' [ 0.3579] '19-May-1999' [ 3.6492] '20-May-1999' [ 1.0150] '21-May-1999' [ 1.2445] '22-May-1999' [ 5.5466] '23-May-1999' [ 0.1251] '24-May-1999' [ 1.1195] '25-May-1999' [ 0.3374]...
The new object srs2 contains all the dates in myfts, but the data series is only series2. The name of the data series retains its name from the original object, myfts.
| Financial Time Series Object Structure | Object to Matrix Conversion | ![]() |