Skip to content

Return Metadata instead of raising TypeError on invalid requests #38

@ctdunc

Description

@ctdunc

Code Sample, a copy-pastable example if possible

from blp import blp

sec_ids = ["US5949181045", "BMG0684D3054"] #BMG0684D3054 changed domiciles, but index won't update until monthend
with blp.BlpQuery("****") as bbg_conn:
    bbg_data = bbg_conn.bdp(sec_ids, ["dvd_ex_dt", "dvd_pay_dt"])

    print(bbg_data)
>>> ... 
>>> TypeError: Response for 'US5949181045' contains securityError {'securityError': {'source': '24929:rsfrdsv c2', 'code': 43, 'category': 'BAD_SEC', 'message': 'Unknown/Invalid Security  [nid:24929]', 'subcategory': 'INVALID_SECURITY'}}

Problem description

We have a workflow which sometimes places expired security identifiers into blp requests. Generic TypeErrors do not return enough information for us to handle them well without writing logic to parse error messages across the codebase.

Expected Output

It would be great if it returned this securityError as a dict or object so that we may handle it gracefully by dropping the security & retrying the request. On a larger scale, it would be an improvement to allow for more graceful error handling by returning/raising error objects with more metadata.
Happy to work on a PR with changes if this is something you're interested in implementing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions