matthewgilbert / pdblp

pandas wrapper for Bloomberg Open API
MIT License
241 stars 68 forks source link

Clumsy start and stop #7

Closed tschm closed 7 years ago

tschm commented 7 years ago

Matthew, you can use the contextmanager to make the construction of your connectivity a lot more slick, e.g. with

import pdblp
from contextlib import contextmanager

@contextmanager
def b_berg(debug=False):
    con = pdblp.BCon(debug=debug)
    con.start()
    try:
        yield con
    finally:
        con.stop()

you can now use

        with b_berg(debug=False) as bb:
            return bb.ref(tickers, fields, ovrds=ovrds)

Please update

matthewgilbert commented 7 years ago

Okay this should be working now. I don't currently have a connection to Bloomberg though so it is problematic for me to test things.