Financial Time Series Toolbox    

Transforming a Text File

The function ascii2fts creates a financial time series object from a text (ASCII) data file provided that the data file conforms to a general format. The general format of the text data file is

Several example text data files are included with the toolbox. These files are in the ftsdata subdirectory within the Financial Time Series Toolbox directory <matlab>/toolbox/ftseries.

The syntax of the function

takes in the data filename (filename), the row number where the text for the description field is (descrow), the row number of the column header information (colheadrow), and the row numbers of rows to be skipped (skiprows). For example, rows need to be skipped when there are intervening rows between the column head row and the start of the time series data.

Look at the beginning of the ASCII file disney.dat in the ftsdata subdirectory:

The command line

uses disney.dat to create time series object disfts. This example

The resulting financial time series object looks like this.

There are 782 data points in this object. Only the first few lines are shown here. Also, this object has two other data series, the CLOSE and VOLUME data series, which are not shown here. Note that in creating the financial time series object, ascii2fts sorts the data into ascending chronological order.

The frequency indicator field, freq, is set to 0 for Unknown frequency. You can manually reset it to the appropriate frequency using structure syntax, disfts.freq = 1 for Daily frequency.

With a slightly different syntax, the function ascii2fts can create a financial time series object when time-of-day data is present in the ASCII file. The new syntax has the form

Set timedata to 'T' when time-of-day data is present and to 'NT' when there is no time data. For an example using this function with time-of-day data, see the reference page for ascii2fts.


  Using the Constructor Visualizing Financial Time Series Objects