Using the datafeed toolbox and bloomberg, how do you return a matrix of multiple securties and prices for the same dates?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
cwallen08
2017-3-2
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
回答(1 个)
Tejas
2024-10-24,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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bloomberg Desktop 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!