I am using the pdblp
Python wrapper to query historical daily data from Bloomberg.
Based on the package documentation and the post in Python Bloomberg API pdblp intraday request it is not possible to use the pdblp package to query intraday data.
One answer in the above link suggested to use blpapi API directly via the below:
def sendIntradayTickRequest(session, options):
refDataService = session.getService("//blp/refdata")
request = refDataService.createRequest("IntradayTickRequest")
# only one security/eventType per request
request.set("security", options.security)
# Add fields to request
eventTypes = request.getElement("eventTypes")
for event in options.events:
eventTypes.appendValue(event)
# All times are in GMT
if not options.startDateTime or not options.endDateTime:
tradedOn = getPreviousTradingDate()
if tradedOn:
startTime = datetime.datetime.combine(tradedOn,
datetime.time(15, 30))
request.set("startDateTime", startTime)
endTime = datetime.datetime.combine(tradedOn,
datetime.time(15, 35))
request.set("endDateTime", endTime)
else:
if options.startDateTime and options.endDateTime:
request.set("startDateTime", options.startDateTime)
request.set("endDateTime", options.endDateTime)
if options.conditionCodes:
request.set("includeConditionCodes", True)
print "Sending Request:", request
session.sendRequest(request)
I am not familiar with the underlying API and struggle to make sense of the session
and options
objects provided as arguments in the function call. Can someone please provide a simple example on how to use this function to retrieve intraday data?
(I am not referring to OHLC data, which can be queried using the bdib()
function in pdblp
)
you can create a session object with the blpapi package.
You can also pass a function to your session, which gets called for each event that the session returns. Then the session object looks like this:
The response function needs two arguments, event and session: