Is there a way to query the Datastream source to find the start date of a time series when using the Datafeed Toolbox 3.3 (R2009a)?
2 views (last 30 days)
Show older comments
I am using the FETCH command with the Datastream server and would like to be able to specify an arbitrary start date for the timeseries. MATLAB should then retrieve data that is available for any dates after the specified start date.
I need to do this because I am not aware of the date from which data is available for a particular security. Currently, if I have specified a start date that is earlier than the date from which data is available, I get an error message.
CONNECT = datastream(username,passwd,'Datastream',...
'<http://dataworks.thomson.com/Dataworks/Enterprise/1.0'>);
res = fetch(CONNECT,'CNGDP...D',[],'1950-01-01','2009-03-01');
disp(res)
% This request crashes - '1940-01-01' is too early a startdate.
res2 = fetch(CONNECT,'CNGDP...D',[],'1940-01-01','2009-03-01');
res2 = fetch(CONNECT,'CNGDP...D',[],'1940-01-01','2009-03-01');
??? Error using ==> datastream.fetch at 219
Invalid Start Date
Accepted Answer
MathWorks Support Team
on 1 Feb 2010
The Datafeed toolbox (R2009a) does not support the usage of dates for which data is not available. When an earlier date is specified MATLAB throws an error. To determine the first valid date for a security, one can execute the following code
x = fetch(d,'IBM~REP','BDATE')
x.BDATE will show the start date of the data for the security.
Another workaround is to wrap the call to FETCH in a TRY-CATCH construct. As an example,
startdate = datenum('01-Jan-1940');
while(true)
try
fetch(....., trydate);
break;
catch MException
trydate+1;
disp(['Trying start day: ', datestr(trydate)])
end %end of CATCH
end % end of WHILE
0 Comments
More Answers (0)
See Also
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!