From 5d39b04552ed9b0c1d1a44388f627af3bf99b75b Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 1 Jul 2022 11:02:27 -0400 Subject: [PATCH] Invert normalizer branching logic, raise on edge case --- piker/brokers/kraken/api.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index 8d79873c..1c4c8045 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -446,13 +446,16 @@ async def get_client() -> Client: def normalize_symbol( ticker: str ) -> str: - # This is to convert symbol names from what kraken - # uses to the traditional 3x3 pair symbol syntax + ''' + Normalize symbol names to to a 3x3 pair. + + ''' symlen = len(ticker) - if symlen == 6: - return ticker.lower() - else: + if symlen != 6: for sym in ['XXBT', 'XXMR', 'ZEUR']: if sym in ticker: ticker = ticker.replace(sym, sym[1:]) - return ticker.lower() + else: + raise ValueError(f'Unhandled symbol: {ticker}') + + return ticker.lower()