def test_context_manager_passed_session(port, host): sopts = blpapi.SessionOptions() sopts.setServerHost(host) sopts.setServerPort(port) session = blpapi.Session(sopts) session.start() session.nextEvent(1000) session.nextEvent(1000) with pdblp.bopen(session=session) as bb: # NOQA pass
def test_context_manager(port, host): with pdblp.bopen(host=host, port=port) as bb: df = bb.bdh('SPY US Equity', 'PX_LAST', '20150629', '20150630') midx = pd.MultiIndex(levels=[["SPY US Equity"], ["PX_LAST"]], labels=[[0], [0]], names=["ticker", "field"]) df_expect = pd.DataFrame(index=pd.date_range("2015-06-29", "2015-06-30"), columns=midx, data=[205.42, 205.85]) df_expect.index.names = ["date"] assert_frame_equal(df, df_expect)
def test_context_manager(port, host): with pdblp.bopen(host=host, port=port) as bb: df = bb.bdh('SPY US Equity', 'PX_LAST', '20150629', '20150630') midx = pd.MultiIndex(levels=[["SPY US Equity"], ["PX_LAST"]], labels=[[0], [0]], names=["ticker", "field"]) df_expect = pd.DataFrame( index=pd.date_range("2015-06-29", "2015-06-30"), columns=midx, data=[205.42, 205.85] ) df_expect.index.names = ["date"] assert_frame_equal(df, df_expect)