Main Content

ascii2fts

Create financial time series object from ASCII file

ascii2fts is not recommended. Use timetable instead. For more information, see Convert Financial Time Series Objects fints to Timetables.

Description

example

FTS = ascii2fts(filename,descrow,colheadrow,skiprows) creates a financial time series object FTS from the ASCII file named filename. This form of the function can only read a data file without time-of-day information and create a financial time series object without time information. If time information is present in the ASCII file, an error message appears.

The general format of the text data file is

  • Can contain header text lines.

  • Can contain column header information. The column header information must immediately precede the data series columns unless skiprows is specified.

  • Leftmost column must be the date column.

  • Dates must be in a valid character vector date format:

    • 'ddmmmyy' or 'ddmmmyyyy'

    • 'mm/dd/yy' or 'mm/dd/yyyy'

    • 'dd-mmm-yy' or 'dd-mmm-yyyy'

    • 'mmm.dd,yy' or 'mmm.dd,yyyy'

  • Time information must be in 'hh:mm' format.

  • Each column must be separated either by spaces or a tab.

example

FTS = ascii2fts(___,timedata) creates an FTS object with time information.

Examples

collapse all

  • If your data file contains no description or column header rows:

    1/3/95   36.75   36.9063   36.6563   36.875    1167900
    1/4/95   37      37.2813   36.625    37.1563   1994700  ...
    

    You can create a financial time series object from it with the simplest form of the ascii2fts function:

    myinc = ascii2fts('my_inc.dat')
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In ascii2fts (line 64) 
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In fints/display (line 66) 
    
    myinc = 
     
    desc:  my_inc.dat
    freq:  Unknown (0)
    
    'dates:  (2)'  'series1: (2)'  'series2: (2)'   'series3: (2)'...
    '03-Jan-1995'  [   36.7500]    [    36.9063]    [   36.6563]
    '04-Jan-1995'  [        37]    [    37.2813]    [   36.6250]
    
  • If your data file contains description and column header information with the data series immediately following the column header row:

    International Business Machines Corporation (IBM)
    Daily prices (1/3/95 to 4/5/99)
    DATE     OPEN    HIGH      LOW       CLOSE     VOLUME
    1/3/95   36.75   36.9063   36.6563   36.875    1167900
    1/4/95   37      37.2813   36.625    37.1563   1994700  ...
    

    You must specify the row numbers containing the description and column headers:

    ibm = ascii2fts('ibm9599.dat', 1, 3)
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In ascii2fts (line 64) 
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In fints/display (line 66) 
    
    ibm = 
     
    desc:  International Business Machines Corporation (IBM)
    freq:  Unknown (0)
    'dates:  (2)'  'OPEN:  (2)'    'HIGH:  (2)'    'LOW:  (2)' ...
    '03-Jan-1995'  [  36.7500]    [   36.9063]    [  36.6563]
    '04-Jan-1995'  [       37]    [   37.2813]    [  36.6250]
    
  • If your data file contains rows between the column headers and the data series:

    Staples, Inc. (SPLS)
    Daily prices
    DATE     OPEN    HIGH     LOW      CLOSE    VOLUME
    Starting date: 04/08/1996
    Ending date:   04/07/1999
    4/8/96   19.50   19.75    19.25    19.375   548500
    4/9/96   19.75   20.125   19.375   20       1135900  ...
    

    You need to indicate to ascii2fts the rows in the file that must be skipped. Assume that you have called the data file containing the Staples data (staples.dat).

    spls = ascii2fts('staples.dat', 1, 3, [4 5])
    

    The command above indicates that the fourth and fifth rows in the file should be skipped in creating the financial time series object:

    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In ascii2fts (line 64) 
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In fints/display (line 66) 
    
    spls = 
     
    desc:  Staples, Inc. (SPLS)
    freq:  Unknown (0)
    
    'dates:  (2)'  'OPEN:  (2)'    'HIGH:  (2)'    'LOW:  (2)'
    '08-Apr-1996'  [   19.5000]    [  19.7500]     [19.2500]
    '09-Apr-1996'  [   19.7500]    [  20.1250]     [19.3750]
    
  • Create a financial time series object containing time-of-day information.

    Create a data file with time information:

    dates = ['01-Jan-2001';'01-Jan-2001'; '02-Jan-2001'; ... 
    '02-Jan-2001'; '03-Jan-2001';'03-Jan-2001'];
    times = ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00'];
    serial_dates_times = [datenum(dates), datenum(times)];
    data = round(10*rand(6,2));
    stat = fts2ascii('myfts_file2.txt',serial_dates_times,data, ... 
    {'dates';'times';'Data1';'Data2'},'My FTS with Time')
    
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In fts2ascii (line 60) 
    
    stat =
    
         1

    Read the data file back and create a financial time series object:

    MyFts = ascii2fts('myfts_file2.txt','t',1,2,1)
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In ascii2fts (line 64) 
    Warning: FINTS will be removed in a future release. Use TIMETABLE instead. 
    > In fints/display (line 66) 
    
    MyFts = 
     
        desc:  My FTS with Time
        freq:  Unknown (0)
    
        'dates:  (6)'    'times:  (6)'   'Data1:  (6)'  'Data2:  (6)'
        '01-Jan-2001'    '11:00'         [          9]   [          4]
        '     "     '    '12:00'         [          7]   [          9]
        '02-Jan-2001'    '11:00'         [          2]   [          1]
        '     "     '    '12:00'         [          4]   [          4]
        '03-Jan-2001'    '11:00'         [          9]   [          8]
        '     "     '    '12:00'         [          9]   [          0]
    

Input Arguments

collapse all

Name of ascii data file, specified as a character vector.

Data Types: char

Row number in the data file that contains the description used for the description field of the financial time series object, specified as a numeric.

Data Types: double

Row number that has the column header names, specified as a numeric.

Data Types: double

Row numbers to skip in the data file, specified as a scalar numeric or vector.

Data Types: double

Time data indicator, specified as a character vector. Set to 'T' if time-of-day data is present in the ASCII data file or to 'NT' if no time-of-day data is present.

Data Types: char

Output Arguments

collapse all

Financial time series object, returned as a fints object.

Data Types: object

Version History

Introduced before R2006a