0

I'm trying to use Yahoo API in MATLAB R2015a to retrieve historical data (prices) for commodities. I can get the price for current date, but not for a historical date range. So for example Last price for CK15.CBT Corn May 15:

clear
clc
c = yahoo;
a = fetch(c,'CK15.CBT','Last');
disp (a);

d = fetch(c,'CK15.CBT','Last','02/02/15','02/05/15');
disp (d);

Displaying "a" works ok, but "d" returns the following error messages:

Error using yahoo/fetch>isdatafield (line 543)
Current data field specified but historical data requested.

Error in yahoo/fetch (line 74)
  elseif isdatafield(varargin{1},numinputs)

Error in Untitled (line 7)
d = fetch(c,'CK15.CBT','Last','02/02/15','02/05/15');

Could you please help me how to work with yahoo API in MATLAB to get commodities prices for specified time range? Or do you have a suggestion for any other way how to do it?

Thank you

Petr
  • 1
  • 2

1 Answers1

0

I don't have the Datafeed toolbox so I cannot check, but you probably don't want to invoke the parameter 'Last' when you request a range of values.

d = fetch(c,'CK15.CBT','02/02/15','02/05/15');

should work better.

Ratbert
  • 5,463
  • 2
  • 18
  • 37
  • thanks for your reply. Unfortunately that is not the problem. I think I found the problem now - it is the fact that it's a commodity. Datafeed is capable of getting data in a specified range for stocks, but not for commodities - for those only the last values, not historical. Would anyone know any other API to use to get the historical data for commodities? – Petr Apr 19 '15 at 12:38