Financial Time Series Toolbox | ![]() ![]() |
Construct financial time series object
Syntax
tsobj = fints(dates_and_data) tsobj = fints(dates
, data) tsobj = fints(dates,data
, datanames
) tsobj = fints(dates,data
, datanames, freq
) tsobj = fints(dates,data
, datanames, freq, desc
)
Arguments
dates_and_data |
Column-oriented matrix containing one column of dates and a single column for each series of data. In this format, dates must be entered in serial date number format. If the input serial date numbers encode time-of-day information, the output object contains a column labeled 'dates' containing the date information and another labeled 'times' containing the time information.You can use the function today to enter date information or the function now to enter date with time information. |
dates |
Column vector of dates. Dates may be date strings or serial date numbers and may include time of day information. When entering time-of-day information as serial date numbers, the entry must be a column-oriented matrix when multiple entries are present. If the time-of-day information is in string format, the entry must be a column-oriented cell array of dates and times when multiple entries are present. Valid date and time string formats are
fints . You can use the MATLAB functions today and now to assist in entering date and time information. |
data |
Column-oriented matrix containing a column for each series of data. The number of values in each data series must match the number of dates. If a mismatch occurs, MATLAB will not generate the financial time series object, and you will receive an error message. |
|
Cell array of data series names. Overrides the default data series names. Default data series names are series1 , series2 , ... . |
freq |
Frequency indicator. Allowed values areUNKNOWN , Unknown , unknown , U , u,0 DAILY , Daily , daily , D , d,1 WEEKLY , Weekly , weekly , W , w,2 MONTHLY , Monthly , monthly , M , m , 3 QUARTERLY , Quarterly , quarterly , Q , q,4 SEMIANNUAL , Semiannual , semiannual , S , s,5 ANNUAL , Annual , annual , A , a , 6 Default = Unknown . |
desc |
String providing descriptive name for financial time series object. Default = '' . |
Description
fints
constructs a financial time series object. A financial time series object is a MATLAB object that contains a series of dates and one or more series of data. Before you perform an operation on the data, you must set the frequency indicator (freq
). You can optionally provide a description (desc
) for the time series.
tsobj = fints(dates_and_data)
creates a financial time series object containing the dates and data from the matrix dates_and_data
. If the dates contain time-of-day information, the object contains an additional series of times. The date series and each data series must each be a column in the input matrix. The names of the data series default to series1, ..., seriesn
. The desc
and freq
fields are set to their defaults.
tsobj = fints(
generates a financial time series object containing dates from the dates
, data)
dates
column vector of dates and data from the matrix data. If the dates contain time-of-day information, the object contains an additional series of times. The data matrix must be column-oriented, that is, each column in the matrix is a data series. The names of the series default to series1, ..., seriesn,
where n
is the total number of columns in data. The desc
and freq
fields are set to their defaults.
tsobj = fints(dates,
additionally allows you to rename the data series. The names are specified in the data
, datanames
)
datanames
cell array. The number of strings in datanames
must correspond to the number of columns in data. The desc
and freq
fields are set to their defaults.
tsobj = fints(dates,
additionally sets the frequency when you create the object. The data
, datanames, freq
)
desc
field is set to its default ''
.
tsobj = fints(dates,
provides a description string for the financial time series object.data
, datanames, freq, desc
)
Examples
Example 1: Create a financial time series containing days and data only:
data = [1:6]' data = 1 2 3 4 5 6 dates = [today:today+5]' dates = 731132 731133 731134 731135 731136 731137 tsobjkt = fints(dates, data) tsobjkt = desc: (none) freq: Unknown (0) 'dates: (6)' 'series1: (6)' '08-Oct-2001' [ 1] '09-Oct-2001' [ 2] '10-Oct-2001' [ 3] '11-Oct-2001' [ 4] '12-Oct-2001' [ 5] '13-Oct-2001' [ 6]
Example 2. Expand the above example to include time-of-day information:
dates = [now:now+5]'; tsobjkt = fints(dates, data) tsobjkt = desc: (none) freq: Unknown (0) 'dates: (6)' 'times: (6)' 'series1: (6)' '08-Oct-2001' '14:51' [ 1] '09-Oct-2001' '14:51' [ 2] '10-Oct-2001' '14:51' [ 3] '11-Oct-2001' '14:51' [ 4] '12-Oct-2001' '14:51' [ 5] '13-Oct-2001' '14:51' [ 6]
Example 3. Create a financial time series object when dates and times are located in separate vectors.
Step 1. Create a column vector of times in date number format:
times = datenum(datestr(now:1/24+1/24/60:now+6/24+1/24/60,15)) times = 0.43750000000000 0.47986111111111 0.52222222222222 0.56458333333333 0.60694444444444 0.64930555555556
Step 2. Create a column vector of dates:
Step 3. Concatenate dates and times into a single matrix:
dates_times = [dates, times] dates_times = 1.0e+005 * 7.31133000000000 0.00000437500000 7.31134000000000 0.00000479861111 7.31135000000000 0.00000522222222 7.31136000000000 0.00000564583333 7.31137000000000 0.00000606944444 7.31138000000000 0.00000649305556
Step 4. Create column vector of data:
Step 5. Create financial time series object:
tsobj = fints(dates_times, data) tsobj = desc: (none) freq: Unknown (0) 'dates: (6)' 'times: (6)' 'series1: (6)' '09-Oct-2001' '10:30' [ 1] '10-Oct-2001' '11:31' [ 2] '11-Oct-2001' '12:32' [ 3] '12-Oct-2001' '13:33' [ 4] '13-Oct-2001' '14:34' [ 5] '14-Oct-2001' '15:35' [ 6]
See Also
datenum
, datestr
in the Financial Toolbox documentation
![]() | filter | fintsver | ![]() |