Reputation: 507
I have searched for the answer but unfortunately I have not been able to find it for the 'new' APIv3 that supports Python 2.7.
Full disclosure, I am very new to Python.
I am able to establish a connection with Bloomberg and query historical data with the included example(SimpleHistoryExample.py), however I am having trouble adding it to a simple list. It prints out the data in what looks like jagged lists:
HistoricalDataResponse = {
securityData = {
security = "IBM US Equity"
eidData[] = {
}
sequenceNumber = 0
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2006-01-31
PX_LAST = 81.300000
OPEN = 82.450000
}
fieldData = {
date = 2006-02-28
PX_LAST = 80.240000
OPEN = 80.900000
}
ETC......
All I am trying to do is query ex. "BAC US EQUITY" and get "PX_LAST" from DATE1 to DATE2 into a list ex.listHistPrices which I then can slice and dice however I see fit.
Unfortunately I can't find any documentation for the Python SDK and only examples.
Any help would be appreciated.
Upvotes: 3
Views: 1281
Reputation: 507
I found the exact code I need on github!
https://github.com/kyuni22/pybbg/blob/master/pybbg/pybbg_k.py
The only other thing needed was to get and install Pandas with the dependencies
Upvotes: 2
Reputation: 9946
i use a 2-step approach for this:
store the data from bberg in a bottomless defaultdict
:
def dd():
return defaultdict(dd)
convert that to a pandas DataFrame
for easier access using from_dict
note, this will use a lot of memory on larger datasets.
Upvotes: 0