Serving the Quantitative Finance Community

 
User avatar
twiggie99
Topic Author
Posts: 0
Joined: September 29th, 2009, 9:33 pm

Bloomberg API question

May 16th, 2011, 2:42 pm

I've been reading afoster's posts regarding the Bloomberg API. They've been very helpful, but I'm not advanced in python enough to understand the asychronous code (pasted below).I entered the code into iPython, but I'm not sure what the next step is. I.e., if I want to pull some data asynchronously, what would be the next commands? (Like if I wanted to get the close prices for 4 symbols from 1/1/10 to 12/31/10 and store them in a dictionary.Sorry if this is a basic question, but I'm not sure who else to ask because I don't know anyone else schooled in python.Thanks!http://www.wilmott.com/messageview.cfm? ... 750afoster code:
Last edited by twiggie99 on May 15th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
twiggie99
Topic Author
Posts: 0
Joined: September 29th, 2009, 9:33 pm

Bloomberg API question

May 23rd, 2011, 9:26 pm

Bump..... anyone? Maybe just a clue on how to get started?
 
User avatar
twiggie99
Topic Author
Posts: 0
Joined: September 29th, 2009, 9:33 pm

Bloomberg API question

June 9th, 2011, 1:11 am

Ok, through trial and error, I figured out how to use the classes defined in the code I referenced earlier.I can use the "subscribe" method fine:In [126]: test.request('Subscribe',{'Security':['IBM Equity','T Equity'],'Fields':['ticker','px last']},testCB)In [127]: test.flush()(24, ((u'IBM', 164.34), (u'T', 30.34))) {}But I am having trouble with "GetHistoricalData." For example, these commands work fine for getting all historical data:In [128]: test.request('GetHistoricalData',{'Security':'kkr Equity','Fields':['px last']},testCB)In [129]: test.flush()(25, (((<PyTime:7/14/2010 12:00:00 AM>, 10.5),), ((<PyTime:7/15/2010 12:00:00 AM>, 10.199999999999999),), ((<PyTime:7/16/2010 12:00:00 AM>, 9.6899999999999995), ...... (rest of output snipped)But this code, doesn't work. I must not be formatting the dates correctly, but I can't figure out what's the problem. I've tried "StartDate" instead of "FromDate" as well as using PyTime for the date as well as "YYYYMMDD" format as well as "MM/DD/YYYY" I get the same error below for all.
 
User avatar
twiggie99
Topic Author
Posts: 0
Joined: September 29th, 2009, 9:33 pm

Bloomberg API question

June 9th, 2011, 1:47 am

Played around some more. First issue was I hadn't imported com_error: from pythoncom import com_errorAfter that, I got this error:TypeError: GetHistoricalData() got an unexpected keyword argument 'FromDate'Changed "FromDate" to "StartDate" and it worked! I thought I tried that before, but maybe because I was getting the com_error, it didn't get that far.