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

pdblp does not handle responseError in ReferenceDataResponse #74

Open
shjin404 opened this issue Nov 30, 2019 · 3 comments · May be fixed by #75
Open

pdblp does not handle responseError in ReferenceDataResponse #74

shjin404 opened this issue Nov 30, 2019 · 3 comments · May be fixed by #75

Comments

@shjin404
Copy link

Code Sample

fun = blpcon.ref(securities, fundamental_fields, [('EQY_FUND_RELATIVE_PERIOD', relativePeriod)])

Problem description

When daily limit has reached, I get TypeError: string indices must be integers

~\.conda\envs\myconda36\lib\site-packages\pdblp\pdblp.py in ref(self, tickers, flds, ovrds)
    362         logger.info('Sending Request:\n{}'.format(request))
    363         self._session.sendRequest(request, identity=self._identity)
--> 364         data = self._parse_ref(flds)
    365         data = pd.DataFrame(data)
    366         data.columns = ['ticker', 'field', 'value']

~\.conda\envs\myconda36\lib\site-packages\pdblp\pdblp.py in _parse_ref(self, flds, keep_corrId, sent_events)
    377             d = msg['element']['ReferenceDataResponse']
    378             for security_data_dict in d:
--> 379                 secData = security_data_dict['securityData']
    380                 ticker = secData['security']
    381                 if 'securityError' in secData:

TypeError: string indices must be integers

When enabling debug, this is trace:

pdblp.pdblp:INFO:Event Type: 'PARTIAL_RESPONSE'
pdblp.pdblp:INFO:Message Received:
ReferenceDataResponse = {
    responseError = {
        source = "bbdbd2"
        code = -4001
        category = "LIMIT"
        message = "uuid: xxxxxxx, SN: xxxxx, sid: xxxxx Daily capacity reached. [nid:xxxx] "
        subcategory = "DAILY_CAPACITY_REACHED"
    }
}

Expected Output

It would be great if _parse_ref() function can understand the PARTIAL_RESPONSE event type and report actual error rather than TypeError which is hiding underlying error.

Version Information

[paste the output of pdblp.__version__ here below this line]
'0.1.8'

Thank you

Thank you for awesome library.

@shjin404 shjin404 changed the title pdblp does not handle PARTIAL_RESPONSE pdblp does not handle responseError in ReferenceDataResponse Dec 1, 2019
@matthewgilbert
Copy link
Owner

I agree this would be a nice feature to have but will likely not have the time to implement this in the foreseable future. Currently the parsing of the responses happens throughout the library instead of in a centralized place, so implementing this check would be a bit involved. To test would also involve adding mocking since these responses can only be replicated when your limits are hit.

@shjin404
Copy link
Author

shjin404 commented Dec 1, 2019

Thanks. At least I have some fixes that I have currently sprinkled the error checking and it worked fine for my use. I will send a pull request on your way soon.

@shjin404
Copy link
Author

shjin404 commented Dec 1, 2019

Just sent a new pull request. I am trying to figure out how to link the pull request with this issue. I am completely new to Github workflow.

@shjin404 shjin404 linked a pull request Dec 1, 2019 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants