From 735fbc625906391caccaa9ae8df75e9662cc15b3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 1 Jul 2022 11:02:02 -0400 Subject: [PATCH] Raise any error from response --- piker/brokers/kraken/api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index 7fb606dd..8d79873c 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -208,6 +208,7 @@ class Client: self, method: str, data: dict[str, Any] + ) -> dict[str, Any]: uri_path = f'/0/private/{method}' data['nonce'] = str(int(1000*time.time())) @@ -234,18 +235,17 @@ class Client: 'TradesHistory', {'ofs': ofs}, ) - # get up to 50 results - try: - by_id = resp['result']['trades'] - except KeyError: - err = resp['error'] - raise BrokerError(err) - + by_id = resp['result']['trades'] trades_by_id.update(by_id) + # we can get up to 50 results per query if ( len(by_id) < 50 ): + err = resp.get('error') + if err: + raise BrokerError(err) + # we know we received the max amount of # trade results so there may be more history. # catch the end of the trades