Looping over a set of names and creating a set of variables
5 views (last 30 days)
Show older comments
I currently have download historical quotes for GE, Ford and 3M in both daily and monthly frequencies. I can do all of this with fetch(.), but this means I need to loop across four different arguments: the names ('GE', 'F', 'MMM'), the starting and ending dates, and the frequencies ('d', 'm'). I would then store them into financial time series objects using 'fints.'
(1.) Retrieve the data; (2.) Store it in a time series object within a structure 'data' (say, data.ge, data.f, data.mmm).
Currently, I know how to do exactly that for one series:
ge = fetch(yahoo, 'ge', 'Adj Close', '1/2/1962','1/17/2016','d');
data.ge = fints(ge(:,1), ge(:,2), '', 'd');
I also have the correct names for Ford and 3M Company on yahoo!finance, as well as the appropriate starting and ending dates for each series. If I was doing this work on Stata, I know exactly what I would do because I could use foreach to loop over list of names exactly like I would loop over values -- but, as a newbie on matlab, I need some help! The odds are, I might not even approach the problem the right way for this program.
Thanks
3 Comments
EPAULW
on 12 May 2020
Thanks. A good solution given the way Matlab is used.
The original approach I had in mind is still the one I will use in Stata, because it names individual columns in a useful way.
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!