Reputation: 65
I'm wondering if anyone has been able to use the Bloomberg API within python to pull a piece of intraday historical data for a specific time. There are threads about pulling intraday data for given intervals (5,10,15 minute) but I'm looking to reference a specific time and date (e.g. 01/09/19 13:33:42) and pull the data at that time.
This is possible in excel via a formula with overrides like this:
BDH("AAPL US EQUITY","BID",(DATE + TIME)-0.01,(DATE + TIME)-0.0001,"IntrRw=True","points=1","SIZE=S","TYPE=H","DTS=H","TimeZone=new York","cols=2;rows=1")
Appreciate any thoughts or ideas.
I've been trying to use the xbbg on a simple data request just to figure out the syntax with no luck. Below is the date/time format I have when running this in excel but have no luck. Tried with all overrides in the above excel formula but no luck.
from xbbg import blp
SPXLAST = blp.bdh(tickers='SPX INDEX',flds='PX_LAST',start_date='09-26-18
14:30:25',end_date='09-26-18 14:30:25',TimeZone='New York')
print(SPXLAST)
Have been able to pull only EOD data but nothing for a specific intraday time.
Upvotes: 1
Views: 8765
Reputation: 671
The blpapi is supported in Python. Here is a code snippet:
def sendIntradayTickRequest(session, options, identity = None):
refDataService = session.getService("//blp/refdata")
request = refDataService.createRequest("IntradayTickRequest")
# only one security/eventType per request
request.set("security", "IBM US Equity")
# Add fields to request
eventTypes = request.getElement("eventTypes")
eventTypes.appendValue("TRADE")
eventTypes.appendValue("BID")
eventTypes.appendValue("ASK")
# add more tick types
# All times are in GMT
request.set("startDateTime", "2019-01-15T14:40:00")
request.set("endDateTime", "2019-01-15T14:43:00")
# options
request.set("includeConditionCodes", True)
# add more optionals
print("Sending Request:", request)
session.sendRequest(request)
Upvotes: 1