From bf43036fe10513f5532cacf24d4f381944f9aec8 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 23 Mar 2026 21:36:59 -0400 Subject: [PATCH] Add `MarketNotFound` exc and improve binance fqme error Add a `MarketNotFound(SymbolNotFound)` subclass for mkt-pair-specific lookup failures; use it in binance `get_mkt_info()` with a detailed expected-form hint. Deats, - add `MarketNotFound` in `brokers/_util.py`. - re-export from `brokers/__init__.py`. - binance `feed.py`: swap `SymbolNotFound` import for `MarketNotFound`; build `expected` string showing the `..` format and suggest `".spot."` if venue is missing. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/brokers/__init__.py | 1 + piker/brokers/_util.py | 4 ++++ piker/brokers/binance/feed.py | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/piker/brokers/__init__.py b/piker/brokers/__init__.py index b64231a5..db6a6d1e 100644 --- a/piker/brokers/__init__.py +++ b/piker/brokers/__init__.py @@ -31,6 +31,7 @@ from piker.log import ( from ._util import ( BrokerError, SymbolNotFound, + MarketNotFound as MarketNotFound, NoData, DataUnavailable, DataThrottle, diff --git a/piker/brokers/_util.py b/piker/brokers/_util.py index 5c974c06..3049f4dc 100644 --- a/piker/brokers/_util.py +++ b/piker/brokers/_util.py @@ -66,6 +66,10 @@ class SymbolNotFound(BrokerError): "Symbol not found by broker search" +class MarketNotFound(SymbolNotFound): + "Mkt-pair not found by broker search" + + # TODO: these should probably be moved to `.tsp/.data`? class NoData(BrokerError): ''' diff --git a/piker/brokers/binance/feed.py b/piker/brokers/binance/feed.py index 525ec17d..654252e2 100644 --- a/piker/brokers/binance/feed.py +++ b/piker/brokers/binance/feed.py @@ -48,7 +48,7 @@ import tractor from piker.brokers import ( open_cached_client, NoData, - SymbolNotFound, + MarketNotFound, ) from piker._cacheables import ( async_lifo_cache, @@ -325,9 +325,21 @@ async def get_mkt_info( venue_lower: str = venue.lower() if not venue: - raise SymbolNotFound( + if expiry: + expiry = f'.{expiry}' + expected: str = ( + f'{mkt_ep}' + f'.' + f'{expiry}' + f'.{broker}' + ) + raise MarketNotFound( f'Invalid or missing . part in fqme?\n' + f'\n' f'fqme: {fqme!r}\n' + f'expected-form>> {expected}\n' + f'\n' + f'Maybe you are missing a ".spot." ?\n' ) # XXX TODO: we should change the usdtm_futes name to just