Lol, gotta `float()` that vlm before `*` XD

krakenwsbackup
Tyler Goodlet 2022-07-07 16:27:14 -04:00
parent 5100036e10
commit 2240066a12
1 changed files with 7 additions and 3 deletions

View File

@ -369,6 +369,10 @@ async def handle_order_updates(
defined in the signature clear to the reader.
'''
# transaction records which will be updated
# on new trade clearing events (aka order "fills")
trans: list[pp.Transaction]
async for msg in stream_messages(ws):
match msg:
# process and relay clearing trade events to ems
@ -380,7 +384,7 @@ async def handle_order_updates(
# 'userref': reqid,
{'sequence': seq},
]:
# flatten msgs for processing
# flatten msgs to an {id -> data} table for processing
trades = {
tid: trade
for entry in trades_msgs
@ -726,7 +730,7 @@ def norm_trade_records(
records: list[pp.Transaction] = []
for tid, record in ledger.items():
size = record.get('vol') * {
size = float(record.get('vol')) * {
'buy': 1,
'sell': -1,
}[record['type']]
@ -737,7 +741,7 @@ def norm_trade_records(
pp.Transaction(
fqsn=f'{norm_sym}.kraken',
tid=tid,
size=float(size),
size=size,
price=float(record['price']),
cost=float(record['fee']),
dt=pendulum.from_timestamp(float(record['time'])),