Closed Rayzola closed 6 years ago
This looks like a bug, thanks for reporting. As an aside, for your example it's better to use ref
than ref_hist
since iterative calls to overrides are not necessary.
The issue occurs from attempting to access elm.getValue()
of a null blpapi.element.Element
. I have not previously seen response types of the form
DVD_HIST = {
Declared Date = 1986-01-01
Ex-Date = 1986-04-11
Record Date = 1986-04-14
Payable Date =
Dividend Amount = 0.280000
Dividend Frequency = "Semi-Anl"
Dividend Type = "Interim"
}
which is causing an issue during unpacking.
for elm in field.elements():
mfld = fld + ":" + str(elm.name())
dataj = [ticker, mfld, elm.getValue()]
dataj.extend(corrId)
data.append(dataj)
Something like this would resolve the issue I believe
for elm in field.elements():
mfld = fld + ":" + str(elm.name())
if not elm.isNull():
val = elm.getValue()
else:
val = pd.np.NaN
dataj = [ticker, mfld, val]
dataj.extend(corrId)
data.append(dataj)
Here is a minimal reproducible example of the issue.
import pdblp
con = pdblp.BCon(debug=True)
con.start()
ovrds = [("DVD_START_DT","19860101"), ("DVD_END_DT", "19870101")]
con.ref("101 HK EQUITY", "DVD_HIST", ovrds=ovrds)
DEBUG:root:Sending Request:
ReferenceDataRequest = {
securities[] = {
"101 HK EQUITY"
}
fields[] = {
"DVD_HIST"
}
overrides[] = {
overrides = {
fieldId = "DVD_START_DT"
value = "19860101"
}
overrides = {
fieldId = "DVD_END_DT"
value = "19870101"
}
}
}
DEBUG:root:Message Received:
ReferenceDataResponse = {
securityData[] = {
securityData = {
security = "101 HK EQUITY"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
DVD_HIST[] = {
DVD_HIST = {
Declared Date = 1986-09-26
Ex-Date = 1986-10-31
Record Date = 1986-11-01
Payable Date = 1986-11-17
Dividend Amount = 0.720000
Dividend Frequency = "Semi-Anl"
Dividend Type = "Final"
}
DVD_HIST = {
Declared Date = 1986-01-01
Ex-Date = 1986-04-11
Record Date = 1986-04-14
Payable Date =
Dividend Amount = 0.280000
Dividend Frequency = "Semi-Anl"
Dividend Type = "Interim"
}
}
}
}
}
}
If you update to the newest version of master
from Github this should resolve the issue.
Tried to pull out some historical dividend data through ref() and 'DVD_HIST', but encountered the error "IndexOutOfRangeException".
I did a check on the Bloomberg terminal, there is an empty "payable date" in one of the dividends being pulled out which might cause this issues. Is there a workaround to this "IndexOutOfRangeException" issue?
This codes works perfectly fine
But if I change the starting date to include the dividend with the empty "payable date" as follow:
I got the error message:
Thanks