Using the datafeed toolbox and bloomberg, how do you return a matrix of multiple securties and prices for the same dates?
조회 수: 4 (최근 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일
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!