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
skiprows
argument (see below) is specified.
'ddmmmyy'
or 'ddmmmyyyy'
'mm/dd/yy'
or 'mm/dd/yyyy'
'dd-mmm-yy'
or 'dd-mmm-yyyy'
'mmm.dd,yy'
or 'mmm.dd,yyyy'
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
.
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:
Walt Disney Company (DIS) Daily prices (3/29/96 to 3/29/99) DATE OPEN HIGH LOW CLOSE VOLUME 3/29/99 33.0625 33.188 32.75 33.063 6320500 3/26/99 33.3125 33.375 32.75 32.938 5552800 3/25/99 33.5 33.625 32.875 33.375 7936000 3/24/99 33.0625 33.25 32.625 33.188 6025400...
uses disney.dat
to create time series object disfts
. This example
disney.dat
The resulting financial time series object looks like this.
disfts = desc: Walt Disney Company (DIS) freq: Unknown (0) 'dates: (782)' 'OPEN: (782)' 'HIGH: (782)' 'LOW: (782)' '29-Mar-1996' [ 21.1938] [ 21.6250] [ 21.2920] '01-Apr-1996' [ 21.1120] [ 21.6250] [ 21.4170] '02-Apr-1996' [ 21.3165] [ 21.8750] [ 21.6670] '03-Apr-1996' [ 21.4802] [ 21.8750] [ 21.7500] '04-Apr-1996' [ 21.4393] [ 21.8750] [ 21.5000] '05-Apr-1996' [ NaN] [ NaN] [ NaN] '09-Apr-1996' [ 21.1529] [ 21.5420] [ 21.2080] '10-Apr-1996' [ 20.7387] [ 21.1670] [ 20.2500] '11-Apr-1996' [ 20.0829] [ 20.5000] [ 20.0420] '12-Apr-1996' [ 19.9189] [ 20.5830] [ 20.0830] '15-Apr-1996' [ 20.2878] [ 20.7920] [ 20.3750] '16-Apr-1996' [ 20.3698] [ 20.9170] [ 20.1670] '17-Apr-1996' [ 20.4927] [ 20.9170] [ 20.7080] '18-Apr-1996' [ 20.4927] [ 21.0420] [ 20.7920]
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 | ![]() |