Skip to content

Commit

Permalink
binance: switch to rapidfuzz API
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Sep 21, 2023
1 parent 14f1241 commit d4833eb
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions piker/brokers/binance/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
digits_to_dec,
)
from piker.types import Struct
from piker.data import def_iohlcv_fields
from piker.data import (
def_iohlcv_fields,
match_from_pairs,
)
from piker.brokers import (
resproc,
SymbolNotFound,
Expand Down Expand Up @@ -602,22 +605,11 @@ async def search_symbols(
# `open_symbol_search()`?
keys: list[str] = list(fq_pairs)

matches: list[tuple[
Sequence[Hashable], # matching input key
Any, # scores
Any,
]] = fuzzy.extract(
query=pattern.upper(), # since all keys are uppercase
choices=keys,
return match_from_pairs(
pairs=fq_pairs,
query=pattern.upper(),
score_cutoff=50,
)
# repack in dict form
matched_pairs: dict[str, Pair] = {}
for item in matches:
pair_key: str = item[0]
matched_pairs[pair_key] = self._pairs[pair_key]

return matched_pairs

async def bars(
self,
Expand Down

0 comments on commit d4833eb

Please sign in to comment.