[python-win32] Connecting to Bloomberg

michel.gba at derivativepartners.com michel.gba at derivativepartners.com
Fri Apr 20 09:36:41 CEST 2012


Dear Team,

I want to connect to Bloomberg with Python 3.2.

Looking on internet I found couple of programs written by diverse authors. I implemented by It does not work.

I followed the following steps, I included the python code and the error messages:

I will really appreciate if you could help me.

(Please forward to the right person).

 

Regards,

Michel

 

Step 1 : Install Bloomberg Desktop API v3 from API <GO> download page (file is contained in DAPI_2.zip)

Step 2 : Download and install : ActiveState Python x86 (Key point : not the 64-bit version)

Step 3 : (For safety) :

 

Start menu > start > all programmes > bloomberg > api environment diagnostics > 

start diagnostic tool

repair if needed. Ignore settings errors.

 

Step 4 : In any directory, run the minimal.py file given below : 

python minimal.py

-------------- minimal.py -------------- 

 

import win32com.client

from pythoncom import PumpWaitingMessages

from time import time

 

class EventHandler:

    def OnProcessEvent(self, result)

        event = win32com.client.gencache.EnsureDispatch(result) 

        iterator = event.CreateMessageIterator()

        while iterator.Next():

            print "EventType[%d] -> %s" % (event.EventType, iterator.Message.MessageTypeAsString,)

            

session = win32com.client.DispatchWithEvents('blpapicom.Session.1' , EventHandler)

 

## Each one of these gives rise to another message

session.Start()

started = session.OpenService('//blp/mktdata')

 

endTime = time() + 2

while True:

    PumpWaitingMessages()

    if endTime < time():                

     break           

    

Error Message:

Traceback (most recent call last):

  File "C:\Python32\Pythondev\minimal.py", line 12, in <module>

    session = win32com.client.DispatchWithEvents('blpapicom.Session.1' , EventHandler)

  File "C:\Python32\lib\site-packages\win32com\client\__init__.py", line 245, in DispatchWithEvents

    disp = Dispatch(clsid)

  File "C:\Python32\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch

    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)

  File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName

    return (_GetGoodDispatch(IDispatch, clsctx), userName)

  File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch

    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)

pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

 

 

 

-----------------------------------------------

Michel Gba

Praktikant

Derivative Partners Research AG

Splügenstrasse 10

8002 Zürich, Schweiz

 

tel: +41 (0) 44 515 27 79

fax: +41 (0) 43 305 05 31

mail: michel.gba at derivativepartners.com <mailto:michael.schwarz at derivativepartners.com> 

home: www.derivativepartners.com <http://www.derivativepartners.com> 

 

+++ all about structured products on www.payoff.ch <http://www.payoff.ch>  +++

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120420/f35d0fc2/attachment.html>


More information about the python-win32 mailing list