Hi All,
I am trying to do a basic for loop over stock tickers to download data.
The data should be kept in seperate tables in the workspace.
my attempt -
tickers = {'SPY', 'AAPL'};
for i = length(tickers);
T(i)=F_Alphavantage('time_series_daily_adjusted', 'symbol', tickers{i}, 'outputsize', 'full')
end

3 件のコメント

Bob Thompson
Bob Thompson 2019 年 2 月 12 日
What problems are you having with this script?
Bob Thompson
Bob Thompson 2019 年 2 月 12 日
Is F_AlphaVantage a script that you wrote, something you found elsewhere, or a built-in MATLAB function? I'm not familiar with it.
Based on the error message, it seems that the error is with the warning function. I would suggest looking up the documentation for that to troubleshoot why it's rejecting the input. There may be a small error with parenthesis, or quotes.
Andrew Czeizler
Andrew Czeizler 2019 年 2 月 13 日
編集済み: Stephen23 2019 年 2 月 13 日
F_Alphavantage is a function that downloads data from an api.
i want to loop over a set of tickers and download the data to workspace.
>> tickers = {'SPY', 'AAPL'};
for i = tickers;
T(i)=F_Alphavantage('time_series_daily_adjusted', 'symbol', tickers, 'outputsize', 'full')
end
Error using warning
The message must be specified as either a character vector, string scalar, or a message structure.
Error in F_Alphavantage (line 90)
warning(['!!!!! Attempt ', num2str(Tries), ' unsuccessful for ', Query]);
I get the above error.
I'm not sure how to run the function and download the array to the workspace.
The function on its own works fine.
Its only when i try and put it in a
for loop that it does not produce the desired output.
when im at home, il put some more information .
many thanks,
best
Andrew

サインインしてコメントする。

 採用された回答

Andrew Czeizler
Andrew Czeizler 2019 年 2 月 15 日

0 投票

Thank you!
worked like a charm.
symbols = {'^GSPC', 'DAX', '^N225', 'GLD', 'QQQ'};
for k = 1:length(symbols)
data{k} = table2timetable(F_Alphavantage('time_series_daily_adjusted', 'symbol', ...
symbols{k}, 'outputsize', 'full'));
end
disp(head(data{1}))

1 件のコメント

Andrew Czeizler
Andrew Czeizler 2019 年 2 月 15 日
編集済み: Andrew Czeizler 2019 年 2 月 15 日
Thank you!
Worked like a charm.
Best,
Andrew

サインインしてコメントする。

その他の回答 (1 件)

Andrew Czeizler
Andrew Czeizler 2019 年 2 月 13 日

0 投票

The below command -
Outputs the correct table. All i want to do is use a for loop, to loop over symbols.
I am running into difficulties when i try to wrap it in a for loop.
The alphavantage function is located here -
https://au.mathworks.com/matlabcentral/fileexchange/64803-fetch-financial-price-series-from-alphavantage
SPY_Daily_Close_Adj = F_Alphavantage('time_series_daily_adjusted', 'symbol', 'AMZN', 'outputsize', 'full');

2 件のコメント

Bob Thompson
Bob Thompson 2019 年 2 月 13 日
My best suggestion is to include cell indexing on your output.
SPY_Daily_Close_Adj{index} = ...
If you are doing that already then please elaborate more on what difficulties you're having.
Andrew Czeizler
Andrew Czeizler 2019 年 2 月 15 日
how do i accept your answer?
Best,
Andrew

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by