| Financial Toolbox™ | ![]() |
newfts = fetch(oldfts, StartDate, StartTime, EndDate, EndTime, delta, dmy_specifier, time_ref)
oldfts | Existing financial time series object. |
StartDate | First date in the range from which data is to be extracted. |
StartTime | Beginning time on each day. If you do not require specific times or oldfts does not contain time information, use []. If you specify StartTime, you must also specify EndTime. |
EndDate | Last date in the range from which data is to be extracted. |
EndTime | Ending time on each day. If you do not require specific times or oldfts does not contain time information, use []. If you specify EndTime, you must also specify StartTime. |
delta | Skip interval. Can be any positive integer. Units for the skip interval specified by dmy_specifier. |
dmy_specifier | Specifies the units for delta. Can be
|
time_ref | Time reference intervals or specific times. Valid time reference intervals are 1, 5, 15, or 60 minutes. Enter specific times as 'hh:mm'. |
newfts = fetch(oldfts, StartDate, StartTime, EndDate, EndTime, delta, dmy_specifier, time_ref) requests data from a financial time series object beginning from the start date and/or start time to the end date and/or end time, skipping a specified number of days, months, or years.
Note If time information is present in oldfts, using [] for start or end times results in fetch returning all instances of a specific date. |
Example 1. Create a financial time series object containing both dates and times:
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'];
dates_times = cellstr([dates, repmat(' ',size(dates,1),1),...
times]);
myFts = fints(dates_times,(1:6)',{'Data1'},1,'My first FINTS')
myFts =
desc: My first FINTS
freq: Daily (1)
'dates: (6)' 'times: (6)' 'Data1: (6)'
'01-Jan-2001' '11:00' [ 1]
' " ' '12:00' [ 2]
'02-Jan-2001' '11:00' [ 3]
' " ' '12:00' [ 4]
'03-Jan-2001' '11:00' [ 5]
' " ' '12:00' [ 6]
To fetch all dates and times from this financial time series, enter
fetch(myFts,'01-Jan-2001',[],'03-Jan-2001',[],1,'d')
or
fetch(myFts,'01-Jan-2001','11:00','03-Jan-2001','12:00',1,'d')
These commands reproduce the entire time series shown above.
To fetch every other day's data, enter
fetch(myFts,'01-Jan-2001',[],'03-Jan-2001',[],2,'d')
This produces
ans =
desc: My first FINTS
freq: Daily (1)
'dates: (4)' 'times: (4)' 'Data1: (4)'
'01-Jan-2001' '11:00' [ 1]
' " ' '12:00' [ 2]
'03-Jan-2001' '11:00' [ 5]
' " ' '12:00' [ 6]
Example 2. Create a financial time series object with time intervals of less than 1 hour:
dates2 = ['01-Jan-2001';'01-Jan-2001'; '01-Jan-2001';...
'02-Jan-2001'; '02-Jan-2001';'02-Jan-2001'];
times2 = ['11:00';'11:05';'11:06';'12:00';'12:05';'12:06'];
dates_times2 = cellstr([dates2, repmat(' ',size(dates2,1),1),...
times2]);
myFts2 = fints(dates_times2,(1:6)',{'Data1'},1,'My second
FINTS')
myFts2 =
desc: My second FINTS
freq: Daily (1)
'dates: (6)' 'times: (6)' 'Data1: (6)'
'01-Jan-2001' '11:00' [ 1]
' " ' '11:05' [ 2]
' " ' '11:06' [ 3]
'02-Jan-2001' '12:00' [ 4]
' " ' '12:05' [ 5]
' " ' '12:06' [ 6]
Use fetch to extract data from this time series object at 5-minute intervals for each day starting at 11:00 o'clock on January 1, 2001.
fetch(myFts2,'01-Jan-2001',[],'02-Jan-2001',[],1,'d',5)
desc: My second FINTS
freq: Daily (1)
'dates: (4)' 'times: (4)' 'Data1: (4)'
'01-Jan-2001' '11:00' [ 1]
' " ' '11:05' [ 2]
'02-Jan-2001' '12:00' [ 4]
' " ' '12:05' [ 5]
You can use this version of fetch to extract data at specific times. For example, to fetch data only at 11:06 and 12:06 from myFts2, enter
fetch(myFts2,'01-Jan-2001',[],'02-Jan-2001',[],1,'d',...
{'11:06';'12:06'})
ans =
desc: My second FINTS
freq: Daily (1)
'dates: (2)' 'times: (2)' 'Data1: (2)'
'01-Jan-2001' '11:06' [ 3]
'02-Jan-2001' '12:06' [ 6]
extfield, ftsbound, getfield, subsref
![]() | fbusdate | fieldnames | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |