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;

Réponses (1)

Yesid Fonseca Vargas
Yesid Fonseca Vargas le 30 Mar 2021

0 votes

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.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by