binance: switch to `rapidfuzz` API

ib_py311_fixes
Tyler Goodlet 2023-09-21 19:44:06 -04:00
parent 14f124164a
commit d4833eba21
1 changed files with 7 additions and 15 deletions

View File

@ -56,7 +56,10 @@ from piker.accounting import (
digits_to_dec, digits_to_dec,
) )
from piker.types import Struct 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 ( from piker.brokers import (
resproc, resproc,
SymbolNotFound, SymbolNotFound,
@ -602,22 +605,11 @@ class Client:
# `open_symbol_search()`? # `open_symbol_search()`?
keys: list[str] = list(fq_pairs) keys: list[str] = list(fq_pairs)
matches: list[tuple[ return match_from_pairs(
Sequence[Hashable], # matching input key pairs=fq_pairs,
Any, # scores query=pattern.upper(),
Any,
]] = fuzzy.extract(
query=pattern.upper(), # since all keys are uppercase
choices=keys,
score_cutoff=50, 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( async def bars(
self, self,