Report the closest (via fuzzy match) pairs on unmatched input
parent
b734245183
commit
28e8628c61
|
@ -28,8 +28,9 @@ from decimal import (
|
|||
Decimal,
|
||||
)
|
||||
from functools import partial
|
||||
import time
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
import time
|
||||
from typing import (
|
||||
Any,
|
||||
Optional,
|
||||
|
@ -369,6 +370,19 @@ class Client:
|
|||
return cached_pair
|
||||
|
||||
if sym:
|
||||
opt: OptionPair|None = pair_table.get(sym)
|
||||
if not opt:
|
||||
closest_matches: dict[str, Pair] = match_from_pairs(
|
||||
pairs=pair_table,
|
||||
query=sym,
|
||||
score_cutoff=40,
|
||||
)
|
||||
closest_syms: list[str] = list(closest_matches.keys())
|
||||
raise ValueError(
|
||||
f'No contract found for {sym!r}\n\n'
|
||||
f'Closest {len(closest_syms)} available contracts:\n\n'
|
||||
f'{pformat(closest_syms)}\n'
|
||||
)
|
||||
return pair_table[sym]
|
||||
else:
|
||||
return self._pairs
|
||||
|
|
Loading…
Reference in New Issue