-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkYahoo.m
executable file
·70 lines (52 loc) · 1.59 KB
/
checkYahoo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
clear
ticker=struct('number',0,'name','','sector','');
[tno,tnm,tsc] = ImportTickerFromCSV('HKEquity.csv');
for(i=1:length(tno))
ticker(i).number=tno(i);ticker(i).name=tnm(i);ticker(i).sector=tsc(i);
end
clc;
% ticker(1:1033).number/name/sector
secCount=1;
secName(1)=ticker(1).sector;
secNum(1)=0;
clc;
SelectedTickerNo=[];
for(i=1:length(tno))
SelectedTickerNo(length(SelectedTickerNo)+1)=ticker(i).number;
tickername(length(SelectedTickerNo))=ticker(i).name;
end
SelectedTickerName=cell(length(SelectedTickerNo),1);
% Get Stock Name in Selected Industries.
for(i=1:length(SelectedTickerNo))
SelectedTickerName(i)={strcat(num2str(SelectedTickerNo(i)),'.HK')};
for(j=length(SelectedTickerName{i})+1:7)
SelectedTickerName(i)=strcat('0',SelectedTickerName(i));
end
end
result=SelectedTickerName;
p=[];
tickinperiod=0;
for(i=1:length(SelectedTickerName))
try
data=fetch(yahoo,SelectedTickerName(i),'Adj Close',now-5,now,'d');
Stock(i).price=data;%Now->Old => Old to Now.
%Progress Bar
fetchProgress=(180*i/(1.0*length(ticker)));
clc;
fprintf('\nDownloading data from Yahoo!...\n\n\n ');
for(j=1:180)
if(j<=fetchProgress)
fprintf('>');
else
fprintf('-');
end
end
if(length(Stock(i).price)>tickinperiod)
tickinperiod=length(Stock(i).price);
end
catch
p=[p;SelectedTickerName(i)];
end
end
fprintf('\n\n Gao Ding!\n\nmemeda');
disp(p);