Lol, gotta `float()` that vlm before `*` XD
parent
9d176c2dda
commit
7d49335f8b
|
@ -368,6 +368,10 @@ async def handle_order_updates(
|
||||||
defined in the signature clear to the reader.
|
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):
|
async for msg in stream_messages(ws):
|
||||||
match msg:
|
match msg:
|
||||||
# process and relay clearing trade events to ems
|
# process and relay clearing trade events to ems
|
||||||
|
@ -379,7 +383,7 @@ async def handle_order_updates(
|
||||||
# 'userref': reqid,
|
# 'userref': reqid,
|
||||||
{'sequence': seq},
|
{'sequence': seq},
|
||||||
]:
|
]:
|
||||||
# flatten msgs for processing
|
# flatten msgs to an {id -> data} table for processing
|
||||||
trades = {
|
trades = {
|
||||||
tid: trade
|
tid: trade
|
||||||
for entry in trades_msgs
|
for entry in trades_msgs
|
||||||
|
@ -725,7 +729,7 @@ def norm_trade_records(
|
||||||
records: list[pp.Transaction] = []
|
records: list[pp.Transaction] = []
|
||||||
for tid, record in ledger.items():
|
for tid, record in ledger.items():
|
||||||
|
|
||||||
size = record.get('vol') * {
|
size = float(record.get('vol')) * {
|
||||||
'buy': 1,
|
'buy': 1,
|
||||||
'sell': -1,
|
'sell': -1,
|
||||||
}[record['type']]
|
}[record['type']]
|
||||||
|
@ -736,7 +740,7 @@ def norm_trade_records(
|
||||||
pp.Transaction(
|
pp.Transaction(
|
||||||
fqsn=f'{norm_sym}.kraken',
|
fqsn=f'{norm_sym}.kraken',
|
||||||
tid=tid,
|
tid=tid,
|
||||||
size=float(size),
|
size=size,
|
||||||
price=float(record['price']),
|
price=float(record['price']),
|
||||||
cost=float(record['fee']),
|
cost=float(record['fee']),
|
||||||
dt=pendulum.from_timestamp(float(record['time'])),
|
dt=pendulum.from_timestamp(float(record['time'])),
|
||||||
|
|
Loading…
Reference in New Issue