How do I run this loop to download data from yahoo finance?

2 ビュー (過去 30 日間)
Laurentiu Galan
Laurentiu Galan 2011 年 11 月 12 日
%Code to Get Matrix
fid=fopen('C:\Users\Laurentiu Galan\Desktop\Tickers2.csv');
C = textscan(fid, '%s');
fclose(fid);
%Grab First Value (Just as check)
thisval=(C{1});
% Calculate Number of Tickers
D=size(thisval);
NumTick=D(1,1);
%Calculate Loop to download tickers
for i:Numtick <--------------Problem
thissym=????????? <--------------Problem
thisurl = strcat('http://ichart.finance.yahoo.com/table.csv?s=', thissym, '&d=10&e=8&f=2011&g=d&a=0&b=1&c=2000&ignore=.csv');
thisdata=urlread(thisurl);
thisfilename = strcat(thissym, '.csv');
outputfile = strcat('C:\Users\Laurentiu Galan\Desktop\tickoutput\',thisfilename);
thisfileid=fopen(outputfile, 'wt')
fprintf(thisfileid, '%s\n',thisdata)
fclose(thisfileid)
How do i make thissym a variable that I can loop to download the data from yahoo finance? Each one of the values in thisval is a ticker.
I really appreciate your help if you can help me out with this!!!

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 12 日
for i=1:NumTick
thissym=thisval{i};
To learn more, see the help
help for
help cellstr
help catch
help continue
  4 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 12 日
You want to save the data to each .csv file according to the symbol name. I don't see any way that you can avoid the for-loop.
Laurentiu Galan
Laurentiu Galan 2011 年 11 月 13 日
thanks fangjun. You solved the question at hand. I am still getting an error related to illegal use of the word catch.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFinancial Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by