Asynchrone Daten durch Bloomberg, neue Daten-API (COM-v3) mit Python?

Weiß jemand, wie man asynchronen Daten durch Bloomberg, neue Daten-API (COM-v3) mit Python? Ich fand diesen code unten auf wilmott.com und es funktioniert ganz gut, aber es ist für die alte API-version.

Kennt jemand den entsprechenden code für die neue version?

from win32com.client import DispatchWithEvents
from pythoncom import PumpWaitingMessages, Empty, Missing
from time import time

class BBCommEvent:
    def OnData(self, Security, cookie, Fields, Data, Status):
        print 'OnData: ' + `Data`

    def OnStatus(self, Status, SubStatus, StatusDescription):
        print 'OnStatus'

class TestAsync:
    def __init__(self):
        clsid = '{F2303261-4969-11D1-B305-00805F815CBF}'
        progid = 'Bloomberg.Data.1'

        print 'connecting to BBComm'        
        blp = DispatchWithEvents(clsid, BBCommEvent)
        blp.AutoRelease = False
        blp.Subscribe('EUR Curncy', 1, 'LAST_PRICE', Results = Empty)
        blp.Flush()

        end_time = time() + 5

        while 1:
            PumpWaitingMessages()
            if end_time < time():
                print 'timed out'
                break

if __name__ == "__main__":
    ta = TestAsync()
Schreibe einen Kommentar