Retrieve multiple stocks with fetch function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Good morning everyone.
The goal is to retrieve a lot of stocks by using 'fetch' function. Is there an existing function to do this or should I use loop cycle?
Thanks in advance.
url = 'https://fred.stlouisfed.org/';
c = fred(url);
t0 = datetime(2020,6,1); %start data
t1 = datetime('today'); % end data
series = { 'SP500','DEXUSEU', 'CPF1M'};
for loop:
d = fetch(c,series{i},t0, t1)
.......
time= datetime(d.Data(:,1),'ConvertFrom','datenum');
stocks_data = = d.Data(:,2);
end
Thanks
0 Kommentare
Antworten (1)
VINAYAK LUHA
am 13 Sep. 2023
Hi Gcicceri,
It is my understanding that you wish to know an efficient approach to retrieve large number of stocks data of multiple series from the “FRED” data server using the fetch function in Computational Finance Toolbox.
To address your query, instead of using a loop, you can pass the array of series directly to the “fetch” function and retrieve a (1 x number of series) structure from which data of a series can be retrieved as below.
x=fetch(c,series,t0,t1);
x(i).Data;
Here "i" is the index of a series in the series array
Refer to the documentation on how to request data from FRED server as follows
Hope this helps.
Regards,
Vinayak Luha
0 Kommentare
Siehe auch
Kategorien
Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!