Financial Time Series Toolbox | ![]() ![]() |
Extract data from financial time series object
Syntax
Arguments
Description
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.
|
Examples
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
These commands reproduce the entire time series shown above.
To fetch every other day's data, enter
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 one 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 five-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]
See Also
extfield
, ftsbound
, getfield
, subsref
![]() | extfield | fieldnames | ![]() |