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

Override missing PX_LAST to get last available price #90

Open
youngfella93 opened this issue Nov 19, 2020 · 2 comments
Open

Override missing PX_LAST to get last available price #90

youngfella93 opened this issue Nov 19, 2020 · 2 comments
Labels

Comments

@youngfella93
Copy link

Hello guys,

So I am trying to retrieve equity prices from Bloomberg using the pdblp module with the BDH function like this below. For some securities, there are dates for which there is no PX_LAST reported and thus I would like to take the previously available in that case. I am using the syntax below but to no success, I believe it's doable but it's probably a detail that I'm missing in the syntax/wording. Note that without the ovrds=[("Fill","P")] part the code executes successfully.

 pref_px_bbg= con.bdh(CUSIPS,['PX_LAST'],Date2,Date1,ovrds=[("Fill","P")],longdata=True)

I get the following error when I run this line:

 KeyError: 'securityData'

If I change the ovrds= to elms=, I get the following error:

 NotFoundException: Sub-element '(null)' does not exist. (0x0006000d)

Please advice on how to solve this.

Thanks!

@matthewgilbert
Copy link
Owner

I would get in touch with Bloomberg Help or post to stack overflow with the tag blpapi since this looks like a Bloomberg specific issue as opposed to pdblp issue, which is just a wrapper on top of blpapi.

@youngfella93
Copy link
Author

Hey

I finally solved my issue by using the xbbg module instead.

By looking at the source code for the pdblp bdh function, I see that there isn't really a parameter meant to capture those additional optional parameters (if I understand it well), could it be the reason why it wasn't able to recognize these commands? Like it isn't really part of the elms nor ovrds which refers to other things when I looked at the API documentation.

    def bdh(self, tickers, flds, start_date, end_date, elms=None,ovrds=None, longdata=False):

where as in the xbbg bdh source code I see a place for other args (in the **kwargs)

  def bdh( tickers, flds=None, start_date=None, end_date='today', adjust=None, **kwargs) -> pd.DataFrame:

which allows me to do something like this:

  pref_px_bbg = blp.bdh(tickers=CUSIPS, flds=['PX_Last'], start_date=Date2, end_date=Date1,Fill='P', Days='A')

That's what I observed, but maybe I am wrong about it..

Thanks!

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

No branches or pull requests

2 participants