Skip to content

Commit 4aa1a28

Browse files
committed
Don't bother casting AggTrade values for now, just floatify the price/quantity
1 parent 1f1b103 commit 4aa1a28

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

piker/brokers/binance.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ async def _api(
288288
params: dict | OrderedDict,
289289
signed: bool = False,
290290
action: str = 'get'
291+
291292
) -> dict[str, Any]:
292293

293294
if signed:
@@ -296,7 +297,7 @@ async def _api(
296297
resp = await getattr(self._sesh, action)(
297298
path=f'/api/v3/{method}',
298299
params=params,
299-
timeout=float('inf')
300+
timeout=float('inf'),
300301
)
301302

302303
return resproc(resp, log)
@@ -476,6 +477,7 @@ async def bars(
476477
async def get_positions(
477478
self,
478479
recv_window: int = 60000
480+
479481
) -> tuple:
480482
positions = {}
481483
volumes = {}
@@ -509,7 +511,8 @@ async def get_deposits(
509511
return await self._sapi(
510512
'capital/deposit/hisrec',
511513
params=params,
512-
signed=True)
514+
signed=True,
515+
)
513516

514517
async def get_withdrawls(
515518
self,
@@ -523,7 +526,8 @@ async def get_withdrawls(
523526
return await self._sapi(
524527
'capital/withdraw/history',
525528
params=params,
526-
signed=True)
529+
signed=True,
530+
)
527531

528532
async def submit_limit(
529533
self,
@@ -732,16 +736,15 @@ async def stream_messages(
732736
# ``msgspec.Struct`` does not runtime-validate until you
733737
# decode/encode, see:
734738
# https://jcristharif.com/msgspec/structs.html#type-validation
735-
msg = AggTrade(**msg)
736-
msg.typecast()
739+
msg = AggTrade(**msg) # TODO: should we .copy() ?
737740
yield 'trade', {
738741
'symbol': msg.s,
739742
'last': msg.p,
740743
'brokerd_ts': time.time(),
741744
'ticks': [{
742745
'type': 'trade',
743-
'price': msg.p,
744-
'size': msg.q,
746+
'price': float(msg.p),
747+
'size': float(msg.q),
745748
'broker_ts': msg.T,
746749
}],
747750
}

0 commit comments

Comments
 (0)