Extract from Structure and make a table
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello Everyone,
I downloaded 55 stocks data from yahoo finance for past 5 years.
mydata = hist_stock_data(now-5*365,now,'T','VZ','GOOG','NFLX','FB','EBAY','SBUX','TSLA','NKE','AMZN','KO','CL','PEP','PG','WMT','XOM','EOG','KMI','CVX','WMB','MS','JPM','WFC','BAC','GS','CVS','PFE','JNJ','UNH','ANTM','BA','CAT','HON','FDX','NOC','MSFT','CSCO','MU','ADBE','NVDA','SHW','FMC','MOS','CF','LYB','CBRE','SPG','KIM','BXP','AVB','FE','NI','PPL','AEP','CMS')
The data is stored as 1x55 structure format containing field names Date(1259x1 cell [Open,High,Low,Close,AdjClose,Volume,Ticker](1259x1 double)
I want to extract fields Date,AdjClose and concatenate all three in one table. How do i do it?. Also need to extract Ticker names and replace AdjClose with ticker names
Basically from the structure, I want to extract fields Date and AdjClose for all 55 stocks and make a table and replace AdjClose with ticker names. Any help is greatly appreciated. Thank you
0 comentarios
Respuestas (1)
Image Analyst
el 25 de Dic. de 2020
Editada: Image Analyst
el 25 de Dic. de 2020
See attached demo where I do the same thing - read in Yahoo financial data that I downloaded from their web site.
Or use this function:
Description
T = struct2table(S) converts the structure array, S, to a table, T. Each field of S becomes a variable in T.
T = struct2table(S,Name,Value) creates a table from a structure array, S, with additional options specified by one or more Name,Value pair arguments.
3 comentarios
Image Analyst
el 25 de Dic. de 2020
I don't know - we'd have to play around with it like you've been doing. I can't just imagine trying code and debugging it in my head for something this complicated. You'd have to attach your table in a .mat file or else the original data files and code for reading them in, then someone can try something. But it would be something like getting each value into a column vector then use table():
table(dates, T, VZ, Goog, Nflx, 'VariableNames', {'Date', 'T', 'GOOG', 'NFLX'});
Ver también
Categorías
Más información sobre Web Services en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!