How can I reorder data retrieved using GETDATA and HISTORY methods for Bloomberg V3 API using Datafeed Toolbox 3.5 (R2010a) to obtain prices in the requested order?

2 views (last 30 days)
I am using the HISTORY command to retrieve data from Bloomberg V3 API and as discussed in related solution I am obtaining a different output order.
I'm using the following variables:
indMembers = Original securities list
FF = Prices retrieved from Bloomberg
SecList = New order of securities
I would like to reorder FF to obtain the original securities order I requested in indMembers.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Oct 2022
Edited: MathWorks Support Team on 28 Nov 2022
Due to the new Bloomberg API the data are returned based on the first available one and not based on the original security input list.
Your outputs FF are ordered as in the variable SecList.
Consider the following two methods to reorder these prices accordingly to the original IndMembers list. Check the two attached documents.
The example "reordering.m" is based on a FOR loop:
%% Find sorting vector
% Compare the output string cell array with indMembers to find the actual
% reordering of securities. This reordering index can then be used to index
% into securities prices to reorder accordingly to indMembers.
IX = zeros(size(indMembers));
for i = 1 : length(indMembers)
IX(i) = strmatch(indMembers(i),SecList);
end
%% Reorder prices
FF_ord = FF(IX);
At each iteration I compare the original string with the full list of reordered securities to identify the new position that is collected in the variable IX. IX is then representing the permutation of the original list performed by the Bloomberg V3 API. This matrix can then be used to index into your prices to reorder them accordingly to your original list (indMembers).
The second attached solution is removing the FOR loop for a shorter approach based on the CELLFUN instruction:
This is just a rewriting of the first example in a more compact form using the same operation on each single cell.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2010a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!