# fetch from yahoo! finance database - varying number of ticks

To test a model with real-life data, I used the fetch-function in matlab to connect to the database of yahoo! finance. My code to try and get 7 different assets' returns is the following:

FromDate = '6/1/2001';
ToDate = '12/31/2012';
Period = 'w';

% DAX = ^GDAXI
ASS1 = fetch(yahoo,'^GDAXI','Close',FromDate,ToDate,Period);
% Nikkei 225= ^N225
ASS3 = fetch(yahoo,'^N225','Close',FromDate,ToDate,Period);
% S&P 500 = ^GSPC
ASS5 = fetch(yahoo,'^GSPC','Close',FromDate,ToDate,Period);
% RUSSELL 1000 GROWTH = IWF
ASS6 = fetch(yahoo,'IWF','Close',FromDate,ToDate,Period);
% RUSSELL 1000 VALUE = IWD
ASS7 = fetch(yahoo,'IWD','Close',FromDate,ToDate,Period);
% RUSSELL 2000 GROWTH = IWO
ASS8 = fetch(yahoo,'IWO','Close',FromDate,ToDate,Period);
% RUSSELL 2000 VALUE = IWN
ASS9 = fetch(yahoo,'IWN','Close',FromDate,ToDate,Period);


I intentionally took weekly ticks because the indices come from different world regions and SE may be open at some place but closed at another. This period contains 604 weeks and 3 days, according to wolframalpha.com. But now, the length of the vectors are like this:

<606x2 double>,
<602x2 double>,
<605x2 double>,
<605x2 double>,
<605x2 double>,
<605x2 double>,
<605x2 double>


i.e. the DAX finds 606 weekly ticks in less than 605 weeks, and the Nikkei 225 only 602. Does anybody have an idea what the reason could be - I cannot think of anything else than the stock exchange being closed three times for an entire week in Japan (Earthquake 2011, maybe, but DAX and NIKKEI have an equal number of returns from January 2011 until april of 2012, namely 70.).

It seems I cannot work around this on the core of the yahoo database; just like I had to adjust the Russell Value 2000 index for a 3-for-1 split because I did not get the adjusted price from yahoo.

But more importantly, with an uneven number of ticks and returns, I cannot use any model. I therefore need to remove those rows from an asset where the date does not appear in every other asset (as the fetch function gives a column with the dates along with the ticks). The code I came up with until now is

for i=1:size(ASS1(:,1))
if sum(ismember(ASS1(i,1),[ASS3,ASS5,ASS6,ASS7,ASS8,ASS9]))<6;
ASS1(i,:)=[]
end
end


to remove row i from asset 1 if it is not in all other Assets. But this is very inflexible with respect to number of assets, and not elegant to run. Is there a function that would help me better?

-
This sounds like a MATLAB question; nothing specific to quant finance. –  chrisaycock Jul 18 '13 at 20:35
I think rather than it being a MATLAB issue (all queries are identical) it may have to do with yahoo data storage or possible the fact that Japan is a week off the grid during golden week (may). It should be easy for you to verify which weeks are missing in the shorter time series. –  Matt Wolf Jul 19 '13 at 2:53
Fetching data should be the work of a database administrator, not quant professionals. –  madilyn Jul 19 '13 at 5:11
Have you tried: mathworks.com/matlabcentral/fileexchange/… –  JohnAndrews Jul 19 '13 at 13:11
–  JohnAndrews Jul 19 '13 at 13:12