Skip to content

Commit

Permalink
Don't bother casting AggTrade values for now, just floatify the pri…
Browse files Browse the repository at this point in the history
…ce/quantity
  • Loading branch information
goodboy committed Jun 9, 2023
1 parent 1f1b103 commit 4aa1a28
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions piker/brokers/binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ async def _api(
params: dict | OrderedDict,
signed: bool = False,
action: str = 'get'

) -> dict[str, Any]:

if signed:
Expand All @@ -296,7 +297,7 @@ async def _api(
resp = await getattr(self._sesh, action)(
path=f'/api/v3/{method}',
params=params,
timeout=float('inf')
timeout=float('inf'),
)

return resproc(resp, log)
Expand Down Expand Up @@ -476,6 +477,7 @@ async def bars(
async def get_positions(
self,
recv_window: int = 60000

) -> tuple:
positions = {}
volumes = {}
Expand Down Expand Up @@ -509,7 +511,8 @@ async def get_deposits(
return await self._sapi(
'capital/deposit/hisrec',
params=params,
signed=True)
signed=True,
)

async def get_withdrawls(
self,
Expand All @@ -523,7 +526,8 @@ async def get_withdrawls(
return await self._sapi(
'capital/withdraw/history',
params=params,
signed=True)
signed=True,
)

async def submit_limit(
self,
Expand Down Expand Up @@ -732,16 +736,15 @@ 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.typecast()
msg = AggTrade(**msg) # TODO: should we .copy() ?
yield 'trade', {
'symbol': msg.s,
'last': msg.p,
'brokerd_ts': time.time(),
'ticks': [{
'type': 'trade',
'price': msg.p,
'size': msg.q,
'price': float(msg.p),
'size': float(msg.q),
'broker_ts': msg.T,
}],
}
Expand Down

0 comments on commit 4aa1a28

Please sign in to comment.