Skip to content

Commit

Permalink
ENH: Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgilbert committed Jan 9, 2022
1 parent 5cbbe47 commit 1fcd020
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 53 deletions.
8 changes: 1 addition & 7 deletions src/blp/blp.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,13 +925,7 @@ def bdib(
"""
query = create_intraday_bar_query(
security,
event_type,
interval,
start_datetime,
end_datetime,
overrides,
options,
security, event_type, interval, start_datetime, end_datetime, overrides, options,
)
res = self.query(query, self.parser, self.collect_to_bdib)
dfs = []
Expand Down
56 changes: 10 additions & 46 deletions src/blp/test/test_blp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ class MockBlpQuery(blp.BlpQuery):
}

def __init__(
self,
host="localhost",
port=8194,
timeout=10000,
parser=None,
cache_data=None,
**kwargs,
self, host="localhost", port=8194, timeout=10000, parser=None, cache_data=None, **kwargs,
):
self._cache = cache_data
super().__init__(host=host, port=port, timeout=timeout, parser=parser, **kwargs)
Expand Down Expand Up @@ -198,8 +192,7 @@ def assert_info_equal(data, exp_data, ignore_overrides=True):
d["message"]["element"]["fieldResponse"], key=lambda x: x["fieldData"]["id"]
)
ed["message"]["element"]["fieldResponse"] = sorted(
ed["message"]["element"]["fieldResponse"],
key=lambda x: x["fieldData"]["id"],
ed["message"]["element"]["fieldResponse"], key=lambda x: x["fieldData"]["id"],
)
if ignore_overrides:
for di in [d, ed]:
Expand Down Expand Up @@ -2451,16 +2444,8 @@ def collector_params():
return {
"ids": ["collect_many_to_bds_single_bulk", "collect_many_to_bds_with_multi_bulk"],
"argvalues": [
(
bulk_reference_parsed_data,
blp.BlpQuery().collect_many_to_bds,
bulk_reference_collected_exp,
),
(
bulk_reference_parsed_data_multi,
blp.BlpQuery().collect_many_to_bds,
bulk_reference_collected_multi_exp,
),
(bulk_reference_parsed_data, blp.BlpQuery().collect_many_to_bds, bulk_reference_collected_exp,),
(bulk_reference_parsed_data_multi, blp.BlpQuery().collect_many_to_bds, bulk_reference_collected_multi_exp,),
],
}

Expand Down Expand Up @@ -2489,12 +2474,7 @@ def test_bdh_infer():
host = HOST
port = PORT
bquery = blp.BlpQuery(host, port, timeout=QUERY_TIMEOUT, field_column_map={}).start()
df = bquery.bdh(
["SPY US Equity"],
["PX_LAST_ACTUAL"],
start_date="20180102",
end_date="20180103",
)
df = bquery.bdh(["SPY US Equity"], ["PX_LAST_ACTUAL"], start_date="20180102", end_date="20180103",)
df_expect = pandas.DataFrame(
[(TS(2018, 1, 2), "SPY US Equity", 268.77), (TS(2018, 1, 3), "SPY US Equity", 270.47)],
columns=["date", "security", "PX_LAST_ACTUAL"],
Expand All @@ -2509,16 +2489,10 @@ def test_bdh_coerce_none():
bquery = blp.BlpQuery(
host, port, timeout=QUERY_TIMEOUT, field_column_map={"PX_VOLUME": lambda x: pandas.Series(x, dtype="float64")}
).start()
df = bquery.bdh(
["DOESCRUD Index"],
["PX_VOLUME", "PX_LAST"],
start_date="20180105",
end_date="20180105",
)
df = bquery.bdh(["DOESCRUD Index"], ["PX_VOLUME", "PX_LAST"], start_date="20180105", end_date="20180105",)
dtypes = {"PX_VOLUME": numpy.dtype("float64")}
df_expect = pandas.DataFrame(
[(TS(2018, 1, 5), "DOESCRUD Index", None, 419515.0)],
columns=["date", "security", "PX_VOLUME", "PX_LAST"],
[(TS(2018, 1, 5), "DOESCRUD Index", None, 419515.0)], columns=["date", "security", "PX_VOLUME", "PX_LAST"],
).astype(dtypes)
assert_frame_equal(df, df_expect)

Expand Down Expand Up @@ -2550,8 +2524,7 @@ def test_bdp_not_applicable(bquery):
df = bquery.bdp(["RSF82 Comdty", "PLG18 Comdty"], ["ID_EXCH_SYMBOL"])
dtypes = {"security": numpy.dtype("O"), "ID_EXCH_SYMBOL": numpy.dtype("O")}
df_expect = pandas.DataFrame(
[["RSF82 Comdty", None], ["PLG18 Comdty", "PL"]],
columns=["security", "ID_EXCH_SYMBOL"],
[["RSF82 Comdty", None], ["PLG18 Comdty", "PL"]], columns=["security", "ID_EXCH_SYMBOL"],
).astype(dtypes)
assert_frame_equal(df, df_expect)

Expand Down Expand Up @@ -2607,12 +2580,7 @@ def bdit_params():
"ids": ["bdit", "bdit_with_condition_codes"],
"argvalues": [
("CL1 Comdty", ["TRADE"], None, dtype_expect),
(
"CL1 Comdty",
["TRADE"],
[("includeConditionCodes", True)],
dtype_expect_cc,
),
("CL1 Comdty", ["TRADE"], [("includeConditionCodes", True)], dtype_expect_cc,),
],
}

Expand Down Expand Up @@ -2645,11 +2613,7 @@ def test_create_historical_query():
}
}
res = blp.create_historical_query(
["SPY US Equity"],
["PX_LAST"],
"20190101",
"20190110",
options=[("periodicitySelection", "DAILY")],
["SPY US Equity"], ["PX_LAST"], "20190101", "20190110", options=[("periodicitySelection", "DAILY")],
)
assert res == exp_res

Expand Down

0 comments on commit 1fcd020

Please sign in to comment.