Function convert - yahoo to alpha vantage.

조회 수: 1 (최근 30일)
Andrew Czeizler
Andrew Czeizler 2019년 3월 14일
답변: Yesid Fonseca Vargas 2021년 3월 30일
Hi All,
I am trying to transpose a scritpt from using yahoo to alpha vantage. I am getting errors and I am not sure why.
Alpha vantage function is -
I know I am asking for a lot, but any help would be very much appreciated.
Script below-
disp('Request data for a number of sybmols and calculate covariance matrix');
q=F_Alphavantage('time_series_intraday', 'symbol', 'MSFT', 'interval', '60min');
clear marketData;
d = datetime('today');
initDate = datetime(addtodate(datenum(d),-5,'year'),'ConvertFrom','datenum');
symbols = {'^GSPC', 'DAX', '^N225', 'GLD', 'QQQ', 'GOOGL', 'AMZN'};
for k = 1:length(symbols)
%this is my change but i am not sure how to change the script
%data = getMarketDataViaYahoo(symbols{k}, initDate);
data = F_Alphavantage('time_series_daily','symbols','symbols{k}', 'interval', 'daily');
ts(k) = timeseries(data.Close, datestr(data(:,1).Date));
tsout = resample(ts(k),ts(1).Time);
marketData(:,k) = tsout.Data;
end
marketData(isnan(marketData)) = 0; %# In case resample() introduced NaNs
normalizedPrice = (marketData - mean(marketData))./std(marketData);
normalizedPrice = normalizedPrice - normalizedPrice(1,:);
tscomb = timeseries(normalizedPrice);
tscomb.TimeInfo = ts(1).TimeInfo;
tscomb.Name = 'normalized';
figure, plot(tscomb);
legend(symbols, 'interpreter', 'none', 'Location', 'best');
covMat = corrcoef(marketData);
covMat(eye(8) == 1) = 0;
figure, heatmap(covMat,'Colormap', parula(3), 'ColorbarVisible', 'on');
ax = gca;
ax.XData = symbols;
ax.YData = symbols;

답변 (1개)

Yesid Fonseca Vargas
Yesid Fonseca Vargas 2021년 3월 30일
Alpha Vantange free version has a limited number of access per minute (5) and limited number of access per day (500). Maybe this is the problem, then you must to add a delay to asure 5 access per minute.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by