From 266ecf620605e36349861fe7559a0a4491e4d7e9 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Fri, 8 Nov 2024 21:58:06 +0000 Subject: [PATCH] Minor refactor in open_symbol_search --- piker/brokers/deribit/feed.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/piker/brokers/deribit/feed.py b/piker/brokers/deribit/feed.py index 9cea38ee..5c85e09d 100644 --- a/piker/brokers/deribit/feed.py +++ b/piker/brokers/deribit/feed.py @@ -276,7 +276,16 @@ async def open_symbol_search( async with ctx.open_stream() as stream: + pattern: str async for pattern in stream: - # repack in dict form - await stream.send( - await client.search_symbols(pattern)) + # NOTE: pattern fuzzy-matching is done within + # the methd impl. + pairs: dict[str, Pair] = await client.search_symbols( + pattern, + ) + # repack in fqme-keyed table + byfqme: dict[str, Pair] = {} + for pair in pairs.values(): + byfqme[pair.bs_fqme] = pair + + await stream.send(byfqme)