I am trying to send commands to Bloomberg Terminal using DDE. Eg: to display the Microsoft page I can send:
<blp-1><CANCEL><CANCEL><HOME>MSFT<EQUITY><GO>
This works fine using a VBA library from EXCEL. However I am trying to do the same from a Python script. I am using the code from here (due to some restrictions I cannot use the more standard win32ui/dde python modules)
http://code.activestate.com/recipes/577654-dde-client/
Messages are being passed to the Bloomberg Terminal but are not being interpreted correctly, Eg:
de = DDEClient('WinBlp', 'bbk')
de.execute('<blp-1><CANCEL><CANCEL><HOME>MSFT<EQUITY><GO>')
results in a Bloomberg window popping up, but with garbled text in the command area, something like
????A?????
Has anyone seem something like this?
The solution was to change this line
Initialize = get_winfunc("user32", "DdeInitializeW", UINT, (LPDWORD, DDECALLBACK, DWORD, DWORD))
to
Initialize = get_winfunc("user32", "DdeInitializeA", UINT, (LPDWORD, DDECALLBACK, DWORD, DWORD))
From the MS documentation here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648757(v=vs.85).aspx
DdeInitializeA is the ANSI version of the initializer, rather than than the unicode.