matthewgilbert / blp

Pythonic interface for Bloomberg Open API
Apache License 2.0
112 stars 24 forks source link

//blp/mktbar enhancement #21

Closed obronco closed 1 year ago

obronco commented 1 year ago

I managed to get the mktbar service working by changing a few lines in blp.py:

class EventHandler:

def marketdata_event(self, event):
    event_name = _EVENT_DICT[event.eventType()]
    for n, msg in enumerate(event):
        if msg.messageType() in _MARKET_DATA_EVENTS:  # replace == with in

and _MARKET_DATA_EVENTS becomes a list:

_MARKET_DATA_EVENTS = [ blpapi.Name("MarketDataEvents"), blpapi.Name("MarketBarStart"), blpapi.Name("MarketBarUpdate") ]

Now when calling blp.BlpStream, I use

with blp.BlpStream(setDefaultSubscriptionService="//blp/mktbar") as bs: default_args = { "fields": ["LAST_PRICE"], "options" : "interval=1" } bs.subscribe({ "USDJPY Curncy": default_args})

matthewgilbert commented 1 year ago

Ahh this is a good example and seems fairly easty to support. I haven't used this service before hence the lack of support. Happy to except a PR on this feature.

matthewgilbert commented 1 year ago

Closed by https://github.com/matthewgilbert/blp/pull/22