Has anyone found away to call Bloomberg BQL API using Pdblp or another package with Python?

2.6k views Asked by At

The BQL works in Excel using what appears to be the same API add-in using the same fields to call the Bloomberg data, i.e PX_LAST. I currently run models in python using pdblp, that works great and I would love to move to the BQL version of the API to optimize data usage outside of the terminal. Is anyone aware of any effort to utilize the BQL in any package? I know someone asked about this last year... looking for an update.

3

There are 3 answers

0
okost On

Quite old but maybe someone comes along this thread... I talked to BBG recently and they have no intention to open the BQL API for Python. They couldn't give me a reason why, when I asked but I guess they want to promote their internal BQNT environment.

1
Herman L On

I use: "from xbbg import blp" This seems to work pretty well.

The syntax is very similar to what one would use in excel e.g.

df = blp.bdh(tickers1, flds=fields, start_date='2017-01-01', end_date='2023-01-25')

There is also: "import blpapi" But I find that less user friendly. You have to initate sessions etc.

0
Pedro Teles On

I've incorporated this functionality into the blp package, which is the successor to pdblp by the same author. Currently, it's accessible exclusively through GitHub:

> pip install git+https://github.com/matthewgilbert/blp.git
from blp import blp

bquery = blp.BlpQuery().start()

bquery.bql(expression="get(px_last()) for(['AAPL US Equity', 'IBM US Equity'])")

Since this is an endpoint without documentation, we haven't yet fully grasped its behavior. So, if anyone comes across any bugs, please feel free to open a GitHub issue.

TIP: For an easy way to create this expression, try Excel's BQL Builder in Advanced View. After previewing the query, you can just "Copy BQL Query String Only."