Using the datafeed toolbox and bloomberg, how do you return a matrix of multiple securties and prices for the same dates?
6 views (last 30 days)
Show older comments
Using the following code
sec = {'MSFT US Equity','AAPL US Equity'}
fromdate = '1/01/2012'; % beginning of date range for historical data
todate = '12/31/2012'; % ending of date range for historical data
period = 'monthly'; % retrieve monthly data
[d,sec] = history(c,sec,fields,fromdate,todate,period)
d will be a 2x1 cell with the prices and their respective dates of MSFT and AAPL. However, I want a 13x3 matrix with the dates in the first column and the prices in the next two columns. I want to do this without a loop, as my ultimate security list will be quite large.
1 Comment
cwallen08
on 2 Mar 2017
Hi Cormac,
Have you tried inputting a cell array for both the fromdate and todate, so that they mirror you sec array? I don't have a bloomberg, so I can't try this but from the documentation, both fromdate and todate can be cell arrays as well. It may be the case that you need to have a 1-1 mapping between sec entries and date entries to get the matrix you're looking for. Good luck
-Cody
Answers (1)
Tejas
on 24 Oct 2024 at 7:10
Hello Cormac,
I am assuming that the cell array 'd', sized 2x1, contains two timetables, each sized 13x2. These timetables represent data for 'MSFT US Equity' and 'AAPL US Equity'. To create a matrix with the first column as dates and the next two columns as prices, consider using the 'synchronize' function. More details about this function are available in this documentation: https://www.mathworks.com/help/matlab/ref/timetable.synchronize.html.
Here is a code snippet demonstrating how to use this function to obtain a 13x3 matrix with data in the desired format:
resultMatrix = d{1};
resultMatrix = synchronize(resultMatrix, d{2}, 'union');
0 Comments
See Also
Categories
Find more on Bloomberg Desktop in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!