Quantcast

Connecting to Bloomberg

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Connecting to Bloomberg

michel.gba

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: [hidden email]

home: www.derivativepartners.com

 

+++ all about structured products on www.payoff.ch +++

 


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Connecting to Bloomberg

Tim Roberts
[hidden email] wrote:

>
>
> 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.
>
> ...
>
> 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) :
>

Are you on a 64-bit operating system?  Are you entirely sure that the
Bloomberg Desktop API v3 a 32-bit service?  Remember that you can ONLY
call a 32-bit in-process server from a 32-bit application, and a 64-bit
server from a 64-bit application.

You could check in the registry.  If you find an entry under
    HKEY_CLASSES_ROOT\blpcomapi.Session.1
then you have a 64-bit version.  If you find an entry under
    HKEY_CLASSES_ROOT\Wow6432Node\blpcomapi.Session.1
then you have a 32-bit version.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Connecting to Bloomberg

michel.gba
Hi Tim and all,
Thanks for your reply... I thought would be helpful looking at the error code from win32, I got.
Basically, I'm getting error in the _init_.py line 85, 95, 108 and 245. See below.
I got this error in all programs I try to implement  win32com.client module.
I'm quite new Python user and I will appreciate your kind further help.

Best Regards,
Michel

/************************************ Errror code ******************************************/
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)


/****************************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              
/*****************************************************************************************************/

Best Regards,
Michel

-----------------------------------------------
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: [hidden email]
home: www.derivativepartners.com

+++ all about structured products on www.payoff.ch +++

-----Original Message-----
From: python-win32-bounces+michel.gba=[hidden email] [mailto:python-win32-bounces+michel.gba=[hidden email]] On Behalf Of Tim Roberts
Sent: Freitag, 20. April 2012 18:55
To: Python-Win32 List
Subject: Re: [python-win32] Connecting to Bloomberg

[hidden email] wrote:

>
>
> 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.
>
> ...
>
> 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) :
>

Are you on a 64-bit operating system?  Are you entirely sure that the Bloomberg Desktop API v3 a 32-bit service?  Remember that you can ONLY call a 32-bit in-process server from a 32-bit application, and a 64-bit server from a 64-bit application.

You could check in the registry.  If you find an entry under
    HKEY_CLASSES_ROOT\blpcomapi.Session.1
then you have a 64-bit version.  If you find an entry under
    HKEY_CLASSES_ROOT\Wow6432Node\blpcomapi.Session.1
then you have a 32-bit version.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Connecting to Bloomberg

Tim Roberts
[hidden email] wrote:
> Hi Tim and all,
> Thanks for your reply... I thought would be helpful looking at the error code from win32, I got.
> Basically, I'm getting error in the _init_.py line 85, 95, 108 and 245. See below.
> I got this error in all programs I try to implement  win32com.client module.
> I'm quite new Python user and I will appreciate your kind further help.

You didn't answer any of my questions.  My current theory is that you
are mixing a 32-bit application with a 64-bit DLL, or vice versa.  I
gave you instructions on how to check that in my original reply.


> Are you on a 64-bit operating system?  Are you entirely sure that the Bloomberg Desktop API v3 a 32-bit service?  Remember that you can ONLY call a 32-bit in-process server from a 32-bit application, and a 64-bit server from a 64-bit application.
>
> You could check in the registry.  If you find an entry under
>     HKEY_CLASSES_ROOT\blpcomapi.Session.1
> then you have a 64-bit version.  If you find an entry under
>     HKEY_CLASSES_ROOT\Wow6432Node\blpcomapi.Session.1
> then you have a 32-bit version.
--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Loading...