From 2dc8ee2b4eac3d8ea6a37384a1cc5fa16b73e7d5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 9 Jun 2023 16:05:31 -0400 Subject: [PATCH] Don't bother casting `AggTrade` values for now, just floatify the price/quantity --- piker/brokers/binance.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/piker/brokers/binance.py b/piker/brokers/binance.py index b2150e86..3bbea328 100644 --- a/piker/brokers/binance.py +++ b/piker/brokers/binance.py @@ -60,11 +60,11 @@ from ..accounting._mktinfo import ( MktPair, digits_to_dec, ) -from . import ( +from .._cacheables import open_cached_client +from ._util import ( resproc, SymbolNotFound, DataUnavailable, - open_cached_client, ) from ._util import ( get_logger, @@ -288,6 +288,7 @@ class Client: params: dict | OrderedDict, signed: bool = False, action: str = 'get' + ) -> dict[str, Any]: if signed: @@ -296,7 +297,7 @@ class Client: resp = await getattr(self._sesh, action)( path=f'/api/v3/{method}', params=params, - timeout=float('inf') + timeout=float('inf'), ) return resproc(resp, log) @@ -476,6 +477,7 @@ class Client: async def get_positions( self, recv_window: int = 60000 + ) -> tuple: positions = {} volumes = {} @@ -509,7 +511,8 @@ class Client: return await self._sapi( 'capital/deposit/hisrec', params=params, - signed=True) + signed=True, + ) async def get_withdrawls( self, @@ -523,7 +526,8 @@ class Client: return await self._sapi( 'capital/withdraw/history', params=params, - signed=True) + signed=True, + ) async def submit_limit( self, @@ -732,7 +736,7 @@ async def stream_messages( # ``msgspec.Struct`` does not runtime-validate until you # decode/encode, see: # https://jcristharif.com/msgspec/structs.html#type-validation - msg = AggTrade(**msg) + msg = AggTrade(**msg) # TODO: should we .copy() ? yield 'trade', { 'symbol': msg.s, 'last': msg.p,