diff --git a/piker/brokers/__init__.py b/piker/brokers/__init__.py index 8817842e..0c328d9f 100644 --- a/piker/brokers/__init__.py +++ b/piker/brokers/__init__.py @@ -50,7 +50,7 @@ __brokers__: list[str] = [ 'binance', 'ib', 'kraken', - 'kucoin' + 'kucoin', # broken but used to work # 'questrade', @@ -71,7 +71,7 @@ def get_brokermod(brokername: str) -> ModuleType: Return the imported broker module by name. ''' - module = import_module('.' + brokername, 'piker.brokers') + module: ModuleType = import_module('.' + brokername, 'piker.brokers') # we only allow monkeying because it's for internal keying module.name = module.__name__.split('.')[-1] return module diff --git a/piker/brokers/_util.py b/piker/brokers/_util.py index d35c2578..3588a87a 100644 --- a/piker/brokers/_util.py +++ b/piker/brokers/_util.py @@ -18,10 +18,11 @@ Handy cross-broker utils. """ +from __future__ import annotations from functools import partial import json -import asks +import httpx import logging from ..log import ( @@ -60,11 +61,11 @@ class NoData(BrokerError): def __init__( self, *args, - info: dict, + info: dict|None = None, ) -> None: super().__init__(*args) - self.info: dict = info + self.info: dict|None = info # when raised, machinery can check if the backend # set a "frame size" for doing datetime calcs. @@ -90,16 +91,18 @@ class DataThrottle(BrokerError): def resproc( - resp: asks.response_objects.Response, + resp: httpx.Response, log: logging.Logger, return_json: bool = True, log_resp: bool = False, -) -> asks.response_objects.Response: - """Process response and return its json content. +) -> httpx.Response: + ''' + Process response and return its json content. Raise the appropriate error on non-200 OK responses. - """ + + ''' if not resp.status_code == 200: raise BrokerError(resp.body) try: diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index df2ebd6a..4b16a2d0 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -170,7 +170,7 @@ class Client: method: str, data: dict, ) -> dict[str, Any]: - resp = await self._sesh.post( + resp: httpx.Response = await self._sesh.post( url=f'/public/{method}', json=data, ) @@ -191,7 +191,7 @@ class Client: self._secret, ), } - resp = await self._sesh.post( + resp: httpx.Response = await self._sesh.post( url=f'/private/{method}', data=data, headers=headers,