Closed anxl2008 closed 3 years ago
Merging #28 (64d3f3e) into master (5a0b5f4) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #28 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 415 415
=========================================
Hits 415 415
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 5a0b5f4...64d3f3e. Read the comment docs.
Is this working in your local environment? Looks like the method not returning anything.
Yes, this works for me. Originally in your code, the call to conn.bbg_session() is wrapped inside bdh/bds/bdp functions to take care of connection when querying the data. alt_connect() essentially is try to doing the same thing but without specifically initiating a data query.
Ultimately, the "globals()[con_sym] = connect_bbg(**kwargs)" line in conn.bbg_session() will assign the blpapi.session object to global namespace, which is then accessible to subsequence call. So there is no need to return anything in alt_connect().
With this change, the alt_connect() call act as a "login" step for alternative authentication method:
from xbbg.conn import alt_connect
from xbbg import blp
alt.connect(auth_method = 'app', app_name = 'some_app_name', server_host = 'xxx.xxx.x.xx')
df = blp.bds(...)
Without this change, say I need to make a bds call in for loop, one will either:
df = blp.bds(..., sess = session)
Got you. Will merge your request and do some renaming to make it more convenient to use.
Appreciated for your contribution
You're welcome. Do whatever renaming needed to make it better. This is a really useful package.
Added alt_connect() function in core/conn.py to support different authentication methods to connect to blpapi. If a user is simply connecting with desktop api (the default method), then there will be no need to call alt_connect(). If a user is using other authentication method (Sever API/ anything else), then user can call alt_connect first to create the connection.
I am only able to tested this with bloomberg Server API authentication and it's working. For completeness, I also adapted other authentication methods listed in blpapi's sample script: https://github.com/msitt/blpapi-python/blob/master/examples/ConnectionAndAuthExample.py (further testing will be required.)