Datafeed toolbox history function with specified period 'nil_value' doesn't work

5 visualizzazioni (ultimi 30 giorni)
c = blp;
c.DataReturnFormat = 'table';
myAsset = 'WBA UW Equity';
period = {'yearly', 'non_trading_weekdays','nil_value'};
currency = 'EUR';
T = (datetime('31/12/1999', 'InputFormat', 'dd/MM/yyyy'): calyears : datetime('31/12/2024', 'InputFormat', 'dd/MM/yyyy'))';
BloombergTicker = myAsset;
% Download accounts from Bloomberg and update Accounts
Data = history(c,BloombergTicker,'SUSTAIN_GROWTH_RT' ,T(1), T(end),period,currency);
Data.DATE = datetime(Data.DATE, "ConvertFrom", "datenum");
save('Data', 'Data')
I get this table:
'31-Dec-1999' 15.6474000000000
'31-Dec-2000' 16.6047000000000
'31-Dec-2001' 15.7416000000000
'31-Dec-2002' 15.2272000000000
'31-Dec-2003' 15.1379000000000
'31-Dec-2004' 15.3092000000000
'31-Dec-2005' 15.6553000000000
'31-Dec-2006' 15.5260000000000
'31-Dec-2007' 16.1649000000000
'31-Dec-2008' 14.7080000000000
'31-Dec-2009' 11.2681000000000
'31-Dec-2010' 10.5713000000000
'31-Dec-2011' 13.8749000000000
'31-Dec-2012' 7.73210000000000
'31-Dec-2013' 7.79810000000000
'31-Dec-2014' 3.56310000000000
'31-Dec-2015' 10.8525000000000
'31-Dec-2016' 8.55140000000000
'31-Dec-2017' 8.51290000000000
'31-Dec-2018' 12.7121000000000
'31-Dec-2019' 9.16660000000000
'31-Dec-2020' -17.4810000000000
'31-Dec-2021' 2.08800000000000
'31-Dec-2022' 11.0235000000000
'31-Dec-2023' 11.0235000000000
'31-Dec-2024' 11.0235000000000
the data for '31-Dec-2023' and '31-Dec-2024' should be nan. It works as if period is 'previous_value'.

Risposte (2)

Parag
Parag il 10 Apr 2025
Hi @Maite,
This behavior is likely due to how Bloomberg handles future dates and the interpretation of the 'nil_value' parameter in the history function from MATLAB's Datafeed Toolbox. The period argument is expected to control how Bloomberg treats non-trading days or missing data, but the 'nil_value' option doesn't seem to be correctly interpreted in this context.
When requesting data for future dates (e.g., '31-Dec-2024'), Bloomberg may return the last available value, especially if 'non_trading_weekdays' is used without a clearly supported 'nil_value' equivalent. This can lead to unexpected repeats of values instead of NaN (as expected when no data is available).
Instead use 'non_trading_weekdays','nil' instead of 'nil_value', or filter the future dates manually after retrieving data.
Please refer to this sample MATLAB implementation:
c = blp;
c.DataReturnFormat = 'table';
myAsset = 'WBA UW Equity';
currency = 'EUR';
% Define time range
T = (datetime('31/12/1999', 'InputFormat', 'dd/MM/yyyy'):calyears:datetime('31/12/2024', 'InputFormat', 'dd/MM/yyyy'))';
% Use correct period settings
period = {'yearly', 'non_trading_weekdays', 'nil'}; % Try 'nil' instead of 'nil_value'
% Request data
Data = history(c, myAsset, 'SUSTAIN_GROWTH_RT', T(1), T(end), period, currency);
Data.DATE = datetime(Data.DATE, "ConvertFrom", "datenum");
% Post-process: Replace future values with NaN
today = datetime('today');
Data.Value(Data.DATE > today) = NaN;
save('Data', 'Data')
You can also refer to the following MathWorks documentation for more details:
Hope it helps!

Maite
Maite il 10 Apr 2025
Hi and Thanks,
When I run your code I get:
Error using blp/history (line 153)
Periodicity option nil invalid.

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by