Skip to content

Commit

Permalink
Merge pull request matthewgilbert#9 from matthewgilbert/bds-bug
Browse files Browse the repository at this point in the history
BUG: Collector fix for bds bug
  • Loading branch information
matthewgilbert authored Jan 9, 2022
2 parents 8590f7e + 2817dda commit 32b4a03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/blp/blp.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,10 @@ def collect_many_to_bds(self, responses) -> Dict:
sec_dict = res.get(security, {})
for field in response["data"]:
data = response["data"][field]
rows = sec_dict.get(field, [])
rows.extend(data)
sec_dict[field] = rows
if data:
rows = sec_dict.get(field, [])
rows.extend(data)
sec_dict[field] = rows
res[security] = sec_dict
for s in res:
for f in res[s]:
Expand Down
25 changes: 14 additions & 11 deletions src/blp/test/test_blp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,19 +2448,22 @@ def collector_params():
"INDX_MWEIGHT_HIST": pandas.DataFrame({"Index Member": ["BON9", "C N9"], "Percent Weight": [2.89, 5.32]})
}
}
# test for https://github.com/matthewgilbert/blp/pull/8
bulk_reference_parsed_data_empty = [
{"security": "TRAD3 BZ Equity", "fields": ["DVD_HIST_ALL"], "data": {"DVD_HIST_ALL": None}}
]
bulk_reference_empty_collected_exp = {"TRAD3 BZ Equity": {}}

return {
"ids": ["collect_many_to_bds_single_bulk", "collect_many_to_bds_with_multi_bulk"],
"ids": [
"collect_many_to_bds_single_bulk",
"collect_many_to_bds_with_multi_bulk",
"collect_many_empty_to_bds_single_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),
(bulk_reference_parsed_data_empty, blp.BlpQuery().collect_many_to_bds, bulk_reference_empty_collected_exp),
],
}

Expand Down

0 comments on commit 32b4a03

Please sign in to comment.