matthewgilbert / blp

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

[Q] Use B-Pipe or terminal only? #14

Open raszkiewicz opened 2 years ago

raszkiewicz commented 2 years ago

Is this a wrapper on BLPAPI terminal only of can I use with B-Pipe as well? If so how can I authenticate using that library?

matthewgilbert commented 2 years ago

This should be possible by passing an app name to the constructor and then calling authenticate. That being said I have limited experience with the various bpipe authentication procedures so I would recommend testing you can authenticate via blpapi first if you are having issues

raszkiewicz commented 2 years ago

I have created simple Python code which can authenticate for the session but there I have a problem to append any new subscriptions to that session (async events) . I was able to get events for predefined list of ticker so I have ended up closing and then re-opening session with new subscirptions but it creates lag with getting live events between those sessions. That is how I have end up looking for something that maybe already exists and your solution sounds close to what I'm looking for.

B-Pipe uses mutual TLS authentication with a password to the app. For that, what I can see, you (or I) may need to extend your code to cover part from my code:

    tlsOptions = getTlsOptions(priv_cert, root_cert, password, True)
    session_options.setTlsOptions(tlsOptions)

If I will get anything interesting (and working) back I will do PR but first I will need to figure out how to make it more generic with same approach you have passing them via args (I did that via conf file)

matthewgilbert commented 2 years ago

To elaborate on what I wrote above, currently a BlpSession supports authentication via passing in an app and then calling the authenticate method. However, this is only supporting the blpapi.AuthOptions.createWithApp(app) option of authenticating and I believe there are several other ways to authenticate, although I am unfamiliar with these.

One quick and dirty way to handle custom authentication would be to write your own session creation and authentication and then use this. I.e. something like the following

def custom_authenticated_session(session):
    # some logic to authenticate a session
    return session, identity

from blp import blp

bquery = blp.BlpQuery().start()

session, identity = custom_authenticated_session(bquery.session)

bquery.session = session
bquery.identify = identity