Function convert - yahoo to alpha vantage.
1 回表示 (過去 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;
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!