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, MktPair,
digits_to_dec, digits_to_dec,
) )
from .._cacheables import open_cached_client from . import (
from ._util import (
resproc, resproc,
SymbolNotFound, SymbolNotFound,
DataUnavailable, DataUnavailable,
open_cached_client,
) )
from ._util import ( from ._util import (
get_logger, get_logger,
@ -443,15 +443,14 @@ async def stream_messages(
# decode/encode, see: # decode/encode, see:
# https://jcristharif.com/msgspec/structs.html#type-validation # https://jcristharif.com/msgspec/structs.html#type-validation
msg = AggTrade(**msg) msg = AggTrade(**msg)
msg.typecast()
yield 'trade', { yield 'trade', {
'symbol': msg.s, 'symbol': msg.s,
'last': msg.p, 'last': msg.p,
'brokerd_ts': time.time(), 'brokerd_ts': time.time(),
'ticks': [{ 'ticks': [{
'type': 'trade', 'type': 'trade',
'price': msg.p, 'price': float(msg.p),
'size': msg.q, 'size': float(msg.q),
'broker_ts': msg.T, 'broker_ts': msg.T,
}], }],
} }