Skip to content

Commit e84b97f

Browse files
committed
Omit unexported instruments from datasetId lookup
1 parent 73a8239 commit e84b97f

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

tardis_dev/instrument_info.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,14 @@ async def _find_instrument_symbols_for_exchange(
186186
http_proxy=http_proxy,
187187
)
188188

189+
if selector == "datasetId":
190+
symbols = [instrument["datasetId"] for instrument in instruments if "datasetId" in instrument]
191+
else:
192+
symbols = [instrument["id"] for instrument in instruments]
193+
189194
return {
190195
"exchange": exchange,
191-
"symbols": [_get_symbol(instrument, selector) for instrument in instruments],
196+
"symbols": symbols,
192197
}
193198

194199

@@ -230,10 +235,3 @@ def _get_instrument_info_url(
230235
return f"{url}?filter={encoded_filter}"
231236

232237
return url
233-
234-
235-
def _get_symbol(instrument: Mapping[str, Any], selector: InstrumentSymbolSelector) -> str:
236-
if selector == "datasetId":
237-
return instrument.get("datasetId") or instrument["id"]
238-
239-
return instrument["id"]

tests/test_instrument_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def test_find_instrument_symbols_async_selects_id_or_dataset_id():
3636
dataset_result = await find_instrument_symbols_async(["binance"], {"active": True}, selector="datasetId")
3737

3838
assert id_result == [{"exchange": "binance", "symbols": ["btcusdt", "ethusdt"]}]
39-
assert dataset_result == [{"exchange": "binance", "symbols": ["BTCUSDT", "ethusdt"]}]
39+
assert dataset_result == [{"exchange": "binance", "symbols": ["BTCUSDT"]}]
4040

4141

4242
@pytest.mark.asyncio

0 commit comments

Comments
 (0)