binance: pre-#520 fixes for `open_cached_client()` import and struct-field casting

basic_buy_bot
Tyler Goodlet 2023-06-20 16:46:30 -04:00
parent c4277ebd8e
commit a44bc4aeb3
1 changed files with 4 additions and 5 deletions

View File

@ -48,11 +48,11 @@ from ..accounting._mktinfo import (
MktPair,
digits_to_dec,
)
from .._cacheables import open_cached_client
from ._util import (
from . import (
resproc,
SymbolNotFound,
DataUnavailable,
open_cached_client,
)
from ._util import (
get_logger,
@ -443,15 +443,14 @@ async def stream_messages(
# decode/encode, see:
# https://jcristharif.com/msgspec/structs.html#type-validation
msg = AggTrade(**msg)
msg.typecast()
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,
}],
}