pdblp icon indicating copy to clipboard operation
pdblp copied to clipboard

Adding a limit to brsch

Open TSchulz85 opened this issue 7 years ago • 14 comments

Hi,

Thanks a lot for your work, I use this project a lot and really like it! I currently started using the bsrch function and it seems it uses the standard limit of 5,000 results. In excel you can get up to 20,000 results with this function: =BSRCH("FI:BONDS","LIMIT=20000") Would it be possible to add this limit as well? I am fairly new to python, so struggling a bit programming it myself.

Thanks, Tobias

TSchulz85 avatar Aug 16 '17 14:08 TSchulz85

Glad you find the project helpful. This might be possible but I'm unsure since I don't believe bsrch is documented in the Developers Guide. I also don't currently have access to a Bloomberg connection so I can't really test this. In theory it would be fairly straightforward if the ExcelGetGridRequest behaves similarly to the HistoricalDataRequest, you could add an ovrd parameter to the function call and then something like

overrides = request.getElement("overrides")
for ovrd_fld, ovrd_val in ovrds:
    ovrd = overrides.appendElement()
    ovrd.setElement("fieldId", ovrd_fld)
    ovrd.setElement("value", ovrd_val)

@MarekOzana thoughts on this?

matthewgilbert avatar Aug 16 '17 15:08 matthewgilbert

I am tied with other things right now, let me ask Bloomberg help and come back.

MarekOzana avatar Aug 16 '17 18:08 MarekOzana

Yes it seems like returning all the results is better default behaviour than limiting the returned data. Having not actually used this functionality and not currently having access to BBG I can't implement this change but if someone wants to implement I'm happy to accept a pull request. Otherwise I can look at implementing next time I have access to BBG.

matthewgilbert avatar Aug 21 '17 18:08 matthewgilbert

So by default, there is a limit of 5000 items, but you can increase the limit by specifying the override of "LIMIT=20000". I'm happy to test some things via BBG, but unfortunately, my programming skills are limited, thus I would need some instructions what to do.

TSchulz85 avatar Aug 22 '17 13:08 TSchulz85

As previously discussed, since this is undocumented this is just a guess, but something like this may work

overrides = request.getElement("overrides")
ovrd = overrides.appendElement()
ovrd.setElement("fieldId", "LIMIT")
ovrd.setElement("value", 20000)

You could add this to the bsrch function in the pdblp.py module after the request is created, i.e. after line 462. I'd play around with the value of 20000 to make sure it's actually having the desired effect. If you are doing this make sure to set the debug flag to True since this can be quite helpful.

matthewgilbert avatar Aug 22 '17 17:08 matthewgilbert

Basically I get this error back

NotFoundException: Attempt to access unknown sub-element 'overrides' on element 'ExcelGetGridRequest' (0x0006000d)

TSchulz85 avatar Aug 23 '17 11:08 TSchulz85

Hmmm, it looks as if unlike other request types, e.g. HistoricalDataRequest and ReferenceDataRequest, overrides are not supported. To the best of my understanding since this is undocumented functionality I'm unsure how to move forward on this.

matthewgilbert avatar Aug 23 '17 14:08 matthewgilbert

Checking back on this, I don't seem to be able to reproduce this issue. Possibly Bloomberg has changed the behavior of the upsteam ExcelGetGridRequest service. @TSchulz85 are you still encountering this problem? e.g. I don't seem to have an issue with requests limited to 5000 results.

con = pdblp.BCon()   
df = con.bsrch("FI:BONDS")
df.shape
(136392, 1)

matthewgilbert avatar Feb 11 '18 05:02 matthewgilbert

Hmm, I actually still have the same problem. Any idea what I could modify to make it work?

TSchulz85 avatar Feb 13 '18 09:02 TSchulz85

Hmmm, so to be clear when you run the code I posted above you are seeing 5000? e.g.

con = pdblp.BCon()   
df = con.bsrch("FI:BONDS")
df.shape
(5000, 1)

matthewgilbert avatar Feb 13 '18 13:02 matthewgilbert

Almost exactly:

con = pdblp.BCon()   
con.start()
df = con.bsrch("FI:BONDS")
df.shape
Out[16]: (5000, 1)

TSchulz85 avatar Feb 13 '18 13:02 TSchulz85

I'm not exactly sure what is happening. My guess would be that there is some setting associated with a user profile in a BBG terminal that defines the behaviour. In excel I understand that you can use the LIMIT keyword but since this relies on the ExcelGetGridRequest which has no documentation it is a bit unclear how to do this in the Bloomberg Open API. A possible solution would be to ask the BBG help if there is a user profile setting you could change. Alternatively you could ask what the corresponding override for their Bloomberg Open API is for the excel call =BSRCH("FI:BONDS","LIMIT=20000")

matthewgilbert avatar Feb 13 '18 13:02 matthewgilbert

Has anyone ever figured out how to use ExcelGetGridRequest? BBG support no help.

prd1 avatar Jul 01 '19 13:07 prd1

same problem

gioxc88 avatar Apr 20 '22 12:04 gioxc88