Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with bds() with DVD_HIST_ALL field for AAPL US Equity #27

Open
chepurko opened this issue Jun 6, 2018 · 2 comments
Open

Error with bds() with DVD_HIST_ALL field for AAPL US Equity #27

chepurko opened this issue Jun 6, 2018 · 2 comments

Comments

@chepurko
Copy link

chepurko commented Jun 6, 2018

import pybbg
from datetime import datetime, date, time

import pandas as pd

bbg = pybbg.Pybbg()
bbg.service_refData()

bds_data = bbg.bds('AAPL US Equity', 'DVD_HIST_ALL')

Trying to retrieve bulk static data with the 'bds()' function. It works fine on a ticker like MSFT US Equity but doesn't work for AAPL US Equity and returns the following error:

---------------------------------------------------------------------------
IndexOutOfRangeException                  Traceback (most recent call last)
<ipython-input-15-865841f87f3b> in <module>()
----> 1 bds_data = bbg.bds('AAPL US Equity', 'DVD_HIST_ALL')

~\Anaconda3\lib\site-packages\pybbg\pybbg_k.py in bds(self, security, field, overrides)
    323                             e = row.getElement(j)
    324                             k = str(e.name())
--> 325                             v = e.getValue()
    326                             if k not in data:
    327                                 data[k] = list()

~\Anaconda3\lib\site-packages\blpapi\element.py in getValue(self, index)
    503         valueGetter = _ELEMENT_VALUE_GETTER.get(datatype,
    504                                                 Element.getValueAsString)
--> 505         return valueGetter(self, index)
    506 
    507     def values(self):

~\Anaconda3\lib\site-packages\blpapi\element.py in getValueAsDatetime(self, index)
    434         self.__assertIsValid()
    435         res = internals.blpapi_Element_getValueAsDatetime(self.__handle, index)
--> 436         _ExceptionUtil.raiseOnError(res[0])
    437         return _DatetimeUtil.convertToNative(res[1])
    438 

~\Anaconda3\lib\site-packages\blpapi\exception.py in raiseOnError(errorCode, description)
    143         """
    144         if errorCode:
--> 145             _ExceptionUtil.raiseException(errorCode, description)
    146 
    147 __copyright__ = """

~\Anaconda3\lib\site-packages\blpapi\exception.py in raiseException(errorCode, description)
    135                 description = "Unknown"
    136         errorClass = _ExceptionUtil.__getErrorClass(errorCode)
--> 137         raise errorClass(description, errorCode)
    138 
    139     @staticmethod

IndexOutOfRangeException: Attempt to access an empty scalar element 'Record Date' (0x0005000b)

Works fine for other tickers like GE, IBM... not sure where to start with this one...

@chepurko
Copy link
Author

chepurko commented Jun 6, 2018

Tried this in Excel to see what the data actually looks like - pulled up AAPL and compared versus MSFT. My guess is on Ex-Date 2/13/1996 where I'm guessing the dividend was suspended when they were having trouble - and the Record Date, Payable Date, and Dividend Amount fields are blank (null).

@trentmaetzold
Copy link

I tried to pull div history for 129 names and got the exception on 25 of them. I think we need to catch the IndexOutOfRangeException on line 325. I'll test it on my local version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants