MATLAB: How to get historical prices of each month’s last trading day from Bloomberg

activebloombergdatafeedDatafeed Toolboxdayshistorymonthtrading

When I execute:
>> sec = '3864 JP Equity';
>> fields = {'PX_LAST'};
>> fromdate = '1/31/1985';
>> todate = '09/30/2018';
>> period = 'monthly';
>> [d,sec] = history(c,sec,fields,fromdate,todate,period);
The return dates always alternate between 28-Feb or 30th of the month, which are not the last trading days for the historical prices.

Best Answer

To get the historical price for the last trading days, use the 'active_days_only' option when defining the "period" name-value pair arguments:
>> period = {'monthly', 'active_days_old'};
>> [d,sec] = history(c,sec,fields,fromdate,todate,period);
You can refer to the 'period' section of the "history" function for more information about the use case above: