Why do I receive an error when I attempt to use the FETCH function in the Datafeed Toolbox to retrieve historical data that Bloomberg cannot find?

1 view (last 30 days)
When I use these commands:
c = bloomberg;
d = fetch(c,'SMY AU Equity','HISTORY',...
'OPER_MARGIN','01/01/95','01/01/04','y')
close(c);
to attempt to retrieve data for an equity that Bloomberg cannot find, I receive the following error:
??? Error retrieving historical data.
Error in ==> C:\MATLAB6p5p1\toolbox\datafeed\datafeed\bbdatafeed.dll
Error in ==> C:\MATLAB6p5p1\toolbox\datafeed\datafeed\@bloomberg\fetch.m
On line 318 ==> d = bbdatafeed(bbflag,reqval,c.connection,s,fids,
dts(1),verboseflag,dts(2),maxpoints,sectype,perflag);
Error in ==> C:\MATLAB6p5p1\work\BLOOMBERG_DATA_AGSM.m
On line 64 ==> d = fetch(c,string,'HISTORY', 'OPER_MARGIN','01/01/95',
'01/01/04','y')
I would like an empty data set, or one composed of all zeros, to be returned rather than an error.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This error is a result of the way that missing historical data from Bloomberg is handled by the BBDATAFEED function.
To work around this behavior, wrap a "try...catch" statement around the FETCH request, and return zeros if an error is caught. For example, use the following commands:
c = bloomberg;
try
d = fetch(c,'SMY AU Equity',...
'HISTORY','OPER_MARGIN','01/01/95','01/01/04','y')
catch
msg = lasterr;
d = zeros(10,1);
end
close(c);

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!